Categories
Laravel Forge

How to migrate Laravel forge sites to a user isolated site

This process will have a few minutes of downtime while you run through the steps.
Things you should have handy:

  • Your ssh key
  • The server’s sudo password

1. SSH into the server as forge. Rename the existing site to something else, so when we delete it from forge the files don’t get deleted!Very Important!

mv /home/forge/{{oldSite}} /home/forge/old.{{oldSite}}

2. Delete the site from forge to free up the domain.

3. Create a new site in forge with the {{oldSite}} domain and check off “Use Website Isolation”. 

4. On forge, go to the server page and click SSH Keys. You will have to refresh most likely to see the new user. Add your ssh key to the new user. I’m labeling mine as josh-{{newUser}}

5. SSH into the server as the forge user

6. Delete the other users site you just created in step #3.

sudo rm -rf /home/{{newUser}}/{{newSite}}

7. Replace the site we just deleted with our old site we renamed in step #1. This is a lot faster than rsync and we don’t end up with duplicate files on the server.

sudo mv /home/forge/old.{{oldSite}} /home/{{newUser}}/{{newSite}}

8. Change the owner and group for all the files and folders

cd /home/{{newUser}}/{{newSite}}sudo chown -R {{newUser}}:{{newUser}} .

9. On forge, reinstall a let’s encrypt cert for the site.

All done!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.