Migrating from WP Engine

by Gisle Hannemyr

WPE (Wordpress engine) is a managed hosting provider for Wordpress site, charging US$ 200 per site per year.

Table of contents

Introduction

Karde AS has traditionally outsourced hosting of all its Wordpress websites to WP Engine. This is a company provides premium managed hosting. Hosting a small site there costs $US 200 per year.

Basically, they provide:

See alsoStart out by reading: WPEngine.com: Migrate a WP Engine Site to Another Host; InMotionHosting.com: How to Migrate a WordPress site from WP Engine.

In brief

Because of Wordpress' hardwired internal URLs, migrating directly to a production websites is simplest, provided there is access to the DNS dashboard at the registrar.

  1. Configure Apache2 for the site.
  2. Set up a database for the site.
  3. Unpack the tarball. The siteroot goes in /var/www/example.com/web/.
  4. Check that it is there.
  5. Set up TLS.
  6. Make sure you can login as admin. Often simplest to edit the {users} table.

If there is no login page, look at Wordpress administration.

Outdated plugins may cause PHP and other errors. Consult with client what to do with these.

Preserve key data

You may want to take a screen shot of the legacy website, to have a record of what its should look like.

mylifeproducts_fp.png
The front page of mylifeproducts.no

Make sure you record key data about the site:

Original URL: semicolon.no.
Original IP: 35.189.107.25.
Staging URL: semicolon.roztr.org.

Original DNS:

Host             RRType Data
semicolon.no     ANAME  semicolon.wpengine.com
www.semicolon.no CNAME  semicolon.wpengine.com

Test URLs:

phpMyAdmin

Migrations tasks

There are three challenges that must be faced when migrating a Wordpress site to a new Url:

  1. The site URL is hardwired in the configiration file and in the database, and redirections to the the old URL will stop you from logging in and access the admin dashboard.
  2. If the staging site is not seet up to use TLS, there may be settings in the configuration file to force TLS (SSL).
  3. All internal links have absolute URLs pointing to the old location.

Set up DNS

Permform the following steps to set up a parked version of the domain:

  1. Visit domeneshop to set up DNS-pointer for semicolon.roztr.org.
  2. Copy 0_parked/ into /var/www/semicolon.roztr.org.
  3. Edit semicolon.roztr.org.conf.
  4. sudo a2ensite semicolon.roztr.org.conf
  5. apache2ctl configtest
  6. sudo systemctl reload apache2

Install codebase and database

# Database Configuration
define( 'DB_NAME', 'wp_semicolon' );
define( 'DB_USER', 'semicolon' );
define( 'DB_PASSWORD', 'xfHE0WqF3agAWrtSgvXB' );
define( 'DB_HOST', '127.0.0.1' );
define( 'DB_HOST_SLAVE', '127.0.0.1' );
define('DB_CHARSET', 'utf8');
define('DB_COLLATE', 'utf8_unicode_ci');
$table_prefix = 'wp_';
  1. Unpack the tarball in ~/karde/.
  2. Set up /var/private/semicolon for database backup.
  3. Move the .sql-dump into the backup directory.
  4. Move the codebase root directory into the site root and name it web.
  5. Set up a database for WordPress by editing "mysql_createdb.sh". Keep DB_NAME, DB-user "gisle" with my own stanadrd credentials.
  6. Edit wp-config.php to change credentials.

Use this command to roll back the database:

$ wp db import /var/private/semicolon/wp_semicolon.sql
Success: Imported from '/var/private/semicolon/wp_semicolon.sql'.

If this fails, use this instead:

$ sudo mysql wp_semicolon < /var/private/semicolon/wp_semicolon.sql

Clean out wp-config.php

There are stuff in wp-config.php that doesn't do anything when no longer hosted on WPE, or do the wrong thing.

Remove all variables in in wp-config.php starting with $wpe_.

Remove all definitions in in wp-config.php starting with WPE_.

Change this setting to "true":

define( 'WP_AUTO_UPDATE_CORE', true );
Remove these:

define( 'PWP_ROOT_DIR', '/nas/wp' );
define( 'PWP_NAME', 'domain-name' );

See alsoThis one may not contain accurate information: BlueTide.ca: Code to Remove from wp-config after moving from WPEngine about what to remove. Investigate further.

Fix permissions

There is now a script to do this:

$ fixpermswp.sh
Password:

Change site URL

When migrating a Wordpress site to a new URL, there are hardwired settings may result in redirections to the the old URL. This will stop you from logging in and access the admin dashboard of the relocated site.

To fix this. edit the file wp-config.php. After the "define" statements (just before the comment line that says "That's It. Pecils down"), insert the following line:

define( 'RELOCATE',true );

Before testing, clear cached content in the browser.

In addition, you may need to use phpMyAdmin to change two keys in the {wp_options} table to point to the new domain::

You may also do this by means of query:

UPDATE wp_options SET option_value = 'http://semicolon.roztr.org' WHERE option_name = 'siteurl';
UPDATE wp_options SET option_value = 'http://semicolon.roztr.org' WHERE option_name = 'home';

To be able to log in, get the login name of user #1 and change the password:

$ wp user list
…
$ wp user update 1 --user_pass=cleartext

Open a web browser and visit /wp-login.php on the new server. Navigate to Settings » General (Innstillinger » Generelt) and verify that both the address settings (WordPress-adresse (URL) Nettstedsadresse (URL)) are correct. Remember to Save Changes.

Once this has been fixed, edit wp-config.php and remove the line.

If it still redirects to the old URL, you may try to put these definitions (in wp-config.php)points to the correct URL for the migrated site (if they exist):

define( 'WP_SITEURL', 'http://semicolon.roztr.org' );
define( 'WP_HOME', 'http://semicolon.roztr.org' );
define( 'DOMAIN_CURRENT_SITE', 'semiolon.roztr.org' );

Note: Putting these wp-config.php will stop them from displaying in the General settings in the dashboard.

Source WordPress.org: Changing The Site URL.

To solve the remaining problem: Absolute internal links. Use the Search & Replace plugin. [Try: Better Search Replace.]

Install the latest version from of Better SearchReplace from wordpress.org and activate:

$ wp plugin install search-and-replace --activate
$ wp plugin install better-search-replace --activate

Navigate to Tools » Search & Replace » Replace Domain URL and fill in the replacement pattern:

Search for: semicolon.no
Replace with: semicolon.roztr.org

Click Do Replace Domain/Url. The operation will take some time.

Navigate to Settinngs (Instillinger) » Permalinks

Notice what setting you have selected, so you can put it back later. Options are:

If you are using a Custom Structure copy and save it.

Select the "Plain" setting, then click the "Save Changes" button. If you already have the "Plain" setting selected, choose "Day and name", then click the "Save Changes" button.

You will then see a message stating "Permalink structure updated".

Now, restore your original setting, and click the "Save Changes" button again. You are finished when you see the "Permalink structure updated" message again. Your site permalinks should now be working again. You may have to clear your browser cache before testing in order to see the change.

Source InMotionHosting.com: How to Reset WordPress Permalinks.

General cleanup

The following plugins are part of the WPengine environment and should be disabled and deleted. For details, see Manage plugins.

The same goes for these if they are found:

Fix metadata for user #1.

Remove unused plugins and themes. Update those that remain.

Run health check.

Miscellaneous tasks

To get access to the admin account use wp in the CLI, or alter the {users} table in the database.

If the code base contains MFS resource forks (files with names starting with “._”, e.g.: “._README.txt”), they sometimes are included on page loads, showing a band of text above the HTML that contains the string “apple.metadata” (see screenshot below). These are useless on Unix and should be deleted.

resourcefork.png
MFS resource fork appears above HTML.

To search for them below the current directory:

$ grep -r "apple\.metadata" . | more

To delete them below the current directory:

$ find . -name "._*" -type f -delete

The following can safely be removed from the code base:

See alsoithemes.com: What Files Should Be Excluded Within A WordPress Backup?

Themes used by Karde

Troubleshooting

Redirects

The the most common cause for redirects is HTTP Strict Transport Security (HSTS). To clear HSTS-settings, see the chapter about TLS.

If you experience that typing example.com into the browser's address fields forwards to https://www.example.com/wp-signup.php?new=example.com, some values in the WordPress database may need adjusting-

This may be caused by the “ServerName” in the Apache configuration file for the domain is not matching the domain and siteurl in the {blogs}, {site} {options} tables. Make sure they all match [2023 note: can't find this tables anymore, outdated?]:

Apache configuration:
ServerName        example.com
WP Database:
{blogs.domain}    example.com
{site.domain}     example.com
{options.siteurl} https://example.com

Test all combinations and make sure none redirects:

http://example.com      RD
https://example.com     RD
http://www.example.com  OK
https://www.example.com OK

Source SE.WPD: Site Redirecting to wp-signup.php.

If you experience site redirects to some other URL (typical to a legacy domain for the site), try to clear the browser cache. Here is how for differen browsers:

Chrome:

[TBA]

Edge:

[TBA]

Firefox:

Navigate Hambruger menu (upper right) » Options » Privacy & Security. Then look under "Cookies and Site Data" and click "Clear data". Make sure that "Cached Web Content" is ticked. Click "Clear".

If you also tick "Cookies and Site Data", stored credentials are cleared.

Safari:

[TBA]

imagick

The WP Health Check may complain about:

“The optional module, imagick, is not installed, or has been disabled.”

To install and enable:

$ sudo apt install  php-imagick
$ sudo systemctl reload apache2

Source WordPress.org: PHP imagick.

WP-Pro-Quiz

The plugin WP-Pro-Quiz cannot be deleted from the GUI.

  1. Drop all tables starting with wp-wp-pro-quiz from the DB
  2. Delete the plugin from the CLI.

No administrator access

"Sorry, You Are Not Allowed to Access This Page" https://stackoverflow.com/questions/11194028/plugins-menu-doesnt-appear-in-the-admin-panel https://wordpress.stackexchange.com/questions/313826/wordpress-address-url-option-missing-under-general-setting https://kinsta.com/knowledgebase/sorry-you-are-not-allowed-to-access-this-page-error-in-wordpress/

Final word

[TBA]


Last update: 2020-10-20 [gh].