In this post I will outline the steps necessary to migrate your WordPress installation away from GoDaddy. Godaddy offers a lot of information to get you to migrate to them, but very little in the way of getting away from them. And honestly, why would they give you information that would help them lose money?
In any case, I used the following steps to migrate my GoDaddy Managed WordPress installation from GoDaddy to my own VPS on DigitalOcean. Now, much of this information is available directly from DigitalOcean in the form of guides, but a lot of it is either slightly outdated, incomplete, or incorrect.
If you follow these directions you will:
- Have a new, secure (via private key) VPS on DigitalOcean
- Have migrated your WordPress from GoDaddy to DigitalOcean
- This post assumes you have your own domain name (eg: www.yourname.com) and control over your DNS records for that domain
This post is broken down into two sections – Creating and Securing Your Digital Ocean Server and Migrating WordPress
Creating and Securing your DigitalOcean Server
This section will walk you through creating your DigitalOcean VPS and securing access to it.
Create a Digital Ocean Droplet
The easiest way to do this is to sign up with DigitalOcean, then choose an appropriate Droplet Configuration – for example, this blog (and a couple of others) are running on the $10/mo instance.
Then you will want to choose a datacenter region. This option is fully up to you. I chose San Francisco as I live close by. If you live close to another location, you may wish to choose them. The closer you are to a datacenter, the more likely it is you will see good speeds to it.
You will now want to click the “One-click Apps” section under “Choose an image”. Here are various Ubuntu images pre-installed with different types of software. Choose the “WordPress on 14.04” button to proceed.
Note: The tabs are not cumulative. One-click Apps are only available on Ubuntu — you either choose your distribution (eg: CentOS, Ubuntu, FreeBSD) and install WordPress manually or you choose a One-click App which will force you onto Ubuntu. If you have chosen “WordPress on 14.04” but had selected CentOS on the Distributions tab, you will end up with an Ubuntu 14.04LTS server with WordPress preinstalled from the image.
The way you go about creating a keypair will differ depending on the operating system you are on. This step is important in securing your server. You will use this keypair instead of a password to connect via SSH and SFTP.
Windows Users follow this guide – begin at “Download and Install PuTTY and PuTTYgen” and stop before reading “Create a New VPS Server with your Public SSH Key Embedded”
Mac Users follow this guide – begin at “Step One—Create the RSA Key Pair” and stop before reading “Step Four—Spin Up a New Server”
Once you have your new keypair, click “New SSH Key”
- Paste your public key into the “SSH Key content” area and hit “Add SSH Key”
- Save your private key somewhere on your computer. Your private key will be what you use to connect to your instance, so safeguard it with your life.
Wait a minute (literally) while your new server is provisioned for you. This process takes about a minute, two at most. When it is complete, you will see the IP Address of your server underneath the name of your instance.
Note: This was a throwaway instance that I made for the purposes of this blog post.
If you go to the IP Address of your new server in your browser, you will see this:
So, what do we do now? Do what it says! SSH into your server! If you do not SSH into your server at this point, if you browse to http://yourip/wp-admin/ you will see an error related to “Not Found” – SSHing into your server will enable the WordPress installation for configuration.
SSH Into Your New Server
Windows Users follow this guide – begin at “Setting up an SSH Session with SSH Keys in PuTTY” read through the end of the article.
- Open a terminal
- cd to the location of the SSH keys you created
- ssh into your server with the following command
ssh -i privatekeyfilenamehere root@yourserveriphereFor example, if I was connecting to an instance at 220.127.116.11, and my private key file was named “digitalocean.priv” then the full command would be:
ssh -i digitalocean.priv email@example.com
Congratulations, you’ve just Enabled WordPress on your new server.
We will want to run through the WordPress configuration immediately after Enabling it for security sake. Browse to http://yourinstanceip/wp-admin (eg: http://18.104.22.168/wp-admin/) in your browser and follow the initial WordPress setup prompts. Make note of the username and password you created.
Secure Your Instance
So if you are still with me, you have just created a new VPS server on DigitalOcean and have accessed it via private key over SSH. Thats a great start, but we must also secure SSH so that it rejects any login attempts that do not use keys. By doing this, it will stop simple brute force attacks over SSH which are basically just common background noise on the Internet now.
- SSH to your server
- Modify the /etc/ssh/sshd_config file
- Change or Add the value of PasswordAuthentication to “no”.
- Change or Add the value of PermitRootLogin to “without-password”
- Restart your server or restart your sshd daemon
Now, if someone tries to simply SSH into your server with or without a password, the connection will get rejected. However, if you try to connect with your SSH key, you will be allowed access.
Now that we have our shiny new secure, working VPS we can begin the process of migrating from GoDaddy to DigitalOcean.
Backup your GoDaddy WordPress Database
- Log into your GoDaddy phpMyAdmin page – if you are unsure of where this is:
- Log in to Gateway using your GoDaddy login.
- Under the WordPress hosting site you want to use, click Settings.
- Go to the SSH & sFTP or Database tab.
- Click Toggle Password to view the password to use.
Once logged into phpMyAdmin you will want to choose your WordPress database from under the “phpMyAdmin” menu on the left. Your database name will be prefixed with “wp” followed by a unique identifier (eg: wp_dfsjflkxjklj3r393)
Click the “Export” tab and then export to the Format of SQL.
Depending on your version of phpMyAdmin you may not have the “quick” and “Custom” options as you see here. However you accomplish it, you will want to make sure to export the entire database with the SQL format.
You will end up with one file with the extension of .sql — this is a SQL dump of your database. Guard it with your life.
Backup your wp-content
You will now want to connect to your GoDaddy account and download the entire /wp-content/ directory. You can find the SFTP credentials in the same place you found your phpMyAdmin credentials.
Windows and Mac Users: I prefer the FileZilla FTP Client
- SFTP into your GoDaddy Account with the given information
- Download the whole /wp-content/ directory so that you end up with a folder somewhere on your computer called “wp-content”. This could take a while depending on the amount of data and your download speed.
- Compress this file into a .zip so you end up with something like wp-content.zip – Windows and Mac both have built-in compression utilities)
Transfer Files to your VPS
Now we need to get both our wp-content.zip and database.sql over to our VPS. There are various ways of doing this, but since we already have FileZilla we can use that with our private key to securely connect over SSH.
- Launch FileZilla
- Go to Settings > SFTP
- Choose “Add Key File”
- Choose your private key that you made for connecting to your VPS
- Click OK
- Open Site Manager in FileZilla, and configure a connection as followsNote that the Logon Type is “Interactive”, user is “root”, but there is no password supplied as authentication will occur with your private key.
- Upload both wp-content.zip an your .sql file to a temporary location, say /tmp/
Import your database
Once again, SSH into your VPS. You will now be importing the data from the SQL dump you made earlier.
mysql -h localhost -u root -p wordpress < yourSQLfile.sql
This will prompt you for the MySQL root password before creating a database called ‘wordpress’ on your MySQL instance.
Your MySQL database has now been restored to your new server.
Unzip your content
You now want to unzip /wp-content/ to your web directory.
unzip /wherever/you/put/wp-content.zip -d /var/www/html/
You have now restored the contents of your old WordPress installations “wp-content” folder to your new VPS.
Now, we must edit the /var/www/html/wp-config.php file to reflect the new table names.
- Edit the file in your preferred editor, I prefer vim or nano
- Change $table_prefix = ‘wp_’; to include the prefix of your database.
Example: $table_prefix = ‘wp_dqzn1m1dkb_’;
- Verify that the db_name, db_user, and db_password entries are all correct (you might have to enter in your correct MySQL root password)
- Save this file
If you are still with me, up to now we have:
- Created a new VPS with WordPress pre-installed
- Secured the VPS
- Created a backup of GoDaddy SQL WordPress database and wp-content
- Restored the SQL database to the new server
- Restored the wp-content to the new server
Now it is time to test.
Test The Website
Right now, your website is probably at something like www.yourname.com (eg: www.jgomez.net). What we want to do now, is test to make sure the blog is working before we update public DNS.
To do so, we need to update our hosts file:
Mac Users: Edit your /etc/hosts file to include a line like this
Example: 22.214.171.124 foo.bar.my.blog.com
Windows Users: Edit your %SYSTEMROOT%\System32\drivers\etc\hosts file in similar fashion.
Doing this tricks our computer, and only our computer, into thinking your domain is actually at the new host already, but yet we haven’t updated public DNS, so the rest of the world is still going to your production website.
- Ping your domain, you should see the IP Address of your VPS
- Browse to your domain in a web browser – if everything was done correctly you will see your Blog.
- Log into your Blog and confirm things look good.
- Remove the entries in your host file that relate to your Blogs new IP Address
Remove GoDaddy Related Plugins
Open your plugins page in your Admin console of your WordPress instance. Find, deactivate, and delete the WordPress plugins that GoDaddy forced you to use, as of this writing I believe there were 3 of them.
One or two of them may be “must use” plugins which you cannot remove through the interface, so to remove those:
- SFTP to your new instance.
- Browse to /var/www/html/wp-content/mu-plugins
- Delete the GoDaddy related plugins here, it should be something referencing “gd-” or “godaddy”.
Modify .htaccess and info.php
Browse to http://yourVPSip/wp-content/uploads/ — what do you see? If you see an open directory and all your files are browseable, then you will want to follow the next few steps. If you don’t, you can ignore them.
- Add these line to the /var/www/html/.htaccess file
Options All -Indexes
This will prevent open directory listing of your website.
Browse to http://yourVPSip/info.php — what do you see? If you see a page with a bunch of information thats better off not being public, you can also add these lines to your .htaccess file – just remember to modify the “iprange/16” and “singleIP” to fit your needs.
# protect phpinfo
Deny from all
Allow from iprange/24
Allow from singleIP
Now that we have our blog up and running on our new host, we have to decomission the old blog and update DNS. The way in which you do this will vary depending on where your DNS is hosted, but the concept is the same — you need to update DNS A-Record for your domain to reflect your VPS IP Address.
Allow some time for DNS to propagate (up to 24-48 hours with some configurations) and then test accessing your domain again. If all goes well, you can now cancel your hosting subscription with GoDaddy.
Now that all this hard work is done, you may want to configure backups for your DigitalOcean instance. Doing so is very easy – simply log into DigitalOcean, click your droplet, then go to the Backups section. The price of a backup plan varies with the plan that you chose, but for the $10 plan its an additional $2/mo. Well worth it.
You now have a VPS Hosting WordPress
Now this might go without saying, but I must say so anyway. You now have a VPS — that is an entire server dedicated to your WordPress installation. That sounds great, but you must remember to keep up with updates, patches, and security for it as well. You are in total control — which may or may not be a bad thing. Keep in mind that Digital Ocean is very hands-off, meaning that they leave the maintenance and upkeep of your server up to you, and the most they can or will do is provide you with a stable environment and some whitepapers and blog posts of their own to configure things with.
Hope this helps.