Rename a ghost blog installation folder on Ubuntu
June 26, 2019

Rename a ghost blog installation folder on Ubuntu

Quick Reference

If you're in a hurry, these are the steps you'll need to take to move your ghost blog to a different directory:

  1. Rename the original directory or move the files
  2. Fix your Apache vhost files (if running reverse proxy with Apache, otherwise follow the steps posted in this forum to fix NGINX)
  3. Update your ghost config file vi config.production.json
  4. Fix broken symlinks with ln -sf:
    /current should point to /versions/YOUR_CURRENT_VERSION
    and /content/themes/casper should point to /current/content/themes/casper
  5. Fix any broken folder ownerships with ghost doctor
  6. Fix any broken symlinks in /etc/systemd/system/ so that systemd can automatically start your ghost blog

Full Rundown

I needed to rename a Ghost installation folder and couldn't find a comprehensive guide anywhere other than a forum entry in the ghost forum.

All commands shown here contain example values, please make sure to replace these to fit your environment!

Some background: I needed to transition a site (hungariantranslation.com) to support multiple languages. Unfortunately, this is not at all easy to do with Ghost within one "instance" as of now, so my approach is to install the english site at www.hungariantranslation.com and the Hungarian language site at hu.hungariantranslation.com.

  • Ghost is configured to be served through Apache via reverse proxy
  • We are running Ubuntu 18.10.
  • The old directory (for us) is at: /var/www/hungariantranslation.com/ghost
  • The new directory will be at: /var/www/hungariantranslation.com/hu

(1) Rename the directory

In our case the ghost installation is /var/www/hungariantranslation.com/ghost, so we can just go there cd /var/www/hungariantranslation.com and mv ghost en

(2) Fix your Apache vhost files

For me these are in /etc/apache2/sites-available, you will have to fix any references to your old directory in your own vhosts files and then don't forget to run sudo service apache2 reload.

(3) Update your ghost config file

This will be nothing new since you've already had to edit this file after installing ghost: vi config.production.json

If you try to start ghost now,  you'll run into some errors:

$ ghost start
+ sudo systemctl is-active ghost_beta-hungariantranslation-com
✔ Ensuring user is not logged in as ghost user
✔ Checking if logged in user is directory owner
✔ Checking current folder permissions
+ sudo systemctl is-active ghost_beta-hungariantranslation-com
✔ Validating config
✔ Checking folder permissions
✔ Checking file permissions
✔ Checking content folder ownership
✔ Checking memory availability
A SystemError occurred.

Message: Systemd process manager has not been set up or is corrupted.
Help: Run ghost setup systemd and try again.

Go into  your new ghost directory cd /var/www/hungariantranslation.com/en and run ls -lha to see if you have any broken symbolic links. For me, the "current" directory was off.

Fix this with: ln -sf ./versions/2.25.2 ./current (or write out the absolute path if you wish). Looks good now:

Another broken symlink for me was in the casper theme:

cd /var/www/hungariantranslation.com/en/content/themes$

ls -lha

Fix it! sudo ln -sf ../../current/content/themes/casper ./casper

(5) Fix folder ownerships

If you start ghost now, you may run into folder ownership issues:

Thanks to the good sense of ghost devs we see an error message that actually tells us the solution (wish Microsoft took note!). So just run ghost doctor and that should clear that issue up.

(6) Fix systemctl issues

If you now try to start ghost you'll see

Message: Command failed: /bin/sh -c sudo -S -p '#node-sudo-passwd#'  systemctl enable ghost_beta-hungariantranslation-com --quiet
Failed to enable unit: Unit file ghost_beta-hungariantranslation-com.service does not exist.

Ghost doctor won't help you now :-(

You can verify that your ghost service is "bad": systemctl list-unit-files | grep bad

This should return your ghot service:

Running systemctl status ghost_beta-hungariantranslation-com.service doesn't help much.

But if you cd /etc/systemd/system/ and ls -lha you'll see that you have a broken symlink:

Fix it! sudo ln -sf /var/www/hungariantranslation.com/en/system/files/ghost_be ghost_beta-hungariantranslation-com.service

That's it, you should now be up and running again!

Rename a ghost blog installation folder on Ubuntu
Share this