I moved my sites to a new server. How can I get ee to pick them up?

Hi folks,

As the title says, I moved my sites to a new server and want easyengine to manage them again. I brought the nginx configs and certs with me using the automatic git repos, but missed the easyengine database. I need to get this sorted before the current certs expire, so ee can renew them automatically

Is there a way to tell a new easyengine to accept the sites from another install?

Thanks

Hi @coagmano You will need to import database as well. Alternatively, if you don’t want to sync DB, you can create a new site and then make changes in nginx configurations as per the previous configs.

There is an easier way to do this. First you need to install easyengine on your new server and after install your prefered WP site. I’ll copy/paste a guide which I have used with success:

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:

define('DB_NAME', 'DB_NAME');

define('DB_USER', 'DB_USER');

define('DB_PASSWORD', 'DB_PASSWORD');

define('DB_HOST', 'localhost');

define('DB_CHARSET', 'utf8mb4');

define('DB_COLLATE', '');

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-w3tc3) manually:

sudo ee site create www.sitename.com --wp --php7

Navigate to WP folder

cd /var/www/sitename.com/htdocs

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:

ls -la

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:

ls -la

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)

cd ..

Output the DB info for the WP site on the destination server:

cat wp-config.php | grep DB

You will get:

define('DB_NAME', 'DB_NAME');

define('DB_USER', 'DB_USER');

define('DB_PASSWORD', 'DB_PASSWORD');

define('DB_HOST', 'localhost');

define('DB_CHARSET', 'utf8mb4');

define('DB_COLLATE', '');

Then, navigate to /htdocs again and drop all tables using WP CLI or via PHPMyAdmin in your server IP’s 22222 port. e.g. 122.45.22.120: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.

Hope this helps.