• Domains
  • Web Hosting
  • WordPress Hosting
  • Reseller Hosting
  • Cloud VPS
  • Dedicated Servers
  • Domains
  • Web Hosting
  • WordPress Hosting
  • Reseller Hosting
  • Cloud VPS
  • Dedicated Servers
home/Knowledge Base/Web Servers/Nginx Reverse Proxy with Ghost on Ubuntu 14.04
Popular Search:Dedicated Server, CentOS, Web Hosting

Nginx Reverse Proxy with Ghost on Ubuntu 14.04

24 views 0 December 6, 2019 aklwebhost

Ghost is a free and open source blogging platform written in node.js, completely customizable and dedicated for publishing.

Prepare the server: Update packages, Install Node.js and NPM

We’ll demonstrate the installation by logging into the server as root, so that we will not need to add sudo before each command. If you are logged as another user, remember that you will need sudo.

On your server, run the following to update the package index, upgrade packages, and install nodejs and npm.

apt-get update
apt-get upgrade

apt-get install python software-properties-common gcc g++ make -y  # auto install
add-apt-repository ppa:chris-lea/node.js -y

The output from these commands should be similar to:

gpg: keyring `/tmp/tmpvpe2ugzj/secring.gpg' created
gpg: keyring `/tmp/tmpvpe2ugzj/pubring.gpg' created
gpg: requesting key C7917B12 from hkp server keyserver.ubuntu.com
gpg: /tmp/tmpvpe2ugzj/trustdb.gpg: trustdb created
gpg: key C7917B12: public key "Launchpad chrislea" imported
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)
OK

Automatically, the package signing key will be added to the keyring (so that the packages downloaded can be verified), and the PPA will be added to APT’s sources.list.d.

Now, let’s run:

apt-get update  # again 
apt-get install nodejs -y

Run npm to test the installation. You will see npm‘s usage printed to the screen:

Usage: npm <command>
...
...
npm@1.4.28 /usr/lib/node_modules/npm

Now we can install Ghost.

Installation: Ghost and Nginx

Since Ghost is now considered “stable”, it can be installed through npm. Install with the following command:

npm install -g ghost --production

Ignore any warnings for now.

Next, we will start Ghost and check if it’s working properly.

cd /usr/lib/node_modules/ghost
npm start --production

Output should look like this:

> ghost@0.5.2 start /usr/lib/node_modules/ghost
> node index

Migrations: Database initialisation required for version 003
...
Migrations: Complete
Ghost is running... 
Your blog is now available on http://my-ghost-blog.com 
Ctrl+C to shut down

It works! Use Ctrl-C to shut down Ghost, and move on to the next step: installing (and configuring) Nginx.

Nginx is very simple to install. Run the following command:

apt-get install nginx

Nginx will be configured to allow connection from anywhere in the wild to port 80 (or 443, if using SSL) on your server, which is then forwarded (“proxied“) to Ghost. This is how people connect to your blog.

Configuring Nginx is not that hard, either. Follow these steps to configure the Ghost proxy.

First, remove the default configuration file:

cd /etc/nginx/
rm sites-enabled/default

Then, make a new configuration file:

cd sites-available
touch ghost

Adapt the following lines to your need and use something like nano or vi to paste it in (you’ll need to set server_name to your domain name):

server {
    listen 80;
    server_name yourdomain.tld;
    access_log /var/log/nginx/yourdomain.tld.log;  # if you want logging

    location / {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header HOST $http_host;       
        proxy_pass http://127.0.0.1:2368;
        proxy_redirect off;
    }
}

Symlink your configuration file:

cd /etc/nginx
ln -s sites-available/ghost sites-enabled/ghost

Restart Nginx:

service nginx restart

At this point, Nginx is installed, configured, and running on your server.

Finally: Start Ghost Automatically

Supervisor is a process control system which allows you to run Ghost at startup without using init scripts. We will be installing Supervisor to manage Ghost.

To install Supervisor, run:

apt-get install supervisor
service supervisor start

Then, create a new script file in /etc/supervisor/conf.d/ghost.conf. Paste in these contents:

[program:ghost]
command = node /usr/lib/node_modules/ghost/index.js
directory = /usr/lib/node_modules/ghost
user = ghost
autostart = true
autorestart = true
stdout_logfile = /var/log/supervisor/ghost.log
stderr_logfile = /var/log/supervisor/ghost_err.log
environment = NODE_ENV="production"

Save and close the file.

Next, we need to create a user for Ghost and give it permissions to access the Ghost files and database. Run the following commands:

useradd ghost
chown -R ghost /usr/lib/node_modules/ghost/
supervisorctl reread
supervisorctl update

Our setup is complete!

Now you can control Ghost by executing supervisorctl start ghost and supervisorctl stop ghost.

Tags:Nginx Reverse Proxy with Ghost on Ubuntu 14.04

Was this helpful?

Yes  No
Related Articles
  • Setup Spigot Server on Arch Linux
  • How To Install OSSEC HIDS on a CentOS 7 Server
  • Initial Setup of a CentOS 7 Server
  • Using StrongSwan for IPSec VPN on CentOS 7
  • Hot Backups with Percona XtraBackup on the One-Click WordPress App
  • Installing Rust on Ubuntu 14.04
Leave A Comment Cancel reply

Web Servers
  • Nginx Reverse Proxy with Ghost on Ubuntu 14.04
  • How To Setup Apache on Windows Server
  • Setting up IIS on Windows Server
  • Setup NGINX, PHP-FPM, and MariaDB on Debian 8
  • Apache Virtual Hosts on Ubuntu 14.04 LTS
  • Install Lighttpd with PHP5 and MySQL (LLMP Stack) on Ubuntu 14.04
View All 37  
Popular Articles
  • Using StrongSwan for IPSec VPN on CentOS 7
  • Disabling SSDP (Linux / Windows)
  • Can I pay by Western Union?
  • Can a Coupon Code Discount Be Carried Forward While I Upgrade My VPS Account
  • Can I pay multiple due invoices using a single transaction?
KB Categories
  • Billing
  • Cloud Hosting
  • CMS Hosting
  • cPanel/WHM Control Panel Guide
  • Dedicated Servers
    • AMD Opteron 6272
    • Arch
    • Backup Storage
    • Bandwidth
    • Basic Security
    • BSD
    • CentOS
    • Containers
    • CoreOS
    • DDoS Protection
    • Debian
    • Dedicated Server Control Panel
    • Intel Core i5 3550
    • Intel Core i5 4570
    • Intel Core i7 3770
    • Intel Core i7 4770
    • Intel Xeon E3 1230 V3
    • Intel Xeon E3 1245 V2
    • IP Space
    • Linux Guides
    • Minecraft
    • Networking
    • Server Apps
    • Server Troubleshooting
    • Ubuntu
    • Windows Guides
    • Windows Server 2008
    • Windows Server 2012
  • Domain Names
  • Email Support Documentation
    • Setup IMAP or POP
    • User Features – How To
    • Webmail – How To
  • FTP (File Transfer Protocol
    • CuteFTP Guide
    • FileZilla Guide
  • Game Servers
  • MySQL and MariaDB
  • Node.js
  • Plesk Web Hosting Guide
  • VPS Server
  • Web Servers

  Monitor Debian Server Status with Munin

On CoreOS, Setup Your Own Docker Registry  

  • Privacy Policy
  • Terms of Use
  • © 2022 AKLWEB HOST LLC, All Rights Reserved.

Popular Search:Dedicated Server, CentOS, Web Hosting