How To Host Multiple Ghost Blogs on Ubuntu 12.04 Using Apache

Introduction

Ghost is a new blogging engine that built using node.js, so it can’t be run like a PHP-based blogging engine, such as WordPress. Ghost was born to return the essence of blogging, blogging that focused on content. Therefore, Ghost has a very simple design both on the public page and admin page. Ghost doesn’t use MySQL database, it uses SQLite – a database system that stores data in a file.

Running multiple Ghost blogs is not easy as running other blogging engines, because Ghost runs as a service and can’t be accessed directly through a web browser by starting the web server such as PHP scripts. In this tutorial, you will learn how to host multiple Ghost blogs on Ubuntu 12.04 using Apache.

Prerequisites

We assume that you have a droplet with Ubuntu 12.04 and you have installed the Apache web server, too. So, we will focused on setting up the Apache and Ghost blogs.

We will learn to run two Ghost blogs, it’s just an example, you can use this tutorial to run more blogs.

Installing Ghost

The default document root of Apache is /var/www, you can use this directory to place the Ghost engine. Download and extract Ghost in the document root


cd /var/www/
sudo curl -L https://ghost.org/zip/ghost-latest.zip -o ghost.zip
unzip -uo ghost.zip -d ghost1
unzip -uo ghost.zip -d ghost2
sudo rm ghost.zip

Then, install Ghost


cd /var/www/ghost1
npm install --production

Do the same on the second Ghost

cd /var/www/ghost2
npm install --production

Configuring Ghost

Open config.js in the first Ghost directory /var/www/ghost1, go to production section, change the url and don’t change any other settings.

sudo nano /var/www/ghost1/config.js


production: {
url: 'http://firstdomain.com',
mail: {},
database: { client: 'sqlite3', connection: { filename: path.join(__dirname, '/content/data/ghost.db') },
debug: false },
server: { host: '127.0.0.1', port: '2368' }
},

Open config.js in the second Ghost directory /var/www/ghost2, this time you have to change the url and port, you can change the port to 2369, its free to use.

sudo nano /var/www/ghost2/config.js


production: {
url: 'http://seconddomain.com',
mail: {}, database: { client: 'sqlite3', connection: { filename: path.join(__dirname, '/content/data/ghost.db') }, debug: false },
server: { host: '127.0.0.1', port: '2369' } },

Configuring Apache

In this case, Apache is running as a proxy, and you use Apache to redirect requests to the Ghost engine which is running as a service.

Create a configuration file /etc/apache2/sites-avaiable/firstdomain.com.

sudo nano /etc/apache2/sites-avaiable/firstdomain.com

Use this config:


<VirtualHost *:80>
ServerName firstdomain.com
ProxyPass / http://127.0.0.1:2368/
ProxyPassReverse / http://127.0.0.1:2368/
ProxyPreserveHost On
RewriteEngine On
RewriteOptions inherit
</VirtualHost>

Then, create for the second domain /etc/apache2/sites-available/seconddomain.com.

sudo nano /etc/apache2/sites-avaiable/seconddomain.com

Use this config:


<VirtualHost *:80>
ServerName seconddomain.com
ProxyPass / http://127.0.0.1:2369/
ProxyPassReverse / http://127.0.0.1:2369/
ProxyPreserveHost On
RewriteEngine On
RewriteOptions inherit
</VirtualHost>

The last one, enable mod_rewrite on Apache, this is for enabling clean URL.

sudo a2enmod rewrite

Start All Services

Apache

sudo service apache2 start

Ghost

It’s recommended to run Ghost as a background task, you can use forever to handle it.

Install forever with this command

sudo npm install forever -g

Run the first Ghost
cd /var/www/ghost1

sudo NODE_ENV=production forever start index.js

Run the second Ghost

cd /var/www/ghost1

sudo NODE_ENV=production forever start index.js

You should now have two Ghost blogs running on a single droplet using Apache web server.

Iklan

Satu pemikiran pada “How To Host Multiple Ghost Blogs on Ubuntu 12.04 Using Apache

  1. Nice walkthrough. Some comments which may help other readers: you are missing an ‘l’ in some cases, e/g/, /etc/apache2/sites-avaiable/firstdomain.com. Also, it might be easier to understand if you use the same syntax all the way through, for example, ghost1 is also firstdomain… why not just use ghost1, or firstdomain,all the way through. I know when I was starting out something like that would throw me for a loop. Great work!

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s