How to Migrate Your Website From Shared Hosting to VPS
Now, let’s go over the process of migrating your website from shared hosting to VPS, ensuring a smooth transition to increased performance and control.
1. Create a Site Backup
Before modifying a site, create a backup to avoid data loss in case of errors or misconfigurations. It also lets you easily transfer your site files and databases to another hosting type and provider.
This tutorial will show you how to back up your site data through Hostinger’s custom control panel, hPanel. The steps may differ for another hosting provider, but the general procedure is similar:
- Open hPanel and log in to your hosting account. Navigate to Files → Backups.
- Select Files backups. Check the time and date of the latest backup from the drop-down menu. Click Next step.
- Press Download all files. Wait until the process is finished.
- Once the Download Backup button appears, right-click and select Copy Link Address.
- Paste the link on a text editor like Notepad. We will use this download link to migrate your website files.
Repeat the steps to download the database backup. If there are no backups available, select Generate new backup → Proceed. Copy the backup download link and database name to a text editor.
2. Set Up a Virtual Private Server
Before migrating your site, set up the VPS first. We recommend choosing a server template with the Linux, Apache, MySQL, and PHP (LAMP) stack and Webmin/Virtualmin pre-installed. Servers with a pre-installed control panel, like Hostinger’s Cyberpanel VPS hosting, make management easier.
Suggested Reading
Alternatively, set up your stack without a graphical user interface (GUI). We have several tutorials about LEMP and LAMP stack installation on UNIX-based operating systems: How to Install Nginx, MySQL, PHP v7 (LEMP) stack on CentOS 7 How to Install Linux, Apache, MySQL, PHP (LAMP) stack on Ubuntu 16.04 How to Install Linux, Apache, MySQL, PHP (LAMP) stack on CentOS 7
To change your VPS OS and pre-installed software, Go to hPanel → VPS tab. Select the VPS in question, and click Operating System on the sidebar. Pick OS with Control Panel, select your desired template, and click Change OS.
For this tutorial, we will use the AlmaLinux 8 64bit with Virtualmin. Remember that the new server might take a few minutes to start, and the process will wipe all the existing data in your VPS.
Accessing Webmin/Virtualmin
Webmin is web-based frontend software for UNIX system administration. It allows the admin to manage the system remotely through any web browser.
Virtualmin is a Webmin plugin that helps simplify multiple domain management tasks, which works similarly to cPanel or other website management tools. This web hosting control panel supports UNIX-based systems like Linux.
Here’s how to access Webmin or Virtualmin with root access permissions:
- Once the new OS is installed, go to hPanel → Operating system to obtain the management panel’s username and Login URL.
- Get your root password. If you forget it, reset it and create a new one from the Settings section.
- To access Webmin or Virtualmin, enter the Login URL link in your web browser’s address bar.
- Once you see the login page, enter the credentials.
- In the post-installation wizard, click Next to set up Virtualmin.
Setting Up Virtualmin
Follow these steps to configure Virtualmin. Depending on the version, the steps may slightly differ:
Memory
- Preload Virtualmin libraries? ‒ we recommend choosing No since we will use a secure SSH connection for most of the process.
- Run email domain lookup server? ‒ if you want to run an Email Server on your VPS, choose Yes. Keep in mind that this feature uses more RAM.
- Virus Scanning ‒ enable the ClamAV virus scanner.
- Spam filtering ‒ enable SpamAssassin to run an email server on your VPS.
- Database servers – select enable on the MariaDB database server and disable on PostgreSQL. This is the database selection you want to use.
- MariaDB password ‒ enter the password for the database.
- MariaDB database size ‒ determine the website’s database size based on the system’s usage. Leave the default settings if you’re unsure what to choose.
- DNS configuration ‒ select Skip check for resolvability. Later, you can point the domain name to the VPS via hPanel’s DNS Zone Editor.
Important! Don’t enable ClamAV if your VPS has less than 2 GB of spare RAM. Doing so may consume all the remaining memory, crashing your server.
Once the configuration process is complete, click Re-check and refresh the configuration to test whether the virtual server setup is successful.
Creating a Virtual Private Server
Next, create a new user, database, and directory for your website. Here are the steps to do it using Virtualmin:
- Navigate to List Virtual Server and select your server from the list.
- If it suggests that “Virtualmin’s configuration has not been checked since it was last updated,” select Re-check and refresh configurations.
- Wait until the checking process is complete. At the bottom of the page, press Return to the servers list.
- If the list doesn’t show a new server, create one. Otherwise, skip this step.
- From the server configuration page, click the new server → Virtual server details tab. Obtain your Home directory for the file transfer.
- Check the MariaDB database enable box to create the database. Click Save virtual server. The server is ready to host a website.
Virtualmin will create a MariaDB account with its administrative login username for the domain. If you use the default template settings, it will also create a MariaDB database for the virtual server.
The database name will be the first part of the domain name – so if the domain is foo.com, the database will be called foo.
Depending on the hosting provider, your website’s database may not be MariaDB. For example, Hostinger uses MySQL. While different, you can migrate a MySQL database to MariaDB without extra steps.
3. Transfer Website Files to the VPS
Once the new server is set, transfer the site files from shared hosting to VPS. We’ll use the wget command to download the backup archives we created in the first step. Here’s how to do it:
- Connect to your new VPS account via an SSH client or use Browser terminal from the Overview section in hPanel.
- Access the directory where you will store all your files. Use the Home directory copied from the last step. The command should look like this:
cd /home/hostinger-dev/public_html/
Remember to replace hostinger-dev with the appropriate domain name.
- Copy your website file backup’s download link.
- Use the wget command to download the backup from your shared server to the VPS. If you can’t paste the link into the SSH client, transfer it to a text editor first. Here’s an example of what the command will look like:
wget http://srv167.main-hosting.eu:8080/download-backup/fe26ee2e4159db037c3106c37fa3ffb5b2072662/backup-file-name.tar.gz
- Then, extract the archive using the tar command:
tar -xvf backup-file-name.tar.gz
For the last two commands, replace backup-file-name.tar.gz with the appropriate file name.
- We’ve just created a new public_html folder. Now, move its contents to the original public_html directory. Access the extracted public_html folder using the cd command:
cd domains/hostinger-dev/public_html/
Remember to replace hostinger-dev.
- Then, move all the contents to the public_html folder created with Virtualmin using the mv command:
mv -v ./* /home/hostinger-dev/public_html/
- Navigate back to the public_html directory that Virtualmin created using the cd command:
cd /home/hostinger-dev/public_html/
- Use the ls command to verify that the folder contains all the moved files. You should see a list like this:
- Virtualmin automatically creates a user and group based on the domain name. Change the files and folders’ ownership to match the credentials from Virtualmin using the chown command:
chown hostinger-dev:hostinger-dev -R *
Pro Tip
Instead of SSH, you can also use an FTP client like FileZilla to transfer files from your local computer to the personal server. However, FTP only supports file transfer to VPS. It does not support shell commands for website configuration.
4. Transfer Database Files to the Virtual Private Server
We’ll use the wget command to transfer the database backup from your shared hosting account to the VPS. The steps are similar to migrating site data in the previous section.
Since the server already created a new database during the VPS configuration, you don’t need to make additional ones.
Checking MySQL Database Name and Password
To transfer the MySQL database backup, obtain the newly created database’s name, username, and password. Go to the Virtualmin control panel → Edit Databases section to retrieve them. The username and password will show up in separate tabs.
In this example, our MySQL database Name and username are both hostinger-dev.
Downloading and Importing the MySQL Backup
Once you have the MySQL database name, follow these steps to import the backup:
- Navigate to the Backups section of your shared hosting account and copy the download link.
- Go back to the VPS control panel. Create a new directory called sql_backup and enter it using the following command:
mkdir sql_backup && cd sql_backup
- After switching directories, use the wget command to download the file from the shared web hosting backup and save it on the new virtual server:
wget http://srv167.main-hosting.eu:8080/download-backup/60a7e64afb1a769b1de4f2139aa0a27c2c2ecb01/backup-file-name.sql.gz
- Extract the compressed file using the gunzip command:
gunzip backup-file-name.sql.gz
- You will get a file with the same name in the SQL format. Move it to the new database using the command below. Replace the MySQL-database-name with your own and hostinger_dev with your VPS name.
mysql -u root -p hostinger_dev < MySQL-database-name.sql
- Enter the database password from the post-installation wizard.
5. Make Some Final Changes
After completing the website and MySQL database import process, you may need to do additional VPS configurations to ensure it works properly.
If the Error establishing a database connection message appears, edit the wp-config.php file and update it with the new MySQL database details. Here’s how to do it:
- Enter the directory where all your site data are stored using the cd command:
cd /home/hostinger-dev/public_html/
- You will see all the files present in the current folder. Check if the wp-config.php file is in the directory using the ls command.
- After confirming that the file is present, run the following command to edit it with the Nano text editor:
nano wp-config.php
Scroll down until you find these lines:
// ** MySQL settings – You can get this info from your web host ** //
// ** MySQL settings – You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'database-name');
/** MySQL database username */
define('DB_USER', 'username');
/** MySQL database password */
define('DB_PASSWORD', 'password');
/** MySQL hostname */
define('DB_HOST', 'mysql');
Enter your database details in these fields:
- DB_NAME – database name.
- DB_USER – username.
- DB_PASSWORD – password.
- DB_HOST – localhost since the MySQL database is on the same server.
Press CTRL + X to close the window and Y to confirm the changes.
Lastly, update the DNS record to point the domain name to VPS from the shared hosting server. The easiest way is to change the A record via the domain name registrar or VPS account settings.
Since domains registered with Hostinger resolve to our nameservers, set the A record via hPanel. Go to DNS Zone Editor, fill in your VPS IP address as the A record, and click Save Changes. A similar procedure should apply to other domain name registrars.
Alternatively, contact your registrar to point the domain name to your new VPS.
Important! It can take up to 24 hours for DNS changes to fully propagate worldwide.
Conclusion
Many users wanting to scale their websites migrate from shared hosting to virtual private server (VPS) services.
A VPS hosting plan guarantees better security, offers stable performance, and lets users manage resources flexibly – making it suitable for higher-traffic websites.
Commonly, many web hosting providers offer both shared and VPS plans. For example, Hostinger offers four VPS hosting plans starting at $5.99/month.
In this article, you have learned how to migrate from shared hosting to your new VPS. The migration process comprises five steps but may differ depending on the VPS provider. Here’s how to do it with Hostinger:
- Back up your site files and database via hPanel.
- Set up and access your new VPS using Virtualmin.
- Download and transfer your site files from the shared server to the VPS hosting account. Download and transfer your database backup to your VPS account.
- Make final database changes and point your domain name to the VPS. We hope this article helps you understand the shared hosting to VPS migration process. If you have any questions, leave us a comment below.