94.28 WordPress Transfer a Site

20200902

Consider the use case of developers having created a website based on WordPress using the facilities of https://wpengine.com. Suppose the actual instance is https://devhub.wpengine.com. The developers have supplied a zip archive from this site and our task is to get it running on our own new site, https://myhub.togaware.com.

Something like:

$ scp site-archive-devhub-live.zip myhub.togaware.com:
$ ssh muhub.togaware.com
$ unzip site-archive-devhub-live.zip
$ cd site-archive-devhub-live
$ rm -rf \
     wp-content/advanced-cache.php \
     wp-content/object-cache.php \
     wp-content/mu-plugins/mu-plugin.php \
     wp-content/mu-plugins/wpengine-common/ \
     wp-content/mu-plugins/slt-force-strong-passwords.php \
     wp-content/mu-plugins/force-strong-passwords/ \
     wp-content/mu-plugins/stop-long-comments.php \
     wp-content/mu-plugins/wpe-wp-sign-on-plugin/ \
     wp-content/mu-plugins/wpe-wp-sign-on-plugin.php \
     wp-content/mu-plugins/wpengine-security-auditor.php
$ perl -pi.bak -e 's|http://devhub.wpengine.com|http://myhub.togaware.com/blog|g' wp-content/mysql.sql
$ emacs wp-config.php
  DB_NAME -> 'wordpress'
  DB_USER -> wordpress'
  DB_PASSWORD -> '<secret>'
$ sudo rsync -avzh ./ /usr/share/wordpress/
$ sudo mysql -u root
mysql> CREATE USER 'wordpress@'localhost' IDENTIFIED BY '<secret>';
mysql> GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpress@'localhost';
mysql> FLUSH PRIVILEGES;
mysql> USE wordpress;
mysql> SOURCE wp-content/mysql.sql
mysql> INSERT INTO wp_users SET user_login = 'myhub', user_pass = MD5('<secret2>');
mysql> QUIT

Change settings in WordPress to set
  + WordPress Address (URL) http://myhub.togaware.com/blog
  + Site Address (URL)  http://myhub.togaware.com/blog

Can also be done from mysql
mysql> UPDATE wp_options SET option_value = replace(option_value, 'http://localhost', 'http://myhub.togaware.com/blog/') WHERE option_name = 'home' OR option_name = 'siteurl';
mysql> UPDATE wp_posts SET guid = replace(guid, 'http://localhost','http://myhub.togaware.com/blog/');
mysql> UPDATE wp_posts SET post_content = replace(post_content, 'http://localhost', 'http://myhub.togaware.com/blog/');
mysql> UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://localhost','http://myhub.togaware.com/blog/');

Browse to http://myhub.togaware.com/blog/


Your donation will support ongoing availability and give you access to the PDF version of this book. Desktop Survival Guides include Data Science, GNU/Linux, and MLHub. Books available on Amazon include Data Mining with Rattle and Essentials of Data Science. Popular open source software includes rattle, wajig, and mlhub. Hosted by Togaware, a pioneer of free and open source software since 1984. Copyright © 1995-2022 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0