How To Move Your Wordpress Site to a VPS

Many beginners start their first few websites on shared hosting.

A good choice because you likely don't have the technical skills to setup and maintain your own private server, configure nginx/apache, host your own mail, set up your own nameservers and many other things you will have to do run everything yourself.

But after a few years, you are probably sick of your hosting company. Especially if you have multiple websites and you are paying $$/month for every domain.

You are technically limited, support is slow and often outsourced to Indians who don't have the technical knowledge necessary and many other downsides that come with most hosting companies.

I was facing the exact same issues and I decided to move my websites to a Virtual Private Server. This seems like a daunting task at first but with all the resources available online, it's easier than ever.

This does not mean anyone can do it. I recommed you know your way around the command line and know the basics of SSH.

Here are all the steps I followed to move a Wordpress website from a shared hosting to a VPS.

Setup a Server with Wordpress

You can do this manually but many VPS providers provide a one-click Wordpress install so PHP, MySQL, Wordpress and Apache/Nginx are already setup for you.

I went with Vultr's One-click Wordpress install because their hardware is fast, reliable, their UI is amazing and their price is good too!

Initial Server Setup

Once your new server is up and running it's important to make sure you take all necessary security steps. Setting up the permissions, user accounts, adding your SSH key, etc.

Don't worry if you've never done this before. Digital Ocean has a great guide for this.

"But my server is with Vultr!!" Yes, but they are running on the same OS so you can always use Digital Ocean, Linode or any other companies' documentation.

Especially Digital Ocean has great docs.

Import your Database and Files

Now you can import the database and website files of your existing shared host to your new server.

Create an SQL dump from your existing database and import that into the database on your new server. You can do this in the command line but I personally installed PhpMyAdmin to make this and other database admin tasks easier.

To import your website files you should copy your public_html folder to your local disk. If you are using a caching plugin on your Wordpress website, it's best to empty the cache before starting this action. Otherwise copying will take a lot longer since it will also copy thousands of cache files.

Once you have these copied you can move them to the /var/www/html/ folder on your new server. Either on the command line or using sFTP.

You will need to update your wp-config.php file to match the credentials of your new database.

Testing

To make sure the migration goes smoothly, it's important to test if everything is working properly before sending the traffic to your new server.

You can test this locally by updating your hosts file
sudo nano /etc/hosts

Mapping your domain to the IP of your new server
server_ip_address yourdomain.com

And clearing your DNS cache (Mac OS High Sierra)
sudo killall -HUP mDNSResponder

Now, if you visit yourdomain.com, all pages will be loaded from your new server.

If everything works as expected then you can move on, if not you can troubleshoot and fix the issue.

If everything works, you can remove the above line from your hosts file and clear your DNS cache again.

Change the DNS Settings

You can now change your DNS settings so that the domain will send all the traffic to your new server. You should not experience any downtime during the migration if you have setup and tested your server properly.

DNS propagation can take up to 72 hours but it usually takes no longer than a few hours. You can check the status with this global DNS tracker tool.

Note that if you are using Cloudflare, your IP will not change! In this case you should monitor your server load to see when traffic is being redirected as the DNS tracker tool mentioned above will show no difference in IP after the migration.

If you are moving from a shared host, you probably also host your email with your old host. You will need to setup your email with G Suite, Zoho or any other provider that supports custom domains. They will provide you with the instructions needed to change your MX domain records so all email is directed to your new email provider.

Bonus: Configure Automatic Security Updates

Now that you are running your own server, you are also responsible for keeping it secure and up-to-date.

To automate installing updates you can setup unattended-upgrades.

Bonus 2: Setup Automatic Backups

To make sure you never lose your data in case of an emergency, I highly recommend making automatic backups.

Vultr has a built-in backup option, for extra redundancy you should also consider automatic backups to Backblaze or Amazon S3 and a local harddrive.

For me, the move was 100% worth it.

Jurn W

Traveling indie maker. Freelance designer and developer. Creator of Screely. Chosen one of the most promising young talents in the Dutch tech industry by The Next Web.

Subscribe to Jurn.blog

Get the latest posts delivered right to your inbox. No marketing campaigns. Unsubscribe anytime.

or subscribe via RSS