Setup Ghost on GoDaddy cPanel Shared Hosting

Ghost on GoDaddy

There are many How-To installation guides for Ghost floating about the internet but so very few are tailored for shared hosting. Rightfully so, the general consensus is that Ghost will not run on shared hosting. Certainly not on a shared hosting platform that doesn't offer Softaculus or it's own specific Node.js hosting. This post will serve as a how-to for setting up your own Ghost installation on GoDaddy's cPanel shared hosting (may also work for other shared hosting providers that utilize cPanel).

Steps

  1. Build/Install Node.js
  2. Install/Configure Ghost
  3. Create .htaccess
1.Build/Install Node.js
  1. Log in to your account via SSH
  2. Ensure you're in the root of your home directory and set a TMP directory:
    cd ~ export TMPDIR=~/tmp
  3. Download the latest version of Node.js
    wget http://nodejs.org/dist/node-latest.tar.gz
  4. Extract the archive
    tar xzf node-latest.tar.gz
  5. Build Node.js (this make take a few minutes)
    cd node-vX.X.X ./configure --prefix=~ make && make install
  6. Install npm modules for SQLite and MySQL
    npm install sqlite3 npm install mysql
  7. That's it! Node.js should now be installed and ready for use.
2.Install/Configure Ghost
  1. Log in to your account via SSH
  2. Download the latest version of Ghost (v.0.4.2 as of this writing)
    cd ~ wget --no-check-certificate https://ghost.org/zip/ghost-0.4.2.zip
  3. Unzip ghost to website document root
    unzip -d public_html ghost-0.4.2.zip
  4. Install Ghost
    cd public_html/ npm --install production
  5. Now to configure ghost by modifying the config file.
    cp config.example.js config.js vim config.js
  6. Use vim (or your editor of choice) to modify the production section. You will need to modify the following:
    url(your site's URL):
    host(shared server IP address):
    port(any port between 49152 and 65536 that's not already in use):
production: {  
        <url: 'http://my-ghost-blog.com',
        mail: {},
        database: {
            client: 'sqlite3',
            connection: {
                filename: path.join(__dirname, '/content/data/ghost.db')
            },
            debug: false
        },
        server: {
            // Host to be passed to node's `net.Server#listen()`
            host: '127.0.0.1',
            // Port to be passed to node's `net.Server#listen()`, for iisnode set this to `process.env.PORT`
            port: '2368'
        }
    },

7.Save your changes, configuration is complete!
8.To start Ghost (and keep in running in the background)
nohup npm start --production &

3.Create .htaccess file
  1. Create a .htacccess file in your site's document root. You can upload one via FTP, use SSH, or use the FileManager within cPanel if you'd like.
  2. Insert the following into your .htaccess file:
DirectoryIndex  
RewriteEngine On  
RewriteRule ^$ http://example.com:55555/$1 [P]  
RewriteCond %{REQUEST_FILENAME} !-f  
RewriteCond %{REQUEST_FILENAME} !-d  
RewriteRule ^(.*)$ http://example.com:55555/$1 [P]  

3.Change out example.com for your own URL and 55555 for the port you set in your config.js file


Update:

I've created a new article that will show you how to run Ghost without the need to nohup the process in the background. It utilizes the forever npm module and can be found here


Congratulations! You've just setup and configured a Ghost installation on your GoDaddy cPanel shared hosting account. You can now access the Ghost admin via http://yoururlhere.com/ghost/ and start blogging away.

If you want to use MySQL instead of a SQLite database you'll simply need to setup a databse and user in cPanel and edit the necessary section in your config.js. Be sure to comment out the sqlite section! Also worth noting, if your Node.js server ever dies you'll need to manually log in and re-run the npm start command from the Ghost directory. Perhaps a future post will entail host to create a cron-job to do this for you.