In this short how-to I will explain how to get the Ghost publising platform up and running on CentOS 7.
To check if you are up to date run:
sudo yum update -y
Run the following commands to install Node.js from the EPEL repo:
sudo yum install -y epel-release
sudo yum install -y nodejs npm
Or if you prefer installing Node.js from source:
curl -sL https://rpm.nodesource.com/setup | bash -
sudo yum install -y nodejs
sudo npm -g install npm@latest
Download and unzip Ghost with the following commands:
mkdir -p /var/www/
cd /var/www/
curl -L -O https://ghost.org/zip/ghost-latest.zip
unzip -d ghost ghost-latest.zip
cd ghost
sudo npm install --production
Run the following commands to add the ghost user:
sudo useradd -r ghost
sudo chown -R ghost:ghost /var/www/ghost/
We are going to use Apache to proxy to port 80. Run the following commands to install the Apache HTTP server:
sudo yum install -y httpd
Create your virtual host config file /etc/httpd/conf.d/your-site.conf
, add the following content and replace example.com with your domain name :
<VirtualHost *:80>
ServerName example.com
ProxyPreserveHost on
ProxyPass / http://127.0.0.1:2368/
</VirtualHost>
Many guides instruct to use forever or pm2. But you can also do this with systemd. Simply create the systemd service file /etc/systemd/system/ghost.service
with the following content:
[Service]
ExecStart=/usr/bin/node /var/www/ghost/index.js
Restart=always
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=ghost
User=ghost
Group=ghost
Environment=NODE_ENV=production
[Install]
WantedBy=multi-user.target
Now you will be able to manage Ghost via systemd:
systemctl start ghost
systemctl stop ghost
systemctl restart ghost
systemctl status ghost
Time to enable Apache and Ghost and start them. Run the following command to accomplish this:
systemctl enable ghost
systemctl enable httpd
systemctl start ghost
systemctl start httpd
And done!