Running Ghost with Node v5 (Ubuntu 14.04LTS)
Updated: 13 Apr 16
Ghost is a blogging platform that makes it so easy to set up a really beautiful blog.
As I was setting this up, I went through trouble as Node v5 is not supported by Ghost.
I am running node v5.6.0 and npm v3.7.5 which are currently the latest.
To set up Ghost with Node v5, do the following:
Use
sudowhen needed
Move to your web directory and create a folder for the blog:
cd /var/www mkdir blog cd blogGet the latest Ghost and unzip it:
wget https://ghost.org/zip/ghost-latest.zip unzip ghost-latest.zipInstall for production mode without checking for node version:
GHOST_NODE_VERSION_CHECK=false npm install --productionInstall
sqlite3v3.1.0 locally:Note: In Ghost >=0.7.8, step 4 is not needed anymore.
npm install sqlite3@3.1.0Run your Ghost in production mode without checking for node version:
GHOST_NODE_VERSION_CHECK=false npm start --productionIt should run fine, as it just did with me. Copy the configuration and edit it as needed:
cp config.example.js config.js vim config.jsTo run it in a service deamon:
GHOST_NODE_VERSION_CHECK=false NODE_ENV=production forever start index.js
Setting up nginx server block for Ghost
After setting up Ghost over a port, one could use nginx to proxy pass the port to a subdomain.
Create a new server block in
conf.dorsites-available(depending on what you use):cd /etc/nginx/conf.d touch blog.confEdit your server block as follows:
server { listen 80; server_name blog.z-proj.com; access_log /var/log/nginx/blog.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:3010; proxy_redirect off; } }Edit the subdomain and the port as needed.
Reload nginx configuration:
sudo nginx -s reload
Your blog should be now available at your subdomain.
Setting up service upstart
To set the service to start when your server boots up, do the following:
Create a new
init.dscript:sudo curl https://raw.githubusercontent.com/TryGhost/Ghost-Config/master/init.d/ghost \ -o /etc/init.d/ghostAllow it to run as a script:
sudo chmod +x /etc/init.d/ghostEdit the contents to match your directories:
sudo vim /etc/init.d/ghost GHOST_ROOT=/var/www/blog GHOST_GROUP=www-data GHOST_USER=ubuntu export GHOST_NODE_VERSION_CHECK=false NODE_ENV=productionStop forever if it is still running, and start the blog using the
init.dscript:sudo service ghost startSet it to run at system start:
sudo update-rc.d ghost defaults sudo update-rc.d ghost enable
Your blog setup is now complete.
I have also written a Ghost init.d script for Centos 7.0. You can find it here.