Ghost is a relatively new blog publishing platform which started out as a £25,000 Kickstarter project. While WordPress is still the dominant blogging tool on the web, it has now evolved into a general content management platform with tons of third party developed features, and over time has become increasingly cumbersome and complex to maintain. On the other hand, now only a couple of months old, Ghost promises to remain as a pure blogging platform with slick user-centric publishing interface.
In this tutorial, I will describe how to set up Ghost blogging platform on Linux.
Install Ghost on Linux
Ghost is powered by Node.js. Therefore, first install Node.js on your Linux system. Make sure that the version of Node.js is 0.10 or higher.
Next, log in to http://ghost.org (sign-up needed), and download the source code of Ghost. Then follow the procedure below to install Ghost.
$ sudo unzip ghost-0.3.3.zip -d /var/www/ghost
$ cd /var/www/ghost
$ sudo npm install --production
Configure Ghost Before Launching
Before launching Ghost, create its configuration file located at /var/www/ghost/config.js as follows. Replace "YOUR_IP" with the IP address of your host.
$ sudo cp config.example.js config.js
$ sudo sed -i 's/127.0.0.1/YOUR_IP/g' config.js
Test-Run Ghost in Development Mode
At this point, you are ready to launch Ghost.
Note that Ghost can run in two different modes: "development" and "production" modes. For safety, Ghost maintains configuration info of two modes separately in its configuration file (/var/www/ghost/config.js). For example, the two different modes use different database files (i.e., ghost-dev.db and ghost.db located in /var/www/ghost/content/data).
Use the following commands to launch Ghost. Ghost runs in development mode by default.
$ sudo npm start
If Ghost is launched successfully, you should see the following output in the terminal, indicating that Ghost is running on <YOUR_IP>:2368.
Go to http://<YOUR_IP>:2368 on your web browser, and verify that you can see the following initial Ghost page.
Launch Ghost in Production Mode
After you have verified that Ghost runs okay, stop Ghost in development mode by pressing Ctrl+C. Now it is time to launch Ghost in production mode.
When you run Ghost in production mode, you can use Node.js module called forever, which allows you to daemonize Ghost, and run it as a background process.
To install forever module:
Finally, launch Ghost in production mode as follows:
$ sudo NODE_ENV=production forever start index.js
Verify that Ghost's database is successfully created in production mode (/var/www/ghost/content/data/ghost.db).
You can also check a list of active forever processes.
info: Forever processes running data: uid command script forever pid logfile uptime data:  cH0O /usr/bin/nodejs index.js 15355 15357 /home/dev/.forever/cH0O.log 0:0:0:37.741
If you see output like the above, it means that Ghost is running in the background successfully.
To stop Ghost daemon, run the following command.
$ sudo forever stop index.js
Subscribe to Xmodulo
Do you want to receive Linux FAQs, detailed tutorials and tips published at Xmodulo? Enter your email address below, and we will deliver our Linux posts straight to your email box, for free. Delivery powered by Google Feedburner.
Did you find this tutorial helpful? Then please be generous and support Xmodulo!