< Back

I Finally Managed to Deploy Ghost via Git to a Ubuntu Apache server

After many struggles and not-so-many “Aha” moments, I managed to get Ghost running on my Apache box. Here’s how I did it.

Steps

1. Pull down the latest Ghost source on your dev machine.

2. Get Ghost fired up and running from terminal in your project’s directory:

~ $ npm install
~ $ npm start

3. Update Ghost’s config.js production url setting with the domain you want your project to serve from.

production: {
        url: 'http://example.com',
        mail: {},
        database: {
            client: 'sqlite3',
            connection: {
                filename: path.join(__dirname, '/content/data/ghost.db')
            },
            debug: false
        },
        server: {
            host: '127.0.0.1',
            port: '2368'
        }
    }, 

4. On the Ubuntu box, set up a Git repo for Ghost and push up your local source. I recommend using a Git workflow to help the deployment process.

5. Configure Apache to route requests from your domain to Ghost’s local server.

<VirtualHost *:80>
        ServerName example.com

        <proxy *>
                order deny,allow
                allow from all
        </proxy>
        <location />
                ProxyPass http://localhost:2368/
                ProxyPassReverse http://localhost:2368/
        </location>
</VirtualHost>

Don?t forget to restart Apache.

~ $ sudo service apache2 restart

6. Install the latest versions of Node and NPM on the server. One caveat, I originally installed these tools using apt-get like so:

~ $ sudo apt-get install nodejs
~ $ sudo apt-get install npm

However, when Node refused to start and after several hours of head-banging, I realized that my local machine’s versions of both were much much newer. So, to update to the latest version of Node, I needed to reference Chris Lea’s repository.

~ $ sudo add-apt-repository ppa:chris-lea/node.js  
~ $ sudo apt-get update  
~ $ sudo apt-get install nodejs

7. Finally, fire up Node from your Ghost directory.

~ $ npm start --production

(Next) Steps

If you managed to get Ghost up and running on your box, you probably want some tools that make life easier. Particularly, consider running Ghost using Forever or Supervisor. You can configure node to run as a background task and help recover if anything nasty happens.

Connect with us

Thank You!

We really appreciate your interest in what we do.

We'll get back to you as soon as we can.