Make Gadgets Work

Ghost on Fedora 24

Ankit Mittal

To install Ghost as my blogging platform, I had to go through a number of hoops and one of them was to get the nodejs working and what not. I figured this might as well be worth documenting in case I have to do this all over again. It might also be helpful for some other inquisitive minds. :)

The most useful reference I found was the post on rosehosting website specific to CentOS 71

It would have all gone well too; had it not been for the nodejs related issues which resulted in me finding the other helpful pointers from various forums.

Anyway, the steps I took to get this all working are:

These are detailed in my notes below - keeping it, where I can, true to the post I have referred above:

Step 1: Install nodejs and npm

On Fedora 24 node.js package already includes npm and if you try installing npm separately it will throw an error so just install node.js and npm will be installed along with it.

sudo dnf distro-sync  
sudo dnf install nodejs

Step 2: Install dependencies

sudo dnf install php php-fpm php-cli php-mysql php-curl php-gd

#Create a directory for the website:
mkdir /var/www/html/[sitefolder. eg: blog, myblog, banana] 

#Change to the newly created directory:
cd /var/www/html/[sitefolder. eg: blog, myblog, banana] 

#Set access permissions for this directory
chown -R /var/www/html/[sitefolder. eg: blog, myblog, banana]

#Download latest version of Ghost:
curl -L -o

#Unzip the downloaded file

#Finally check the directory structure
tree -L 2

#OUTPUT of above command should look like as shown below:
├── config.example.js
├── config.js
├── content
│   ├── apps
│   ├── data
│   ├── images
│   └── themes
├── core
│   ├── built
│   ├── index.js
│   ├── server
│   └── shared
├── Gruntfile.js
├── index.js
├── npm-shrinkwrap.json
├── package.json

Step 3: Install npm modules

While installing/initiating npm modules, there were several errors that system was throwing. They were in two categories:

Access Related - I was getting EACCES error and solution given on on under Option 2 is what sorted the access issues 2.

mkdir ~/.npm-global  
npm config set prefix '~/.npm-global'  
nano ~/.profile

Add the line export PATH=~/.npm-global/bin:$PATH in the opened file.

source ~/.profile

Dependencies Related - Some forum hopping later I just followed the advice on Ghost support3 and installed the dependencies. Steps below:

#install required dependencies:  
npm install -g node-gyp  
sudo dnf install gcc gcc-c++

Once above dependencies are installed following code should just work.


Make sure you are in the directory you created in step2.

#Install PM2 a process manager to control Node.js applications  
#It will help in keeping specified Node.js applications alive forever:
npm install pm2 -g  
npm install --production  
#Start Ghost with pm2 and create a name for the pm2
NODE_ENV=production pm2 start index.js --name "Ghost"  

Step 4: Tell Ghost your blog URL

A very simple change is required to config.js file as shown below:

#Copy the sample config file  
cp config.example.js config.js  
nano config.js

File that opens will have following javascript:

// # Ghost Configuration  
// Setup your Ghost install for various [environments]($

// Ghost runs in `development` mode by default. Full documentation can be found$

var path = require('path'),  

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

It's the line number 14 in above code block where you need to replace with actual url of your blog.

Step 4: Configure Nginx

NGINX install and configuration is something I covered in my post for installing Seafile on Fedora 244. So I already had a running nginx. I just needed to create a reverse proxy for Ghost on the existing nginx server.

Open the hostfile using following command:

sudo nano /etc/hosts

Now in the hosts file add the localhost alias for blog - in this example it is  localhost.localdomain localhost

Open the file using following command.


Replace `yourblog.conf` with your actual blog's conf file name.

nano /etc/nginx/conf.d/yourblog.conf

On the file that opens copy and paste the following code.


Replace `` on line number 6 below with alias for localhost for this blog you added to the host file above.

upstream ghost {  
server {  
     listen      80;
     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;

Step 5: Start Ghost and nginx

After all the above steps are completed issue following commands to restart ghost and nginx.

sudo systemctl restart nginx.service  
pm2 restart Ghost

All Done !!!