I am finished with Bluehost/Hostgator and other similar hosting providers.
All my sites are now hosted on either Digital Ocean, or Compute Engine on the Google Cloud Platform.
Moving sites using no control panel (pure SSH) was a big learning experience for me.
By the end of moving around ten sites though I learned a great deal and here is a list of the actions required.
If I need to do it again, or someone else can use the info it will be a great time saver.
Methods you can use to move a site
There are a number of ways you can move a site.
- By using a plugin to migrate your site
- Using the export/import features from WordPress
- Manually zipping up your content and your database and moving them
Method one completely failed for me. There were a number of plugins that you can use, but they were either pay for, or didn’t work properly. If any have worked for you please leave us a comment about your experience.
Method two I used for a couple of sites. It is very quick to do the initial setup, but you end up spending a long time re-configuring everything because it doesn’t bring all your settings and plugins etc across. Good if you want to start afresh though.
Method three is quite technical, but ends up with the site in the best state at the end of it.
Here are the high level steps. If you are unclear on any of the detailed bits you will find plenty of info online.
Moving your site to the Google Cloud Compute Engine
First of all we need to build a new instance in the Google Cloud compute engine.
Go to cloud launcher and launch a standard WordPress install. Make sure you check the option to include phpmyadmin.
Customize your server to give it the specs you need.
With just a couple of clicks you will have a new server instance with phpmyadmin and wordpress installed.
You probably will want to change the disk to SSD.
Make sure you change the IP address to static. Do this under the networking option.
On old server:
Back up the directory and the database.
Connect via SSH and browse to the root of the directory of where your site resides.
Zip up all the files.
zip -r backupyoursite ./
Export the database using PHPMyAdmin Export.
Change the options so that you drop tables that already exist. And remove the if exists under create tables (otherwise it won’t refresh the existing database properly).
On new server:
Install wget if necesary – then download file
sudo apt install wget
Download the backup file into the directory from where you want to unzip it.
Sudo /usr/bin/wget http://yoursite.com/backupyoursite.zip
sudo /usr/bin/unzip backupyoursite.zip -d ./
Make sure you overwrite any existing files.
Change the owner of the files in your html directory.
Sudo chown -R www-data:www-data html
Change maximum upload size to say 20 Megabytes.
/etc/php5/apache2$ sudo nano php.ini
sudo /etc/init.d/apache2 restart
Now go into phpmyadmin and import your script.
Create a mysql user for your wordpress site.
Edit your wp-config.php and update the database details
Thats it! You are almost done.
Now you can test using the IP, or even better edit your hosts file to point the domain name to the new IP address.
Update the DNS using cloud dns (make sure you create an A record and a cname record)
Update the nameservers
Lastly, and this is a real gotcha, remove the robots.txt that was installed in your WordPress root directoy because it blocks all search engines.
I only realized this after getting a warning in Webmaster tools, some days later.
sudo rm robots.txt
PS to check for security update packages you can run this.
sudo unattended-upgrades -d