- Install ghost without ghost cli (it's not needed for this)
- We use sqlite3 (but you can easily change this for mysql if needed
- Apache2 with
- mod_macro installed & enabled
The steps are summarized as the following:
- Install and enable
- Write one apache config for all of your ghost instances
- Install ghost using yarn for each ghost blog instance
- Create a systemd service for each of the blogs
1. Install & enable mod_macro
sudo a2enmod macro sudo service apache2 reload
2. Write one apache config for all of your ghost instances
We will define the following ghost blogs:
- example.co.uk on port 2368
- blog2.example.co.uk on port 2369
- blog3.example.co.uk on port 8001
- example.com on port 8000
This is to demonstrate how you'd host blogs on multiple hosts, and also as subdomains if you needed to. The only thing that really changes between the different ghost blogs is the domain they're on and the port they listen on. It's pointless creating an entire VirtualHost file for each ghost blog. mod_macro allows you to create on VirtualHost config file, and loop over each blog. Store this in your
/etc/apache2/conf-available/ directory (asuming Ubunti 16.04, but that's not required).
# Created by Karma Computing 26/02/2017 14:46 # Documentation Reference: https://httpd.apache.org/docs/current/vhosts/mass.html # get the server name from the Host: header UseCanonicalName Off # this log format cab be split per-virtual-host based on the first field # using the split-logfile utility. LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon CustomLog "/var/log/apache2/access_log" vcommon
Listen $port## Use of VHost with different arguments. Use VHost example.co.uk 80 2368 Use VHost blog2.example.co.uk 80 2369 Use VHost blog3.example.co.uk 80 8001 Use VHost example.com 80 8000 UndefMacro VHost ServerName $host ProxyPass / http://localhost:$proxy/
The above config defines 4 ghost blog entries, look at the bottom of the config file and notice all that really changes is the list at the bottom. We use this to add new blogs. Notice how easy it is to add another ghost instance, simply add another line to your
ghost-blogs.conf file (be sure to avoid any port conflicts) and you're good to setup the ghost instanace.
All that's left is to install ghost and make shure you have an install of ghost listening on each of those ports. You'll need one install of ghost for each blog.
4. Install ghost using yarn for each ghost blog instance
Follow our post on how to install Ghost using Yarn and you're good to go.
This also covers how to set-up a systemd service, so that you can configure all of your ghost instances to start on boot.
You might decide to create a user for each ghost blog for example:
$ ls /home/ $ user1 user2 user3
This way you can seperate each user to have their own ownership of their ghost blog.
Subscribe to Karma Computing
Get the latest posts delivered right to your inbox