How to Migrate Website from Shared Hosting To VPS
There are two methods to migrate a website from shared hosting to VPS. This guide will show you how to migrate your website from cPanel to your VPS that you’ve setup, by manually creating a full backup of your website files and using web migration.
To prepare for site migration, you need to ensure you have access to your old web host via cPanel, as well as your new server via SSH. Your new server should be setup and ready to host a website before beginning, and your website should be put in frozen state or maintenance mode.
Steps to migrate website from shared hosting to VPS
To begin, make sure you are logged in to your old host cPanel area. Either also login to your new server via SSH now or be ready to do so after Step 1. Make sure you are logged in to your new server with root privilege.
- Create a backup of all your files. In File Manager in cPanel, select all files and folders (you may choose to exclude certain files or folders such as cgi-bin or .ftpquota), click the Compress icon and select Zip Archive as the compression type.
- Move your files. In your new server, go to the root folder of your site’s document and enter the command
wget https://domain.com/path/to/filename.zip, where ‘domain’ is your domain name and ‘filename.zip’ is your backup file you’ve just created.
- Extract the backup file using unzip command:
unzip filename.zipthen typing “
Is” and hitting Enter.
- Copy your site’s database link. In your old host cPanel area, select the Backup Wizard > Backup > Select Partial Backup > MySQL Databases. Right-click the relevant database link and select Copy Link Location.
- Move your site’s database. In your SSH client, issue the following command:
wget --user=cpaneluser --password='cpanelpass' https://domain.com:2082/cpsessxxxxxxxx/getsqlbackup/filename.sql.gzwhere ‘cpaneluser’ is your old host cPanel username, ‘cpanelpass’ is your cPanel password, and ‘https://domain.com:2082/cpsessxxxxxxxx/getsqlbackup/filename.sql.gz’ is the database link you just copied in Step 4.
- Extract your database using
gzip -d filename.sql.zip. You should get sql from this.
- Import your .sql file to your server’s database. Create a new MySQL database and MySQL user on your new server with full access granted. Then use the command
mysql -u MYSQL_USER -p DATABASE_NAME < DATABASE_NAME.sqlwhere ‘MYSQL_USER’ is your MySQL username, ‘DATABASE_NAME’ is your database name, and ‘DATABASE_NAME.sql’ is the .sql file you transferred in the previous steps.
The final stages
Once you’ve completed the above steps to migrate your website from shared hosting to VPS, you can edit your script to reflect the new server settings, such as database name, user and password.
Don’t forget to also change the NS entries of your domain with the new server’s IP to ensure your domain name resolves to your new server.
For more help, contact us today.