Skip to content

📚 Step to step guide on how to migrate a WordPress website

Notifications You must be signed in to change notification settings

frankdarnese/wordpress-site-migration

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 

Repository files navigation

WordPress Live/Local Site Migration

Prerequisites

Before you follow this steps please ensure that the MAMP stack have been installed. Please also ensure that you have WP-CLI installed see instructions below.

MAMP v4.1.1+ MySQL v5.6.35+ PHP v7.0.15+ phpMyAdmin v4.6.5.2+ WordPress v4.8+ WP-CLI v1.2.4+

Quick guide

  • Download Database from the live server
  • Search and replace database links
  • Download WordPress
  • Clone or download the existing Wordpress theme
  • Download images & plugins
  • Run the WordPress install

Table of Contents

  1. Download Database from the live server
  2. Search and replace database links
  3. Installing WP-CL
  4. Download WordPress
  5. Clone or download the existing Wordpress theme
  6. Download images & plugins
  7. Run the WordPress install
  8. Testing
  9. More reading
  10. Footnotes

1. Download Database from the live server

You can download the database directly from your web server or alternatively, if you have ** SSH access ** to your live server, you can use the command line:

See example below:

1. website-wp user$ ssh www-data@125.25.125.125
2. Are you sure you want to continue connecting (yes/no)? yes
3. www-data@125.25.125.125's password: your-ssh-password
4. www-data@website-wp:~$ ls
html  mod_cloudflare
5. www-data@website-wp:~$ cd html/
6. www-data@website-wp:~/html$ wp db export db.sql
7. www-data@website-wp:~/html$ exit
8. Logout and DOWNLOAD DATABASE VIA SFTP

** Please not the IP address above is just an example **

Alt text

We need to replace the live site links to localhost links. We can use search and replace from the command line ( instructions to come ) or if you use phpMyAdmin, go to the databases and click to the database name you want to change, then click on the SQL tab (2 tab from top menu) and then insert the following command inside the:

Run SQL query/queries on database DATABASENAME

UPDATE wp_options SET option_value = replace(option_value, 'http://localhost:8888/testing', 'http://www.live-website.com') WHERE option_name = 'home' OR option_name = 'siteurl';

UPDATE wp_posts SET guid = replace(guid, 'http://localhost:8888/testing','http://www.live-website.com');

UPDATE wp_posts SET post_content = replace(post_content, 'http://localhost:8888/testing', 'http://www.live-website.com');

UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://localhost:8888/testing','http://www.live-website.com');

UPDATE wp_options SET option_value = replace(option_value, 'http://www.localhost:8888/testing', 'http://www.live-website.com') WHERE option_name = 'home' OR option_name = 'siteurl';

UPDATE wp_posts SET guid = replace(guid, 'http://www.localhost:8888/testing','http://www.live-website.com');

UPDATE wp_posts SET post_content = replace(post_content, 'http://www.localhost:8888/testing', 'http://www.live-website.com');

UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.localhost:8888/testing','http://www.live-website.com');

Alternatively use this nice and easy script link here that takes the old and new URLs and hands you the sql code for the WordPress swap.

The WordPress installation and general development is made easier through the use of WP-CLI tool. Follow the commands below to install it prior to setting up the project.

curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp

Download and create a new WordPress project folder:

mkdir your-wordpress-folder && cd your-wordpress-folder
wp core download --locale=en_GB

Or if you have 'Oh My Zsh' installed, you can simplify this with the take command which will create and swap into the directory:

take your-wordpress-folder && wp core download --locale=en_GB

Alternatively go to wordpress.org and download WordPress directly from there.

You need to clone from GitHub or download through FTP the existing theme into your WordPress theme folder:

cd wp-content/themes && rm -rf twenty*
mkdir your-theme && cd your-theme
git clone git@github.com:frankdarnese/wordpress-site-migration.git

or

  • FTP to your server and download the theme folder
  • go to the theme folder and initialize .GIT from command line

Download images & plugins via FTP from the LIVE wp-content folder to the local wp-content folder

Go to MAMP websites/ localhost:8888 and click on the new website we have just created on step 4 and run the installation.

(You will get a message saying that WordPress is already installed, that's absolutely fine as the database will take care of the rest).

IMPORTANT: Login with the online username and password. This is due to the fact that the database stores the live server dates.

You should be up and running with the local WordPress site on http://localhost:8081/WORDPRESS-SITE. Just run some test to make sure all is working fine and there are no conflict or plugins issues.

Contributions

Thank you in advance for your contributions! This repository doesn't really contain code, it serves to share my expertise with the world, hence I am not really expecting a lot of contributions from the community.

If you would like to fix a typo or propose suggestions, you are welcome to. Simply make sure your changes are being proofread and then submit a Pull Request. Thanks! 😄

About

📚 Step to step guide on how to migrate a WordPress website

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published