Install Ghost with Nginx on CentOS 7

Ghost is a free and open source blogging platform written in JavaScript and built on Node.js, designed to simplify the process of online publishing for individual bloggers as well as online publications.

The Ghost user interface is very simple and straightforward making it great for beginners as well as advanced users.

In this article we will install Ghost with Nginx on a CentOS 7 VPS. We will use our SSD 1 Linux VPS hosting plan with a clean CentOS environment which means that there is no PHP, Nginx and MySQL installed. We will only need PHP-FPM and Nginx for this tutorial, but if you need to install a full LEMP stack on CentOS 7 then you can easily do that by following our excellent article.


As always, make sure your server is fully up-to-date. Also install unzip and a text editor of your choice. We will use nano:

# yum update && yum install unzip nano

Install the EPEL repository after which you will be able to install Node.js and npm:

# yum install epel-release -y

Now install Node.js and npm:

# yum install nodejs npm --enablerepo=epel

Next, install a process manager so you can control your Node.js applications. This process manager will allow you to keep applications alive forever, to reload them without downtime and to facilitate common system admin tasks. Enter the following command:

# npm install pm2 -g

Your next step is to install Nginx and PHP-FPM along with some much needed dependencies:

# yum install nginx php php-fpm php-cli php-mysql php-curl php-gd

Start Nginx and enable it to start on boot:

# systemctl start nginx
# systemctl enable nginx


First, create a directory for your Ghost website:

# mkdir /var/www/html/your_site

Enter the newly created dir:

# cd /var/www/html/your_site

Download the latest Ghost version:

# curl -L https://ghost.org/zip/ghost-latest.zip -o ghost.zip

Unzip the archive:

# unzip ghost.zip

Delete the archive:

# rm ghost.zip

Now install the app with the npm installer:

# npm install -production

After the installation is completed, configure Ghost and update the URL in the config file with your domain. Copy the example config into a new file:

# cp config.example.js config.js

Open the file:

# nano config.js

Find the ‘Production’ section and update the URL with your domain. After modifying it should look like this:

// ### Production
    // When running Ghost in the wild, use the production environment.
    // Configure your URL and mail settings here
    production: {
        url: 'http://your_domain',

Save and close the file.

Now you can use the process manager that we installed earlier to configure Ghost to run forever. Execute the below command:

# NODE_ENV=production pm2 start index.js --name "Ghost"

To start/stop/restart Ghost you can use:

# pm2 start Ghost

# pm2 stop Ghost

# pm2 restart Ghost

Your next step is to configure Nginx to act as a reverse proxy for your Ghost application. Open a config file:

# nano /etc/nginx/conf.d/your_domain.conf

Paste the following:

upstream ghost {

server {
    listen      80;
    server_name your_domain;

    access_log  /var/log/nginx/ghost.access.log;
    error_log   /var/log/nginx/ghost.error.log;

    proxy_buffers 16 64k;
    proxy_buffer_size 128k;

location / {
        proxy_pass  http://ghost;
        proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
        proxy_redirect off;

        proxy_set_header    Host            $host;
        proxy_set_header    X-Real-IP       $remote_addr;
        proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header    X-Forwarded-Proto https;


Don’t forget to replace your_domain with your actual domain. Save and close the file.

Test the Nginx configuration and restart Nginx so the changes can take effect:

# nginx -t

# service nginx restart

Congratulations, you have successfully installed Ghost on your CentOS 7 VPS. Now open your favorite web browser and navigate to http://your_domain/ghost and create an admin user.

For more information about how manage your Ghost blog ,please refer to the their website.

Of course you don’t have to do any of this if you use one of our Linux VPS Hosting services, in which case you can simply ask our expert Linux admins to setup this for you. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

Categories: Tutorials

View Comments

Leave a Comment