advice and tips

Move WordPress from Share Hosting to DigitalOcean

(Original 11-12-2015)
I decided to give cloud server another try, after my failed attempt to move WordPress from shared hosting to Amazon AWS last year. This time I go with DigitalOcean as I heard good things from my friend Don (who made this cool makeyourcase site and api).

Decision choosing Apache or Nginx
I chose Nginx over Apache due to 2 reasons:
1) I had fairly bad experience running Apache web server on Amazon tc2 micro instance last year. It was fighting for resources with MySQL server;
2) I saw Nginx getting popular recently. And it must have its own strength (performance, scale better). Did read Apache vs Nginx: Practical Considerations.

Some tips and tricks
1) Need to fix the extension for php in nginx setting. Follow this instruction will help, for php the key is the location setting below:

location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;

2) I found again I could not update the plugins after the move, found again this is due to file permission problem. After I grant the correct file permission to wp-content folder, it appears update plugin fine (kebo twitter plugin). Actually the initial problem was the twitter feed was not showing, which leads me to the plugin update. In the process I also changed the twitter feed.

3) A related problem is I went to this maintenance page, after I started updating a bunch of plugins. It appears stopped at the “related post” plugin.

Briefly unavailable for scheduled maintenance. Check back in a minute.

The fix was to delete the .maintenance file in the website root folder (refer to this thread at wordpress site)

Useful links
How To Install WordPress with Nginx on Ubuntu 14.04

How To Install Linux, nginx, MySQL, PHP (LEMP) stack on Ubuntu 14.04

Virtual host
How To Set Up Nginx Server Blocks (Virtual Hosts) on Ubuntu 14.04 LTS

Host name (DNS)
How To Set Up a Host Name with DigitalOcean

How To Migrate WordPress from Shared Hosting to a Cloud Server with Zero Downtime

Ubuntu initial setup
Initial Server Setup with Ubuntu 14.04

Additional Recommended Steps for New Ubuntu 14.04 Servers (think security 🙂

How To Add Swap on Ubuntu 12.04

In general, I think those articles/tutorials above made the job of newbie’s much easier. For me personally I have some UNIX/Linux/Mac experience (and concept), but I’ve never done system admin job full time. Those instructions made my life much easier.

Overall impression 
I spent about total 3 hours to spin up the Linux server, MySQL and nginx web servers, install and set up WordPress, and move site from shared hosting to droplet. The next step is to see the reliability of this setup, if everything is ok, I plan to move to here.

(Update 12-02-2015)
Started working on moving from shared hosting to droplet. That site is about 10 times bigger because it has my 10 years blogs. Encountered a few problems shown below. Was able to overcome so far. It’s up and running and let’s see if the droplet will hold up 🙂

1) Moving of mysql database: from my past experience, direct export via phpmysqladmin won’t work. I tried command line approach again. Note I tried the .gz file format as well, but it failed during import (may due to my data problem in the old mysql db). But regular .sql importing worked.

2) The permanent links stopped working, after looking at the php setting for nginx, file (folder) permission, finally I was able to compare this with, and found I miss this line for /etc/nginx/sites-available/ :
try_files $uri $uri/ /index.php?q=$uri&$args;

After adding this line, the permanent links worked.

The remaining task is to make Chinese characters show properly. I encountered this problem last time when moving it to Amazon AWS. Luckily I found this life saver from (I kind of sensed it as I read from the old wp-config.php, I something much simpler, it does not have the following 2 lines):
Not encoding – collation.
In the newer version of WP the config file has two new lines:

define(‘DB_CHARSET’, ‘utf8’);
define(‘DB_COLLATE’, ”);
If it is an upgrade, delete those two lines!

Last but not least, I found I could not update the plugin again after installation. After much try and error, trying to emualte setup (which works), I found this article on digitalOcean about setup wordpress FTP user/keys for update. I followed along and was able to made it work as desired.

(Update 12-03-2015) I also moved a small wordpress site (happymandarin) from shared hosting to droplet. The one obstacle here was I manually changed the ‘siteurl’ and ‘home’ of wp_options table from (this is a legacy of shared hosting feature) to Btw, this is my wife’s site.

(Update: sometime in the early part of 2019, likely between Apr to June) I updated the ubuntu from 14 to 16, in the process I also upgraded the PhP version. Had to do a small fix (change) to make sure the php continues to work on nginx side.

(Update 03-14-2020 Pi Day) I moved the wordpress site under There was some small technical challenges, but the steps are similar to the one above. I also found out the wordpress update (one click update) prompt me to the annoying ftp credentials. It seems the digital ocean article above (2013) no longer works. I changed the folder ownership from wp-user:wp-user to www-data:www-data, as well as adding this line define(‘FTP_METHOD’, ‘direct’ ); to wp-config.php , now the one click update seems to work. Not sure if it will have any other issues for example, upload a picture in wordpress etc. I will update as time goes.

Btw, the reason I moved (not renewing the domain) is mainly for consolidation. The asks for $18 for domain per year. It seems to me it’s a bit overpriced. My domain expires in 2022. That’s the only dependency I have for godaddy. For some tech people, it seems Godaddy does not have high reputation.

Also, how to get free ssl cert.

By omaha

I am Serenity and Sophia's daddy.

1 reply on “Move WordPress from Share Hosting to DigitalOcean”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.