Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794
{"id":2505,"date":"2019-12-06T00:40:02","date_gmt":"2019-12-06T00:40:02","guid":{"rendered":"https:\/\/support.aklwebhost.com\/?post_type=manual_kb&p=2505"},"modified":"2019-12-06T23:42:34","modified_gmt":"2019-12-06T23:42:34","slug":"nginx-reverse-proxy-with-ghost-on-ubuntu-14-04","status":"publish","type":"manual_kb","link":"https:\/\/support.aklwebhost.com\/knowledgebase\/nginx-reverse-proxy-with-ghost-on-ubuntu-14-04\/","title":{"rendered":"Nginx Reverse Proxy with Ghost on Ubuntu 14.04"},"content":{"rendered":"

Ghost<\/strong>\u00a0is a free and open source blogging platform written in\u00a0node.js<\/em>, completely customizable and dedicated for publishing.<\/p>\n

Prepare the server: Update packages, Install Node.js and NPM<\/h2>\n

We’ll demonstrate the installation by logging into the server as\u00a0root<\/code>, so that we will not need to add\u00a0sudo<\/code>\u00a0before each command. If you are logged as another user, remember that you will need\u00a0sudo<\/code>.<\/p>\n

On your server<\/strong>, run the following to update the package index, upgrade packages, and install\u00a0nodejs<\/code>\u00a0and\u00a0npm<\/code>.<\/p>\n

apt-get update\r\napt-get upgrade\r\n\r\napt-get install python software-properties-common gcc g++ make -y  # auto install\r\nadd-apt-repository ppa:chris-lea\/node.js -y\r\n<\/code><\/pre>\n

The output from these commands should be similar to:<\/strong><\/p>\n

gpg: keyring `\/tmp\/tmpvpe2ugzj\/secring.gpg' created\r\ngpg: keyring `\/tmp\/tmpvpe2ugzj\/pubring.gpg' created\r\ngpg: requesting key C7917B12 from hkp server keyserver.ubuntu.com\r\ngpg: \/tmp\/tmpvpe2ugzj\/trustdb.gpg: trustdb created\r\ngpg: key C7917B12: public key \"Launchpad chrislea\" imported\r\ngpg: Total number processed: 1\r\ngpg:               imported: 1  (RSA: 1)\r\nOK\r\n<\/code><\/pre>\n

Automatically, the package signing key will be added to the keyring (so that the packages downloaded can be verified), and the\u00a0PPA will be added to APT’s<\/strong>\u00a0sources.list.d<\/code>.<\/p>\n

Now, let’s run:<\/p>\n

apt-get update  # again \r\napt-get install nodejs -y\r\n<\/code><\/pre>\n

Run\u00a0npm<\/code>\u00a0to\u00a0test the installation<\/strong>. You will see\u00a0npm<\/code>‘s usage printed to the screen:<\/p>\n

Usage: npm <command>\r\n...\r\n...\r\nnpm@1.4.28 \/usr\/lib\/node_modules\/npm\r\n<\/code><\/pre>\n

Now we can install Ghost.<\/strong><\/p>\n

Installation: Ghost and Nginx<\/strong><\/h2>\n

Since Ghost is now considered “stable”, it can be installed through\u00a0npm<\/code>. Install with the following command:<\/p>\n

npm install -g ghost --production\r\n<\/code><\/pre>\n

Ignore any warnings for now.<\/strong><\/p>\n

Next, we will\u00a0start Ghost<\/strong>\u00a0and check if it’s working properly.<\/p>\n

cd \/usr\/lib\/node_modules\/ghost\r\nnpm start --production\r\n<\/code><\/pre>\n

Output should look like this:<\/strong><\/p>\n

> ghost@0.5.2 start \/usr\/lib\/node_modules\/ghost\r\n> node index\r\n\r\nMigrations: Database initialisation required for version 003\r\n...\r\nMigrations: Complete\r\nGhost is running... \r\nYour blog is now available on http:\/\/my-ghost-blog.com \r\nCtrl+C to shut down\r\n<\/code><\/pre>\n

It works! Use\u00a0Ctrl-C<\/strong>\u00a0to shut down Ghost, and move on to the next step: installing (and configuring) Nginx.<\/p>\n

Nginx is very simple to install. Run the following command:<\/strong><\/p>\n

apt-get install nginx\r\n<\/code><\/pre>\n

Nginx will be configured to allow connection from anywhere in the wild to\u00a0port 80 (or 443, if using\u00a0SSL<\/em>)<\/strong>\u00a0on your server, which is then forwarded\u00a0(“proxied<\/em>“)<\/strong>\u00a0to Ghost. This is how people connect to your blog.<\/p>\n

Configuring Nginx<\/strong>\u00a0is not that hard, either. Follow these steps to configure the\u00a0Ghost proxy.<\/strong><\/p>\n

First, remove the default configuration file:<\/p>\n

cd \/etc\/nginx\/\r\nrm sites-enabled\/default\r\n<\/code><\/pre>\n

Then, make a new configuration file:<\/strong><\/p>\n

cd sites-available\r\ntouch ghost\r\n<\/code><\/pre>\n

Adapt the following lines to your need and use something like\u00a0nano<\/code>\u00a0or\u00a0vi<\/code>\u00a0to paste it in (you’ll need to set\u00a0server_name<\/code>\u00a0to your domain name):<\/p>\n

server {\r\n    listen 80;\r\n    server_name yourdomain.tld;\r\n    access_log \/var\/log\/nginx\/yourdomain.tld.log;  # if you want logging\r\n\r\n    location \/ {\r\n        proxy_set_header X-Real-IP $remote_addr;\r\n        proxy_set_header HOST $http_host;       \r\n        proxy_pass http:\/\/127.0.0.1:2368;\r\n        proxy_redirect off;\r\n    }\r\n}\r\n<\/code><\/pre>\n

Symlink your configuration file:<\/strong><\/p>\n

cd \/etc\/nginx\r\nln -s sites-available\/ghost sites-enabled\/ghost\r\n<\/code><\/pre>\n

Restart Nginx:<\/strong><\/p>\n

service nginx restart\r\n<\/code><\/pre>\n

At this point,\u00a0Nginx is installed<\/strong>, configured, and running on your server.<\/p>\n

Finally: Start Ghost Automatically<\/strong><\/h2>\n

Supervisor<\/strong>\u00a0is a process control system which allows you to run Ghost at startup without using init scripts. We will be installing Supervisor to manage Ghost.<\/p>\n

To install Supervisor, run:<\/p>\n

apt-get install supervisor\r\nservice supervisor start\r\n<\/code><\/pre>\n

Then, create a new script file in\u00a0\/etc\/supervisor\/conf.d\/ghost.conf<\/code>. Paste in these contents:<\/p>\n

[program:ghost]\r\ncommand = node \/usr\/lib\/node_modules\/ghost\/index.js\r\ndirectory = \/usr\/lib\/node_modules\/ghost\r\nuser = ghost\r\nautostart = true\r\nautorestart = true\r\nstdout_logfile = \/var\/log\/supervisor\/ghost.log\r\nstderr_logfile = \/var\/log\/supervisor\/ghost_err.log\r\nenvironment = NODE_ENV=\"production\"\r\n<\/code><\/pre>\n

Save and close the file.<\/strong><\/p>\n

Next, we need to create a user for Ghost and give it permissions to access the Ghost files and database. Run the following commands:<\/p>\n

useradd ghost\r\nchown -R ghost \/usr\/lib\/node_modules\/ghost\/\r\nsupervisorctl reread\r\nsupervisorctl update\r\n<\/code><\/pre>\n

Our setup is complete!<\/strong><\/p>\n

Now you can\u00a0control Ghost<\/strong>\u00a0by executing\u00a0supervisorctl start ghost<\/code>\u00a0and\u00a0supervisorctl stop ghost<\/code>.<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"","format":"standard","manualknowledgebasecat":[106,109,242,247],"manual_kb_tag":[321],"_links":{"self":[{"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb\/2505"}],"collection":[{"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb"}],"about":[{"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/types\/manual_kb"}],"author":[{"embeddable":true,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/comments?post=2505"}],"version-history":[{"count":1,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb\/2505\/revisions"}],"predecessor-version":[{"id":2506,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb\/2505\/revisions\/2506"}],"wp:attachment":[{"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/media?parent=2505"}],"wp:term":[{"taxonomy":"manualknowledgebasecat","embeddable":true,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manualknowledgebasecat?post=2505"},{"taxonomy":"manual_kb_tag","embeddable":true,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb_tag?post=2505"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}