Did you know you can host multiple instances of a ghost blog on one digital ocean droplet? Once you have three or more ghost blogs on individual droplets, it may be time to consolidate to save money. What are you waiting for, let’s dive in!
First things first, what size droplet?
If you have one blog, then the regular with SSD $6 plan is adequate. I have heard of people adding multiple ghost blogs while on this plan, but I would not recommend it.
The minimum RAM for ghost installation is 1GB
Ghost needs 1GB of ram because the installation and updating processes use yarn and npm, which are resource intensive. I have run into issues with memory errors when trying to update my ghost blog, which I resolved by creating a swap file. Swap space is slow compared to ram, so you do not want to rely on a swap file to run your extra blog instances.
Note: How much RAM and disk space are needed will vary greatly depending on the size of files, number of files, and number of visitors. I am providing general numbers based on my experiences with my sites.
- Ghost typically uses ~250MB of RAM per small blog (<100 pages).
- To be safe, consider about 15GBs of your drive are taken up by the operating system, MySQL, dependencies, and logs.
- The default out-of-the box, digital ocean, ghost blog install is about 350MBs.
- Once I add multiple versions of my custom themes, images, and videos, my personal blogs (less than 20 pages) are about 1 GB each.
Recommended Droplet Size
$14/mo Premium AMD with NVME SSD (50GB disk space and 2GB ram) should be able to handle 6–8 Ghost small blogs without problems.
Note: I read several blogs stating the performance on the “AMD” far surpassed the basic and intel servers.
Step One: Domain Migration
Let’s say your domain is https://www.myblog.com, and you already have a ghost site on a smaller droplet. You do not want to point DNS for myblog.com to the new larger server until you finish backing up your old site and migrate it to the new site. I recommend that you create a temporary subdomain. (example: test.myblog.com)
Here are two sites that provide the steps you need to migrate your ghost site contents and also update your ghost domain.
Step Two: New Larger Droplet
You can increase the size of your existing droplet, but I recommend starting fresh. This ensures you have the latest version of Ubuntu, npm, node, and ghost. Migrating your ghost blogs is easy, just do a backup and restore from the admin menus.
After the droplet has been created, you will need to ssh to the server to finish your ghost setup. In a terminal window type:
As soon as you log in, ghost will walk you through the setup wizard.
Adding another Ghost Instance on the Same Droplet
Before installing another ghost instance, you need to find the root password for your MySQL database. Digital Ocean created a password file at the root of your server. To access it, type:
Copy the password and paste it somewhere safe on your computer because you will need it in a couple of minutes.
Press CTRL+X to exit the nano editor
Next, you need to create a directory for your new blog. Replace “ghostfolder2” with the name of your second blog.
sudo mkdir -p /var/www/ghostfolder2
Now you will assign the user “ghost-mgr” as the owner of that directory.
sudo chown ghost-mgr:ghost-mgr /var/www/ghostfolder2
Finally, you will update the permissions.
sudo chmod 775 /var/www/ghostfolder2
Once the directory is created, you need to log in as the ghost-mgr account.
sudo -i -u ghost-mgr
When you switch to the “ghost-mgr” user, you will be placed in the home directory for ghost-mgr so you need to navigate to the folder you just created.
Now you can install a new instance of ghost
When in doubt, accept the defaults.
Enter your blog URL: <type in your domain>
Enter your MySQL hostname: localhost
Enter your MySQL username: root
Enter your MySQL password: <Paste your mysql password>
Enter your Ghost database name: <yourfoldername_prod>
Do you wish to set up “ghost” mysql user? Yes
Do you wish to set up Nginx? Yes
Do you wish to set up SSL? Yes
Enter your email (For SSL Certificate) <your email address>
Do you wish to set up Systemd? Yes
Do you want to start Ghost? Yes
Optimizing your Digital Ocean Droplet
What is nice with having multiple ghost instances on one droplet is you only have to optimize one droplet.
Swap is a space on a disk that is used when the amount of physical RAM memory is full. When our droplet runs out of RAM, inactive pages are moved from the RAM to the swap space. The swap file will not be as fast as ram, but it will definitely help. Since we selected the faster SSD drives, we should get better performance from our swap file than we did on the basic droplet.
Note: If you have 2GB of RAM, then it is recommended that your swap file be 4GB.
The Ghost blog platform doesn’t automatically set up log rotation when it is installed. As a result, Ghost will perpetually append to its log files until you run out of disk space. Setting up log rotation will ensure you only keep one week’s worth of ghost logs.
Note: You will add an entry for each ghost blog into the same file.
Use Cloud Flare
Adding the free version of Cloudflare will improve performance by blocking bad actors as well as caching your site on their CDN, which decreases the load on your server.
Reduce Ram Usage by MySQL
This tip dropped my RAM usage by 16%
Below are my quick notes on common commands I use when maintaining my ghost blogs.
npm install -g ghost-cli@latestsudo -i -u ghost-mgrcd /var/www/ghostghost update
If you run into memory errors and the issue is the cache, then use this line instead:
ghost update --no-check-mem
Ghost doctor is a greta little tool you may want to run even if you do not notice issues to ensure everything is configured correctly. Recently I noticed that my images were not loading correctly, so I ran ghost doctor, and it told me to update the owner on my content folder. This resolved the issue.
How to run Ghost Doctor:
cd /var/www/yourghostfoldersudo -i -u ghost-mgrghost doctor
Example of what ghost doctor may tell you:
Run sudo chown -R ghost:ghost ./content and try again.
View Hard Disk Space Usage
See how much space is being used by each of your ghost instances.
du -hx — max-depth=1 /var/www
Read mail on Server
When you ssh to your ghost server, you may see a message that you have new mail (it’s typically a cron job announcement). Reading your mail is easy, simply type:
Clean Temp Files
We can clean the temporary files using the command.
sudo apt autoremove
sudo apt-get clean
Ghost Log Location
Location of your ghost logs
NGINX Log Location
Your NGINX log should automatically rotate every 14 days, so you do not have to worry about these logs growing out of control. However, you may occasionally need to open the access or error logs to debug issues.
If you need to debug any issues with your domain mapping to the correct folder.
Example Usage Stats
The graphs are of a single digital ocean droplet with three instances of ghost (with no traffic) on the $14/mo Premium AMD with NVME SSD (50GB disk space and 2GB ram) using all my recommended tweaks above.