Next change directories to where you have downloaded and expanded Ghost in your terminal application:

cd /path/to/ghost/folder/

Next configuration step is to tell Heroku how to start Ghost. You can do this with a Procfile. In your local Ghost directory create a text file named Procfile:

sudo vi Procfile

and insert:

web: npm start --production

save and exit.

Next we need to create the Heroku app and tell git where to send our repository.

heroku create

</ br>The heroku create command creates a new Heroku app where you can see and configure your site in the Heroku web interface. It also creates a new git remote which tells git where to send your files. You can verify your git remote was setup correctly by running git remote -v. Mine looks like this:

Next we need to edit the Ghost configurations, in the config.js file. Heroku assigns a port for your Node app dynamically every time it starts. The Ghost config.js assumes that the port will be constant but this setup will not work in the Heroku environment. To overcome this we can use the environment variable process.env.PORT. Heroku assigns the port number Ghost needs to listen on to that variable.

Edit your config file:

sudo vi config.js

In your config.js file replace:

host: '127.0.0.1',
port: '2368'

with

host: '0.0.0.0',
port: process.env.PORT

The last step we need to do is modify how Ghost stores images so that they are persistant. Heroku does not provide persistant storage for things like image uploads. With the release of Ghost 0.6.0 we now have the ability to modify where Ghost stores images. We recomend this project that allows Ghost to stores images on Amazon S3.

Now add all the Ghost files to git so they can be pushed to Heroku by running the following commands from within your Ghost directory:

git add .
git commit -m "Committing all Ghost files"

You now have Ghost in a local git repository.

Now you are ready to deploy Ghost to Heroku:

git push heroku master

This process will take about a minute. It will copy all of the local files up to Heroku. Once this is done your Ghost instance is up and running on Heroku. You can connect to your Ghost instance in your web browser by running heroku open

Security

To avoid storing your database credentials in your config.js file you can store them in Heroku environmental variables. To do this replace the database section in your config.js file with the following:

Now we just need to populate those variables with the credentials for your database. You can do that with the following commands (replacing host, user, password, database with the values from your Heroku account)

Configuring Ghost to use the Heroku environment variables could certainly avoid a situation where your config.js was committed to a public repository.

Possible Errors:

If you can not connect to Ghost try and run heroku ps to see if your instance is running or crashed. If it has crashed run heroku logs to see why. If you can't figure out why it has crashed post a comment and we will help you out.

When running git push heroku master if you get the error:

Permission denied (publickey).
fatal: The remote end hung up unexpectedly

Your ssh key was probably not sent during the initial Heroku Toolset login. You can fix this with heroku keys:add ~/.ssh/id_rsa.pub replacing the path with your actual path.