How to rename ghost installation folder




I would like to rename one of my ghost installation folder from x.dn.tld to y.dn.tld. I updated the contentPath value in config.production.json accordingly but ghost encounters an error:

✖ Starting Ghost
A GhostError occurred.

Message: Ghost process exited with code: 0

Reverting the folder name and the contentPath value to their original name resolves the issue.

I am running multiple ghost instances behind a fairly standard reverse proxy.

Debug error aren’t helpful:

Debug Information:
    OS: Debian, v9.4
    Node Version: v8.11.3
    Ghost-CLI Version: 1.8.1
    Environment: production
    Command: 'ghost start'
Message: Ghost process exited with code: 0
Stack: Error: Ghost process exited with code: 0
    at ChildProcess.cp.on (/home/jhnchr/.npm-global/lib/node_modules/ghost-cli/lib/utils/local-process.js:56:24)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)


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 :smile:

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 /var/www/old to /var/www/new

  1. Stop your instance

    cd /var/www/old && ghost stop

(reset) - cd ~

  1. Rename the folder

    mv /var/www/old /var/www/new

  2. Update the global config (~/.ghost/config).

    Open up your favorite editor and manually update the text (if you don’t have a favorite editor, nano is a great choice) - nano ~/.ghost/config.

    You’re looking for the line that says "cwd": "/var/www/old", which you want to update to "cwd": "/var/www/new"

  3. 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

    a. ssl-params.conf

    1. change ssl_dhparam /var/www/old/system/files/dhparam.pem to ssl_dhparam /var/www/new/system/files/dhparam.pem

    b. *-ssl.conf

    1. change root /var/www/old/system/nginx-root; to root /var/www/new/system/nginx-root;
    2. change include /var/www/old/system/files/ssl-params.conf; to include /var/www/new/system/files/ssl-params.conf;

    c. The other .conf file

    • 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 (replace with your domain)

    1. replace root /var/www/old/system/nginx-root; with root /var/www/new/system/nginx-root;
  4. Update the systemd config

    This config file is located in the same directory as the nginx config files (/path/to/ghost/system/files)

    *.service - replace /var/www/old with /var/www/new

  5. Restart all services

    • Nginx - sudo nginx -s reload
    • Systemd - sudo systemctl daemon-reload
    • Ghost - cd /var/www/new && ghost start
  6. Profit :sunglasses:

    • 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):

  1. (~/.ghost/config) sed -i ~/.ghost/config -e 's/cwd\": \"\/var\/www\/old/cwd\": \"\/var\/www\/new/'
    4.a.1 (/path/to/ghost/system/files/ssl-params.conf) sed -i /path/to/ghost/system/files/ssl-params.conf -e 's/\/var\/www\/old/\/var\/www\/new/'
    3.b.1 (/path/to/ghost/system/files/ sed -i /path/to/ghost/system/files/ -e 's/\/var\/www\/old/\/var\/www\/new/'
    4.b.2 - nothing (4.b.1 handles it for you!)
    4.c.1 (/path/to/ghost/system/files/ sed -i /path/to/ghost/system/files/ -e 's/\/var\/www\/old/\/var\/www\/new/'
  2. (this is just here to fix formatting)
  3. (/path/to/ghost/system/files/name_example-com.service) sed -i /path/to/ghost/system/files/name_example-com.service -e 's/\/var\/www\/old/\/var\/www\/new/'


Thanks, that was the missing step.

Curiously there was only one of the ghost instances referenced in my ~/.ghost/config file so I fixed that and now ghost status seems to work as expected.

It was also necessary to repair two broken links:

$ ln -s $ghostpath/current/content/themes/casper $ghostpath/content/themes/casper
$ ln -s $ghostpath/versions/1.24.4 $ghostpath/current

I am running a bunch of ghost instances on different ports each and apache2 is used as a reverse proxy and handles vhost and SSL. Sorry for not being more explicit about it, it would have saved you time (but as you wrote it it’s going to be useful for someone else anyway :slight_smile: )


You’re right, I missed that! I’ll update my OP in a bit

No worries, as you said I wrote it because I’ve seen it asked a few times and figured it was worth spending a bit of time documenting it :smiley:

closed #5

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.