Migrate Your Install to Another Server or Web Host (Using SSH)
This document details the process for migrating an existing installation to another linux server or web host. It assumes your new server has PHP, MySQL and either Apache/Nginx installed. If you need guidance for this please see our other article first:
1) Backup Existing Installation
Before you do anything ensure you have a backup of your existing installation, both your database and files. Your web host will normally arrange this, if they do validate the backup before continuing.
2) Configure New Server Webroot
On your new server, ensure you've created the new vhost for your existing domain name. If you're using VestaCP you can do this via the VestaCP user interface.
On VestaCP, you'll end up with a web root path similar to:
3) Disable Cron Tasks
On your existing server, disable any cron tasks. These can be found by executing the following as SSH root:
Place a # in front of all the cron commands to disable them.
4) Move Files
The easiest way to move files is using rsync between both servers. Rsync will copy files directly from your current server to your new servers, however it'll also only copy changed or new files if it's run again.
Via root SSH on your current server, execute the following command. Replace the paths and server IP address:
rsync -avh /current/server/path/to/webroot/ [email protected]_server_ip:/new/server/path/to/webroot/
rsync -avh /home/admin/web/yourdomain.com/public_html/ [email protected]:/home/admin/web/yourdomain.com/public_html
If you see any rsync errors, ensure you have rsync installed on both servers.
5) Enable Maintenance Mode
Place your existing site into maintenance mode. In the script admin area, site settings, there's an option to disable your site during the move. This will avoid any new files or updates to the database during the move.
6) Migrate Database
Generate an sql dump of your current database. Replace all items below in the square brackets (removing the brackets) and update the web root path. You can find these in the _config.inc.php within the web root.
mysqldump -u[current_db_user] -p [current_db_name] > /home/admin/web/yourdomain.com/public_html/files/db.sql
After this completes, run the above rsync command to push the generated sql file onto the new server.
On your new server, import the sql file into your new database.
mysql -u[new_db_user] -p [new_db_name] < /home/admin/web/yourdomain.com/public_html/files/db.sql
Remove the sql after this completes.
7) Update Script Config on New Server
The only file you need to update will be the _config.inc.php in the web root.
Edit this file on your new server and set the new database name, username and password.
You can also update the site url in this file if you want to test before repointing the domain name.
8) Nginx Rewrite Rules
If you're using Nginx, ensure you've configured the rewrite rules - https://support.mfscripts.com/public/kb_view/16/
9) Setup Crons
On your new server, setup the crons. See the following article for guidance:
10) Update DNS
Using your DNS provider (such as CloudFlare), update your domain DNS to point at the new server.
11) Disable Maintenance Mode
Via the script admin, site settings, disable maintenance mode.
Areas we'd recommend testing are:
- Email sending (on registration for example)
- Session support - Logging in
- Sub pages, such as contact.html - if these are broken it's likely point 8 above.
13) Celebrate - Your're Done!