Installing ghost on CENTOS 7 with nginx

Installing Ghost on a CENTOS 7 server that already runs nginx

Install the required nodejs and npm:
root@server# yum install nodejs npm

Install Ghost using npm:
root@server# npm install ghost

Install Process Manager:
root@server# npm install pm2 -g

Create a directory for the installation
root@server# mkdir -p /var/www/ghost ; cd /var/www/ghost

Download the latest Ghost release:
root@server# curl -L https://ghost.org/zip/ghost-latest.zip -o ghost.zip

Unzip package:
root@server# unzip -uo ghost.zip -d ghost

Move from ghost subdirectory to the base directory
root@server# mv ghost/* .

Cleanup:
root@server# rmdir ghost root@server# rm ghost.zip

Install the application
root@server# npm install -production

Copy the sample config file:
root@server# cp config.example.js config.js

Edit url in file node.js to your yourdomain.com

From:
url: 'http://my-ghost-blog.com',
To:
url: 'http://yourdomain.com',

Start ghost:
root@server# NODE_ENV=production pm2 start index.js --name "Ghost"

Configure your nginx to forward traffic from port 80 to port 2368 usually in the file /etc/nginx/conf.d/yourdomain.com.conf:

root@server# server { listen 0.0.0.0:80; server_name yourdomain.com; access_log /var/log/nginx/yourdomain.log;

location / {
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header HOST $http_host;
    proxy_set_header X-NginX-Proxy true;

    proxy_pass http://127.0.0.1:2368;
    proxy_redirect off;
}

}

Restart nginx:
root@server# systemctl restart nginx.service