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
Wordpress
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

Migrate
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 stlplace.com to here.

(Update 12-02-2015)
Started working on moving stlplace.com 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 uudaddy.com, and found I miss this line for /etc/nginx/sites-available/stlplace.com :
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 wordpress.org (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 uudaddy.com 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 happymandarin.stlplace.com (this is a legacy of shared hosting feature) to www.stlplace.com/happymandarin. Btw, this is my wife’s site.

Published by

omaha

I am Youyou's daddy.