Changing folders is pretty tricky because every aspect of the installation needs to be updated. Here’s what needs to be done for the recommended stack (Ubuntu 16 + nginx + systemd)
Run these commands as the user that installed Ghost. I think this is everything you need to do, but I might be missing something. Think of this post as a living document
Please don’t blindly copy and paste these commands without understanding what they do fully. There’s implicit example information in these commands which could make life harder if you don’t update the command.
These commands are based on migrating from
Stop your instance
cd /var/www/old && ghost stop
Rename the folder
mv /var/www/old /var/www/new
Update the global config (
Open up your favorite editor and manually update the text (if you don’t have a favorite editor, nano is a great choice) -
You’re looking for the line that says
"cwd": "/var/www/old", which you want to update to
Update the nginx config
All of the config files that Ghost uses are located in
/path/to/ghost/system/files. To update your nginx config, you need to edit 3 files (assuming you have ssl enabled). cd into the config files directory and open up the following files in your editor, making the changes following the filename. All you’re doing is updating folder names - the extra info I’m writing is to give you proper context
ssl_dhparam /var/www/old/system/files/dhparam.pem to
root /var/www/old/system/nginx-root; to
include /var/www/old/system/files/ssl-params.conf; to
c. The other
- there’s no wildcard way to tell you which file this is, so just run
ls -al /var/www/old/system/files/ and look for the
example.com with your domain)
root /var/www/old/system/nginx-root; with
Update the systemd config
This config file is located in the same directory as the nginx config files (
*.service - replace
Restart all services
- Nginx -
sudo nginx -s reload
- Systemd -
sudo systemctl daemon-reload
- Ghost -
cd /var/www/new && ghost start
- Hopefully everything went off without a hitch!
Sed (stream editor) is a really powerful tool which might be able to make updating these files easier. These commands aren’t bulletproof. Use with caution. If you don’t trust it, the manual version is perfectly acceptable. You might want to make a backup of these files. Here’s the sed command you can run instead of manually editing files (the number corresponds to the step above):
sed -i ~/.ghost/config -e 's/cwd\": \"\/var\/www\/old/cwd\": \"\/var\/www\/new/'
sed -i /path/to/ghost/system/files/ssl-params.conf -e 's/\/var\/www\/old/\/var\/www\/new/'
sed -i /path/to/ghost/system/files/example.com-ssl.conf -e 's/\/var\/www\/old/\/var\/www\/new/'
4.b.2 - nothing (4.b.1 handles it for you!)
sed -i /path/to/ghost/system/files/example.com.conf -e 's/\/var\/www\/old/\/var\/www\/new/'
- (this is just here to fix formatting)
sed -i /path/to/ghost/system/files/name_example-com.service -e 's/\/var\/www\/old/\/var\/www\/new/'