How to Migrate Website from Shared Hosting To VPS

Est. reading time: 3 minutes

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 set up and ready to host a website before beginning, and your website should be put in a 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 log in 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.

  1. 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.
  2. In your new server, go to the root folder of your site’s document and enter the command wget http://domain.com/path/to/filename.zip, where ‘domain’ is your domain name and ‘filename.zip’ is the backup file you’ve just created.
  3. Extract the backup file using unzip command: unzip filename.zip then typing Is and hitting Enter.
  4. 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.
  5. Move your site’s database. In your SSH client, issue the following command:
    wget --user=cpaneluser --password='cpanelpass' http://domain.com:2082/cpsessxxxxxxxx/getsqlbackup/filename.sql.gz where ‘cpaneluser’ is your old host cPanel username, ‘cpanelpass’ is your cPanel password, and ‘http://domain.com:2082/cpsessxxxxxxxx/getsqlbackup/filename.sql.gz’ is the database link you just copied in Step 4.
  6. Extract your database using gzip -d filename.sql.zip. You should get sql from this.
  7. 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.sql where ‘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 HOSTAFRICA today.

https://hostafrica.co.za/blog/vps/how-to-migrate-website-from-shared-hosting-to-vps/

Related Posts