I found out about EasyEngine a few days ago and have been playing around with it on an Ubuntu 16.04 VPS. Loving it! Ease of use and performance is really solid.
So, once testing was over, I tried moving some of my sites into EE. After some trial and errors, below is what I ended up with. Hope it is useful for others as well.
Site migration scenario
My site HTTP://WWW.SITENAME.COM (no SSL) is hosted on the origin server wih SSH access. I want to keep the same domain on the destination server with EasyEngine fully configured, including admin tools at port 22222. We are assuming the use of a ‘sudo’ account below, thus, all commands begin with sudo, except for WP CLI commands. If you are logging in as root user, no need to include sudo in the commands.
Useful trick: copy paste in terminal. as I use Putty on a Windows machine to access the servers.
Step 1: On the origin server
Navigate to WordPress folder in the origin server. e.g. /public_html, /webapps, /applications, depending on your system. Enter directory where wp-config.php is stored (if not already at the WordPress folder).
Enter the following command to display DB info:
cat wp-config.php | grep DB
You will get:
Dump the database using:
sudo mysqldump -u DB_USER -pDB_PASSWORD DB_NAME | gzip > sitename.sql.gz
Note that -p and DB_PASSWORD is joined together. No spacing in between. This is where terminal (Putty) copy paste comes really handy.
Compress ‘wp-content’ folder with:
sudo tar -czvf sitename.tar.gz wp-content
Step 2: On the destination server
Create new site using EasyEngine. I’m using PHP7 site here and will install a modded version of W3 Total Cache that works well with memcached/redis (https://github.com/szepeviktor/fix-w3tc) manually:
sudo ee site create www.sitename.com --wp --php7
Navigate to WP folder
Download DB dump and wp-content from origin server:
sudo curl -O http://www.sitename.com/sitenamedb.sql.gz
sudo curl -O http://www.sitename.com/sitename_wpcontent.tar.gz
Extract wp-content into WP/current directory:
sudo tar -xzvf sitename_wpcontent.tar.gz
Check and fix folder permission:
wp-content folder should have same permission as the . line or the first line, which is www-data for user and www-data for group. You will see it is not, so, enter the following command to fix:
sudo chown -R www-data:www-data wp-content
Check again it has been updated with:
If you have a .git repo and .gitignore in origin server, you need to repeat the similar procedure above to compress in origin server, transfer to destination server, extract and fix permission.
Now, let’s migrate the DB. First, extract the downloaded file with:
sudo gunzip sitenamedb.sql.gz
It will delete the sql.gz file and leave only the .sql file.
Navigate up to the directory where wp-config.php is stored (/var/www/sitename.com)
Output the DB info for the WP site on the destination server:
cat wp-config.php | grep DB
You will get:
Then, navigate to /htdocs again and drop all tables using WP CLI or via PHPMyAdmin in your server IP’s 22222 port. e.g. 220.127.116.11:22222
wp db reset
Then, import DB content with:
sudo mysql -u DB_USER -pDB_PASSWORD DB_NAME < sitenamedb.sql
In the origin server using WP CLI, or via PHPMyAdmin, check DB table’s prefix
wp db tables
Note down table prefix, e.g. s1t3n4m3_, then navigate up a folder to edit wp-config.php to use table prefix from origin site’s DB
sudo nano wp-config.php
At this point, the data migration is complete, but before changing DNS records, some tidying up first.
Step 3: Tidying up and going live
Check if you need to edit nginx configuration or not. e.g. access only through www, or without www:
sudo ee site edit www.sitename.com
Look at server_name row, and remove the URL with / without www as you need. Since our scenario is to access via www, leave things as is.
Clean up .gz files on origin and destination servers WP folders.
sudo rm sitename*
Clean up Hello Dolly and/or Akismet plugins, unless you want to keep them of course. Go into /wp-content/plugins folder and:
sudo rm -rf akismet
sudo rm hello.php
Still in the plugins folder, using WP CLI, activate the NGINX Helper plugin installed by EasyEngine:
wp plugin activate nginx-helper
Update DNS to point to site on new/EasyEngine server.
A record @ should point to destination server’s ip.address
CNAME record ‘www’ should point to @ (which in turn points to destination server)
From my experience, a Time to Live (TTL) of 30 minutes should be sufficient to start testing the site on the destination server. Use https://www.whatsmydns.net or https://dnschecker.org to check.
Once new site is accessible and you can login, clear any and all cache from related plugins you use. e.g. Autoptimize, W3 Total Cache.
Congrats!.. and enjoy the speed bump with EasyEngine.
p.s. I was used to doing site migration using a WP plugin, so, the above is really my first adventure into the land of the command lines… …and I can see why developer-types likes it. It is flexible and fast!