How to Migrate a Website from Shared Hosting to a VPS
How to Migrate a Website from Shared Hosting to VPS
Migrating your website from Shared Hosting to a VPS provides your site with dedicated resources, superior loading performance, and grants you full root access to control the server environment.
To successfully migrate a website from Shared Hosting to a VPS, follow these 5 core steps: (1) Back up all source code and databases, (2) Install a Web server environment on the VPS, (3) Upload and restore the data, (4) Update the database connection configuration file, and (5) Point your domain's DNS to the new VPS IP.
When a website experiences rapid growth, Shared Hosting often fails to handle the load, resulting in 508 Resource errors or downtime. Migrating your data to a Linux VPS becomes mandatory. Whether you use custom code or a popular CMS, this article provides a secure, zero-downtime migration roadmap.
- 1. Website Migration Process Overview
- 2. Step 1: Backup All Current Data
- 3. Step 2: Set Up the VPS Web Environment
- 4. Step 3: Upload Data and Restore Database
- 5. Step 4: Update Website Configuration
- 6. Step 5: Point Domain to New VPS IP
- 7. Bonus: How to Migrate WordPress to VPS
- 8. Post-Migration Testing Checklist
- 9. Common Migration Errors (Troubleshooting)
- 10. When Should You Upgrade to a VPS?
- 11. Conclusion
1. Website Migration Process Overview
Before diving in, you need to understand the big picture. The migration process consists of the following phases:
| Phase | Task Description |
|---|---|
| 1. Backup | Compress Source Code (.zip) and export the Database (.sql) from the old host. |
| 2. Setup | Install a Control Panel or LEMP/LAMP stack on the new VPS. |
| 3. Upload & Restore | Upload backup files to the VPS, extract them, and import the database. |
| 4. Config | Update the new Database User/Password in the website configuration file. |
| 5. DNS | Change the domain's A Record to point to the new VPS IP address. |
2. Step 1: Backup All Current Data
Carefully create a copy of everything on your old Shared Hosting environment (usually cPanel or DirectAdmin):
- Backup Source Code: Go to the
File Manager, navigate to thepublic_htmlfolder. Select all files, compress them into a.zipor.tar.gzarchive, and download it to your PC. - Backup Database: Access
phpMyAdmin. Select your website's database, switch to the Export tab, choose the SQL format, and download it.
3. Step 2: Set Up the VPS Web Environment
Your new VPS is completely empty. You must install an "engine" to run your website. There are two popular approaches:
4. Step 3: Upload Data and Restore Database
Use an FTP client (like FileZilla) or the new Panel's File Manager to push the .zip file containing your source code to the VPS and extract it into the web root directory.
Next, create a brand new Database on the VPS (save the DB Name, User, and Password). Then, access phpMyAdmin on the VPS and Import the old .sql file into the newly created database.
5. Step 4: Update Website Configuration
Your source code still remembers the database credentials of the old Hosting. You must edit it to connect to the new Database on the VPS.
For instance, in a WordPress migration, open the wp-config.php file and change these 3 parameters to match the credentials created in Step 3:
6. Step 5: Point Domain to New VPS IP
Log in to your domain registrar's control panel. Navigate to the DNS management section, change the A Record (or @ Record), and point it to the Public IP address of the new VPS.
Note: Global DNS Propagation can take anywhere from 1 to 24 hours. During this period, some users might still see the site loading from the old hosting.
7. Bonus: How to Migrate WordPress to VPS
In addition to the manual 5-step process above, if you are running WordPress, the migration can be highly automated. You simply need to install a fresh WordPress instance on your new VPS and use dedicated migration plugins like All-in-One WP Migration or Duplicator to export and import your entire theme, posts, and database with just a few clicks.
8. Post-Migration Testing Checklist
To ensure a flawless migration, execute this testing checklist before switching live DNS:
- Edit Hosts File: Force your computer to recognize the new IP by editing the
hostsfile on Windows. AddVPS_IP yourdomain.comto test it privately. - Check Permalinks: Click on inner posts. If you encounter a 404 error, go to Settings > Permalinks in WordPress and click "Save Changes" to regenerate the
.htaccessfile. - Test Uploads: Try uploading a new image to ensure the uploads folder has the correct CHMOD permissions.
9. Common Migration Errors (Troubleshooting)
Data migration rarely goes without a hitch. Here are the classic errors:
- Error establishing a database connection: This is 100% caused by entering incorrect Database Name, User, or Password information in the configuration file during Step 4.
- 500 Internal Server Error: Usually caused by the old
.htaccessfile containing configurations incompatible with the new Web Server (e.g., moving from Apache to Nginx). Try renaming.htaccessto.htaccess_oldto test. - Permission Denied: Caused by incorrect file ownership. You need to run the
chowncommand to grant web folder permissions back to thewww-data(on Nginx) orapacheuser.
10. When Should You Upgrade to a VPS?
Upgrading to an independent storage space grants you absolute control (Root Access) and dedicated hardware performance. You should make the switch when:
- Your website experiences sudden traffic spikes, frequently showing "Resource Limit Is Reached" errors.
- Page load times are too slow, severely impacting SEO and customer purchasing experience.
- You need to deploy specialized environments like Node.js, Python, Redis Cache, or Docker, which are locked down on Shared Hosting.
11. Conclusion
Migrating a website from Shared Hosting to a VPS marks a significant milestone in your project's maturity. With this precise 5-step backup, setup, and restoration process, you can execute a seamless migration ensuring absolute safety for your enterprise data.
Shared Hosting severely limits CPU/RAM resources and leaves you vulnerable to the actions of other websites sharing the same server. If your site is slowing down or throwing 508 errors, it's time for an independent environment.
If you haven't secured a VPS for your new infrastructure yet, choose the KVM VPS plans at VietHosting, featuring high-end processors and ultra-fast NVMe SSDs. Our technical team will perform the entire website migration for you completely free of charge.
More Technical Guides
Explore additional technical guides and practical tutorials to optimize performance and manage your server infrastructure efficiently.