In many cases you may want to make changes to an existing WordPress website. The only problem is that the website is live, online, and you don’t want to do anything to mess things up “live” or you don’t want to ruin user’s experience by showing them new stuff or errors while they’re browsing the website. So what you can do ?
The answer is simple: you need an identical copy of the website on your machine so you can work risk free. Ok, sounds good but how you can do that ? I’ll answer to this question in few steps that you have to follow in order to have a copy of the website on your localhost.
– On the live website go to cPanel and then find phpMyAdmin.
– On the left hand side select the database you want to export (same database that you’re using in wp-config.php file)
– On the screen that opens select the FORMAT to SQL and click “GO”. You’ll notice in your browser that the download of the file has started. Now in your “Downloads” folder you’ll have the database save in a .sql file.
– I am using FileZilla as my FTP client. You can use any other ftp client that’s not a problem. Once you connected to the website’s server via ftp, copy the whole content of the public_html folder into a folder on your machine. It may take a while depends on how big the website is.
– Once you’ve done that you have to copy that folder in your XAMP/MAMP in a folder called htdocs (on MAMP) or www (on XAMP).
– Now open phpMyAdmin on your local machine. Create a new database and look for the “import” button.
– On the screen that opens, select the file you’ve just exported from the live website and click “GO”
Now you have the database all set up on your local machine. The problem is that in the database you just imported there are links belonging to the live website like //site-example.com and now you are using something like //localhost:8888/site-example.com. In order to fix that you have to click on the website’s database on the left-hand side and then look for a tab called “SQL”. In that box you have to run the following SQL commands:
UPDATE wp_options SET option_value = replace(option_value,'//www.example.com','//localhost/example') WHERE option_name = 'home' OR option_name = 'siteurl'; UPDATE wp_posts SET post_content = replace(post_content,'//www.example.com','//localhost/example'); UPDATE wp_postmeta SET meta_value = replace(meta_value,'//www.example.com','//localhost/test-site');
One more small step and we’re good to go. Now you have to open the wp-config.php file and update the user name, database name and password to match the ones you have on your local machine. That should be it. Now if you go to //localhost/example you should be able to see an identical copy of //www.example.comI know there are lots of plugins to migrate but most of them faild when I tried to use them so I stick to the old school method.
How do you migrate wordpress websites ? Do you use a plugin or a manual method as described in this article ? I am curious how you guys are doing it. Looking forward for your thoughts.
For any questions, do not hesitate to leave a comment bellow.
Spread the word:Wednesday 27 February 2019 Marian V. Pop
Drop me a line at email@example.com. I'd love to hear from you.💌 Send Email