
Core takeaway
- Order is the whole trick: the old site keeps running while you build a complete copy on the VPS, test it privately, bring it up to date, and only then point your domain at it.
- Prepare first: lower the DNS TTL beforehand and get an HTTPS certificate on the new server before the switch.
- Test, then sync, then switch: test the new server before anyone else can see it, run a final sync, then switch the DNS records.
- Rule: never point visitors at a server you have not already tested.
Disclosure: con1ainer.com participates in affiliate programs. This article contains no affiliate links. See the Affiliate & Commercial Disclosure.
Most website moves go wrong in one of two ways.
In the first, the owner points the domain at the new server before the new server is ready, and visitors land on an error page.
In the second, the owner copies the site once, gets busy, and switches a week later, only to find the new copy is missing everything published in between.
Neither is a technical failure. Both are ordering failures.
The method in this guide fixes the order. The old site keeps running the whole time. You build a complete copy on the VPS, test it where nobody else can see it, bring it up to date, and only then point your domain at it. For the short period while the internet catches up, both servers can answer visitors with a working site. There is never a moment when a visitor can reach something broken.
This guide moves a WordPress site from shared hosting (the kind with a cPanel control panel) to a Linux VPS running Nginx, because that is the most common move. The same sequence applies to other kinds of sites. The file and database steps change; the order does not.
What “Without Downtime” Means
Downtime is any moment when a visitor asks for your site and gets an error instead of a page. That includes a timeout, a “server not found” message, a 500 or 502 error, and a browser warning about the security certificate.
The method below keeps visitors away from all of those. The one thing that needs extra care is content, meaning anything that changes in the database after you copy it. If a visitor leaves a comment on the old server after you copied the database, that comment exists only on the old server. How much this matters depends on the site.
| Site type | Content risk | What to do |
|---|---|---|
| Blog or brochure site with no logins | Low | Do a final copy right before the switch (Step 9) |
| Site with comments or a contact form that saves entries | Moderate | Do the final copy right before the switch, and turn comments off for the hour around it |
| Online store, membership site, or booking system | High | Schedule the switch for your quietest hour and pause orders on the old site for 15 to 60 minutes |
A store cannot be moved with zero interruption using this method, because an order placed on the old server would not appear on the new one. Everything else can be moved without a visitor noticing.
What You Need Before You Start
- A VPS with SSH access. SSH (Secure Shell) is an encrypted way to type commands on a remote server from your own computer. If you have not used it yet, What Is a VPS and How Does It Work? explains how you connect.
- A non-root user with sudo, and a basic firewall.
sudolets a normal user run administrator commands for one command at a time. Read next: How to Secure a VPS: Essential Setup Checklist - The public IP address of the VPS. This is the number your provider shows in its dashboard. This guide uses
203.0.113.25as a stand-in. Replace it with yours. - Access to the old host. Either the cPanel login or SSH access.
- Access to wherever your DNS is managed. This is usually your domain registrar or your hosting account. Step 1 explains how to find out.
- Two to four hours of work, spread across two days. The waiting in Step 2 is the reason.
Throughout the guide, replace example.com with your domain. Commands assume Ubuntu 24.04 LTS (LTS means long-term support, a release that receives security updates for years). Other Debian-based systems are nearly identical.
How DNS Controls the Switch
DNS (Domain Name System) is the lookup service that turns a name like example.com into the IP address of the server that hosts it. Your domain does not contain your website. It contains a record saying where the website is.
These are the records and settings you will deal with:
| Term | What it means |
|---|---|
| A record | Points a name to an IPv4 address, such as 203.0.113.25 |
| AAAA record | Points a name to an IPv6 address, which is longer, such as 2001:db8::1. If one points to your old host and you forget it, visitors using IPv6 keep landing on the old server |
| TTL | Time To Live. The number of seconds other computers may remember an answer before asking again |
TTL is the setting that matters most. If your TTL is 14400 (four hours), an internet provider that looked up your site may keep using the old IP address for up to four hours after you change it. That waiting is what people call propagation. It is not a message travelling across the internet. It is thousands of remembered answers expiring at different times.
So the method is simple: lower the TTL to 300 seconds (five minutes) a day or two ahead, so that when you finally change the IP address, the old answer expires within minutes instead of hours.
The Plan at a Glance
| Steps | What happens | What visitors see |
|---|---|---|
| 1–2 | Planning and lowering the TTL | Old site |
| 3–7 | Building the new copy on the VPS | Old site |
| 8–9 | Testing privately and doing a final sync | Old site |
| 10 | Changing the DNS records | Old site or new site, both working |
| 11–12 | Verifying, then retiring the old host | New site |
Step 1: List Everything You Are Moving
A website is more than its pages. Write down each item below before you touch anything, because every one of them can break a move.
| Item | Why it matters | How to check |
|---|---|---|
| PHP version | A site built for one version can fail on another | In WordPress: Tools → Site Health → Info → Server |
| Database name and size | You need the name to export it, and the size tells you how long the copy takes | Open wp-config.php and read DB_NAME |
| Total file size | The VPS disk must have room for it | cPanel → Disk Usage |
| Where DNS is hosted | If your nameservers belong to the old host, cancelling the old account takes your DNS records with it | Look at the nameservers listed at your domain registrar |
| Mailboxes are separate from the website. Moving the site does not move the mail | Check your MX records in the DNS panel | |
.htaccess rules | .htaccess is a settings file read by the Apache web server. Nginx never reads it, so redirects and security rules inside it must be rewritten in Nginx | Open the file and copy any custom rules |
| Cron jobs | Scheduled tasks that run on a timer | cPanel → Cron Jobs |
Two of these cause most of the damage. If your DNS lives at the old host, move it to your registrar or a DNS service before you cancel anything. If your email lives at the old host, keep that account active and do not change MX records at any point in this guide.
Step 2: Lower the DNS TTL
Open your DNS panel and find the A records for example.com and www.example.com. Note the current TTL, then change the TTL on both to 300. Do not change the IP address yet.
Now wait at least as long as the old TTL. If it was 14400, wait four hours. If it was 86400 (one day), wait a full day. Until that time passes, some computers still hold the old answer with the long timer, and the benefit of the change has not reached them.
This is the only mandatory waiting in the guide. Do the rest while you wait.
Step 3: Install the Software on the VPS
Connect over SSH and install the web server, database server, and PHP.
sudo apt update
sudo apt install nginx mariadb-server php-fpm php-mysql php-curl php-gd php-intl php-mbstring php-xml php-zip unzip
What each part does:
- Nginx is the web server. It receives requests from browsers and sends back pages and files.
- PHP-FPM runs PHP code. WordPress is written in PHP, and Nginx passes PHP files to PHP-FPM to be executed.
- MariaDB is the database server. It stores your posts, pages, settings, and user accounts.
- The
php-*packages are extensions WordPress uses for images, text encoding, XML, and compressed files.
Check the PHP version and compare it with the one you noted in Step 1:
php -v
Then open the firewall for web traffic:
sudo ufw allow 'Nginx Full'
sudo ufw status
“Nginx Full” opens port 80 (plain HTTP) and port 443 (HTTPS). A port is a numbered entrance on a server, and the firewall decides which entrances are open. If the firewall is not enabled yet, enable it only after allowing SSH, or you will lock yourself out. The security checklist covers that order.
Not sure the VPS is big enough for WordPress plus a database? Read next: How Much RAM Does a Web Server Need?
Step 4: Create the Database
Open the MariaDB prompt:
sudo mariadb
Then run these four statements, replacing the names and the password. Use a long random password and store it in a password manager.
CREATE DATABASE example_wp CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'example_user'@'localhost' IDENTIFIED BY 'a-long-random-password';
GRANT ALL PRIVILEGES ON example_wp.* TO 'example_user'@'localhost';
FLUSH PRIVILEGES;
Type EXIT; to leave. The user is created for localhost, which means it can only connect from the VPS itself, not from the internet. That is what you want.
Step 5: Copy the Files and the Database
You have two ways to do this. Option A works on nearly every shared host. Option B is faster if your old host allows SSH.
Option A: Download, then upload
- In cPanel, open File Manager, open
public_html, select everything, click Compress, choose Zip Archive, and download the zip. - In cPanel, open phpMyAdmin, click your database name, click Export, choose Custom, tick Add DROP TABLE, and click Go.
- From your own computer, upload both files to the VPS with
scp(secure copy, which sends files over SSH):
scp site-files.zip example_wp.sql youruser@203.0.113.25:/tmp/
- On the VPS, unpack the files and import the database:
sudo mkdir -p /var/www/example.com
sudo unzip /tmp/site-files.zip -d /var/www/example.com
mariadb -u example_user -p example_wp < /tmp/example_wp.sql
The import asks for the database password you chose in Step 4.
Option B: Pull directly with rsync
rsync copies files between servers and, on later runs, sends only what changed. That makes the final sync in Step 9 take seconds.
sudo mkdir -p /var/www/example.com
sudo chown youruser: /var/www/example.com
rsync -avz --progress olduser@old-host:/home/olduser/public_html/ /var/www/example.com/
The flags: -a keeps permissions, timestamps, and folder structure; -v prints what it is doing; -z compresses data in transit. The slash at the end of each path matters. With it, rsync copies the contents of the folder. Without it, rsync creates an extra folder inside the destination.
For the database, run mysqldump on the old host (it includes the DROP TABLE statements by default) and transfer the output the same way:
mysqldump -u olduser -p --single-transaction oldname > example_wp.sql
Point WordPress at the new database
Edit the configuration file:
sudo nano /var/www/example.com/wp-config.php
Change these four lines to match Step 4:
define( 'DB_NAME', 'example_wp' );
define( 'DB_USER', 'example_user' );
define( 'DB_PASSWORD', 'a-long-random-password' );
define( 'DB_HOST', 'localhost' );
Then set ownership and permissions:
sudo chown -R www-data:www-data /var/www/example.com
sudo find /var/www/example.com -type d -exec chmod 755 {} +
sudo find /var/www/example.com -type f -exec chmod 644 {} +
www-data is the account Nginx and PHP run under on Ubuntu. Permission 755 on folders and 644 on files lets the web server read everything and only the owner write it.
Step 6: Get an HTTPS Certificate Before the Switch
HTTPS needs a certificate on the server. The usual method, where Let’s Encrypt checks that your domain points at the server, cannot succeed yet because your domain still points at the old host. If you skipped this step, visitors who reach the new server after the switch would get a certificate warning.
The fix is to prove ownership through DNS instead. Install Certbot, the free tool that requests certificates from Let’s Encrypt:
sudo apt install certbot python3-certbot-nginx
sudo certbot certonly --manual --preferred-challenges dns -d example.com -d www.example.com
Certbot prints two TXT records to create. A TXT record is a text note stored in DNS. Both records use the name _acme-challenge and different values. Add them in your DNS panel, wait a minute or two, and confirm they are visible before pressing Enter:
dig TXT _acme-challenge.example.com +short
Certificates created this way do not renew automatically. That is acceptable for now, because you will replace this one with a self-renewing certificate in Step 11.
Step 7: Configure Nginx
Create the site configuration:
sudo nano /etc/nginx/sites-available/example.com
Paste this, replacing the domain and, if needed, the PHP socket path. Run ls /run/php/ to see the exact filename on your server. It contains your PHP version.
server {
listen 80;
listen [::]:80;
server_name example.com www.example.com;
return 301 https://example.com$request_uri;
}
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name www.example.com;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
return 301 https://example.com$request_uri;
}
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name example.com;
root /var/www/example.com;
index index.php;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
client_max_body_size 64M;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php8.3-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
What the important parts do:
- The first block sends every plain HTTP request to the HTTPS version in one permanent (301) redirect.
- The second block sends
wwwto the non-www address, so each page has exactly one address. try_filestells Nginx to look for a real file, then a real folder, and otherwise hand the request to WordPress. Without it, every page except the homepage returns a 404 error.client_max_body_sizesets the largest upload allowed. Nginx’s default is 1 MB, which blocks most image uploads.- The
.htblock hides.htaccessfiles from the public.
Now enable the site, test the file for typing mistakes, and reload:
sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/
sudo rm /etc/nginx/sites-enabled/default
sudo nginx -t
sudo systemctl reload nginx
nginx -t checks the configuration without applying it. Never reload until it says the test is successful.
If your old .htaccess file contained custom redirects or security rules, rewrite them as Nginx return 301 or location rules here. WordPress’s own rewrite block in .htaccess is already covered by try_files.
Step 8: Test the New Server Before Anyone Else Can See It
Your domain still points at the old host, so a normal browser visit shows the old site. You need a way to ask the new server for your site specifically. There are two.
Method 1: curl. curl is a command-line tool for making web requests. This one sends a request to the VPS but claims it is for your domain:
curl -I --resolve example.com:443:203.0.113.25 https://example.com/
A response starting with HTTP/1.1 200 OK means the new server is serving your homepage over HTTPS.
Method 2: your hosts file. This is a file on your own computer that overrides DNS for your machine only. Add one line:
203.0.113.25 example.com www.example.com
The file is at C:\Windows\System32\drivers\etc\hosts on Windows (open your editor as Administrator) and /etc/hosts on macOS and Linux. Save it, then open the site in your browser. You are now looking at the VPS and nobody else is.
Click through the new copy like a visitor would:
- Homepage, several posts, and several pages, to confirm permalinks (the readable page addresses) work
- Images and the logo
- Search, menus, and the sidebar
- The contact form, submitted once
- The WordPress admin login at
/wp-admin/ - Uploading one image
Leave the hosts line in place until Step 10. Fix anything broken now, while nobody depends on the new server.
Step 9: Do a Final Sync
The copy you made in Step 5 is already out of date if you have published or received anything since. Close the gap right before the switch.
- For a store or membership site: put the old site into maintenance mode first so it stops accepting changes.
- Files: run the same
rsynccommand from Step 5 again. It transfers only files that changed, usually in seconds. If you used Option A, download and upload a fresh zip instead. - Database: export the old database again and import it on the VPS with the same command as before. Because the export contains DROP TABLE statements, the import replaces the old tables with the fresh ones.
- Re-run the ownership commands from Step 5 if new files arrived.
Then repeat a quick check of the homepage through your hosts file. This is the last moment to find a problem for free.
Step 10: Switch the DNS Records
First, remove the line you added to your hosts file. If you leave it, your computer will keep showing the VPS no matter what DNS says, and you will not be able to judge the result.
Then, in your DNS panel:
- Change the A record for
example.comfrom the old IP address to the VPS IP address. - Change the A record for
www.example.comthe same way. - If an AAAA record exists for either name, change it to the VPS IPv6 address, or delete it if the VPS has none.
- Leave every other record alone, especially MX (mail), SPF, and DKIM records, which keep email working.
Check the change with dig, a tool that asks DNS directly:
dig +short example.com
dig @8.8.8.8 +short example.com
The first asks your own resolver. The second asks Google’s public resolver. When both return 203.0.113.25 (your VPS IP), the switch has reached most of the internet.
With a TTL of 300, the large majority of visitors move within about 30 minutes. Some internet providers ignore low TTLs and hold the old answer longer, so a small trickle may reach the old server for a day or two. That is fine, because the old site still works and still looks identical.
Step 11: Verify Everything and Watch the Traffic
Once DNS points at the VPS, watch real visitors arrive:
sudo tail -f /var/log/nginx/access.log
Each line is one request. When lines begin scrolling by from addresses you do not recognize, real visitors are on the new server. Press Ctrl+C to stop. Errors appear in /var/log/nginx/error.log.
Then finish the remaining jobs:
- Replace the temporary certificate with a self-renewing one. Now that your domain points at the VPS, the normal method works:
sudo certbot --nginx -d example.com -d www.example.com
If Certbot finds the existing certificate, choose the option to renew and replace it. Certbot then renews automatically about 30 days before expiry. Confirm with sudo certbot renew --dry-run.
- Test email sending. WordPress sends mail through PHP’s built-in mail function, and many VPS providers block outgoing mail on port 25 by default. If contact-form emails do not arrive, install an SMTP plugin and connect it to a real mail service.
- Re-check the Search Console. If the site is verified there, the moved site should keep working with no changes, because the web addresses are identical.
- After 48 hours of stable traffic, raise the TTL back to 3600 (one hour) or higher. A low TTL makes every visit slightly slower to look up.
Step 12: Retire the Old Host
Do not cancel the old hosting on the day you switch.
Keep it for at least seven days. Straggling visitors may still land there, and it is your instant way back if something unexpected breaks. Before you cancel, take one final full backup of the old account and store it somewhere other than the old host. Confirm your DNS is not hosted there, and confirm your email is not hosted there.
Then set up backups on the new server, because the old host may have been making them for you without you noticing. Read next: VPS Backup Strategy: How to Back Up a VPS and Actually Restore It
Common Problems and What They Mean
| Symptom | Likely cause | Fix |
|---|---|---|
| 502 Bad Gateway | Nginx cannot reach PHP-FPM, usually because the socket filename is wrong | Run ls /run/php/, correct fastcgi_pass, reload Nginx |
| “Error establishing a database connection” | Wrong credentials in wp-config.php | Recheck name, user, and password. Test with mariadb -u example_user -p example_wp |
| Homepage works, every other page is a 404 | The try_files line is missing | Add the location / block from Step 7 |
| 403 Forbidden | Wrong root path or wrong ownership | Confirm the path and re-run the chown command |
| Too many redirects | HTTPS redirect configured twice, such as in Nginx and in a WordPress plugin | Keep one and remove the other |
| Images broken or a “not secure” warning | Old http:// addresses stored in the database | Run a search-and-replace for http://example.com → https://example.com |
| “Exceeds the maximum upload size” | Upload limits too low | Raise client_max_body_size in Nginx and upload_max_filesize and post_max_size in PHP |
| Contact form emails never arrive | No outgoing mail setup | Use an SMTP plugin with a mail service |
Frequently Asked Questions
How long does DNS propagation take?
With a TTL of 300 seconds, most visitors reach the new server within 5 to 30 minutes. A small number of internet providers cache longer than they are asked to, so allow up to 48 hours for the last stragglers. Because both servers show a working site in that window, the delay causes no visible problem.
Will moving to a VPS hurt my search rankings?
Search engines look at your addresses and your content. If both stay identical, a change of host does not by itself give a reason for rankings to change. The more realistic risk is a slow or misconfigured new server, which is why testing in Step 8 matters.
Can I do this if my old host has no SSH?
Yes. Option A in Step 5 uses only cPanel’s File Manager and phpMyAdmin, which nearly every shared host provides.
Do I need to change anything inside WordPress?
Not if the domain stays the same. The only edit is the four database lines in wp-config.php. If the domain changes as well, that is a separate, larger task.
Should I use a migration plugin instead?
Migration plugins can work well for small sites, and they follow the same logic: copy, test, switch. Doing it by hand takes longer, but you learn exactly what is on your server, and it works for any site, not only WordPress.
Build the Second Copy First
A safe move is mostly patience in the right places. Lower the TTL early. Build the new server while the old one keeps working. Test the new one through a side door. Copy the final changes at the last moment. Switch DNS only when there is nothing left to learn about the new server.
Done in that order, the move is uneventful. Your visitors will never know it happened.
Never point visitors at a server you have not already tested.