Knowledge Base

How to install Ghost manually on a shared hosting account

This article describes how to install the Ghost blogging platform manually.

This article assumes that you have already installed Node.js on your account. If you have not done this yet, please see this article.
To install Ghost, your account must have the normal shell (not jailshell) enabled. To determine which shell your account is using, type the following command at the command line:
echo $SHELL
If your account is using jailshell, please submit a support ticket on the Customer Portal at https://my.a2hosting.com and request normal shell access for your account.

Installing Ghost

To install Ghost on your account, follow these steps:

  1. Log in to your account using SSH.
  2. At the command prompt, type the following commands to download Ghost:
    cd ~
    wget --no-check-certificate https://ghost.org/zip/ghost-0.7.8.zip
  3. To extract the Ghost files into a directory named ghost, type the following command:

    unzip -d ghost ghost-0.7.8.zip
  4. To install Ghost, type the following commands:

    cd ~/ghost
    npm install --production
  5. Ghost is now installed. However, it will not run until you complete some additional configuration steps.

Configuring Ghost

To configure Ghost, follow these steps:

  1. At the command prompt, type the following commands:
    cd ~/ghost
    cp config.example.js config.js
  2. Open the config.js file in a text editor. Locate the production section:

    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'
            }
        },
  3. Change the url value to your site's domain name. For example, if your domain name is example.com, replace http://my-ghost-blog.com with http://example.com.
  4. Under server, change the port value to the port on which Ghost runs.

    To run Ghost on a shared server, you must choose an unused port, and the port number must be between 49152 and 65535 (inclusive).
  5. By default, Ghost uses a SQLite database. If you want to use MySQL instead, modify the database settings in the production section as follows. Additionally, replace the username_databasename, username_dbusername, and user_password values with the correct values for your MySQL database:

    database: {
        client: 'mysql',
        connection: {
            host: 'localhost',
            user: 'username_dbusername',
            password: 'user_password',
            database: 'username_databasename',
            charset: 'utf8'
        },
        debug: false
    },
    
  6. Save the changes to the config.js file, and then exit the text editor.
  7. In a text editor, add the following lines to the .htaccess file in the /home/username/public_html directory, where username represents your account username:

    RewriteEngine On
    RewriteRule ^$ http://127.0.0.1:XXXXX/ [P,L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ http://127.0.0.1:XXXXX/$1 [P,L]
  8. In both RewriteRule lines, replace XXXXX with the port you specified in step 4.
  9. Save the changes to the .htaccess file, and then exit the text editor.
  10. To start Ghost, type the following command:

    cd ~/ghost
    nohup npm start --production &
    If Ghost fails to start, the port you chose may already be in use. Check the application log or nohup.out file for error codes like EADDRINUSE that indicate the port is in use. If it is, select a different port number for your application, update the config.js and .htaccess files with the new port number, and then try again.

More Information

For more information about the Ghost blogging platform, please visit http://ghost.org.