Moving or migrating a WordPress Multisite can be frustating. If you don't know how to move it safely, your site can break along the way. Either the database, the settings, or both. Let me share you how to migrate WordPress Multisite safely without breaking anything.
In this tutorial, I will explain how to moving WordPress Multisite from live server to localhost with an example case: we will move WordPress Multisite from http://example.com to http://localhost/example.
In this case, the live server is using cPanel and the localhost is running on XAMPP.
- First, we have to copy all WordPress files from live server. You can download it all via FTP. Or if you prefer to download it directly from cPanel, you can go to 'File Manager' in your cPanel. Navigate to public_html. Select all files, click 'Compress'. Download the compressed file. Don't forget to delete the compressed file from live server after you finish download it.
- Now we need to copy the database. Go to cPanel's phpMyAdmin. Export the entire database of WordPress Multisite that we want to move.
- Create new folder 'example' in localhost folder (\xampp\htdocs\). Extract the compressed file that we have downloaded in step 1 to the folder 'example'. Now we have the WordPress files inside the folder 'example'.
- Create new database in the local phpMyAdmin. Visit http://localhost/phpmyadmin/. For this tutorial, I will name it 'exampledb'. Import database that we have exported from live site in step 2.
- Open .htaccess in the root folder (\xampp\htdocs\example\). Edit RewriteBase into:
- Open wp-config.php. Change database information to:
/** The name of the database for WordPress */ define('DB_NAME', 'exampledb'); /** MySQL database username */ define('DB_USER', 'root'); /** MySQL database password */ define('DB_PASSWORD', ''); /** MySQL hostname */ define('DB_HOST', 'localhost');
Also, edit these two lines to:
/* Multisite */ define('DOMAIN_CURRENT_SITE', 'localhost'); define('PATH_CURRENT_SITE', '/example/');
- After that, we need to change all urls. DO NOT manually search and replace everything. WordPress database use data serialization. Any mistakes can make your site cannot work properly. You have to use tools or scripts to search and replace database. As recommended on WordPress, we will use Search and Replace Database script from interconnectit.com. Download Search and Replace Database script (We use 'V 2.1.0 Stable' version for this tutorial). Update on 23 April 2016 - to make it clearer: on that script page, please scroll down until you see the red button 'Problems? Try v 2.1.0 STABLE'. Download the 'v 2.1.0 STABLE' version.
- Extract that script's .zip file. You will see a .php file inside. For security reason, rename it to difficult name. Something like: w39opzzzzzzzt.php. Make it hard to be guessed!
- Copy it to the root folder.
- Run the script by visiting http://localhost/example/w39opzzzzzzzt.php (or your choosen file name in step 8).
- Check 'Pre-populate the DB values form with the ones used in wp-config? It is possible to edit them later.' Click 'submit'.
- Click 'Submit DB details'.
- Select all tables. Leave 'Leave GUID column unchanged?' unchecked. Click 'Continue'.
- Search for http://example.com, replace with http://localhost/example. Click 'Submit Search string'.
- Don't forget to DELETE Search and Replace Database script .php file as soon as you finish use it!! It is very very important for security reason. You don't want someone to use it and break your site, do you? 🙂
- Go to database (http://localhost/phpmyadmin/).
- Check wp_site table (or yourtableprefix_site). Change domain, from example.com to localhost. And path, from / to /example/
- Also change domain and path in wp_blogs table (or yourtableprefix_blogs).
- Now, visit the site in http://localhost/example. You should see it running smoothly without problem. 🙂
Is this tutorial helpful for you? Do you want to add something to make it better? or do you want to share your experience when moving WordPress Multisite?. Share it all in comment form below.