In this tutorial I show you how to download a wordpress website on your local computer and run a mirror copy of it there.
This gives you the the ability to test out website ideas privately or ensure that you have a plan B if your website get’s hacked.
The video below gives you a "look over my shoulders" view as I walk you through the steps.
Sign up below and get notified when new Business Programmer web related blog or video tutorials are created.
Setup WordPress Locally – Steps in Brief
The following steps are covered in detail in the video above.
- Get Mamp from https://www.mamp.info this gives you a complete php, mySql and Apache enviornment on your Mac or PC.
Use a filemanager like FileZilla to backup your live site to you hard drive.
You could look into plugins for this backup process, however I prefer this way.
This saves you having to redo all your customisations.
Create a local wordpress mySql Database and User, these can have the same names as the database on your live site, or they can be different.
Database and login details are stored in wp-config.php which is normall stored in the root (top level) directory of your website.
Download your WordPress database using for example phpMyAdmin withn your CPanel Area, Bluehost Web Hosting (affiliate) provide a fully featured cpanel.
Choose the export tab and go with the "Sql" file option, this will result in a file like "YourDatabaseName.sql".
Download the file by clicking "Go".
- Import the sql file downloaded in the previous step into your database created in step 3 above using the "import" tab in phpMyAdmin.
- Execute the Sql queries listed further down the page using the "sql" tab in phpMyAdmin.
SQL To Change URL in you WordPress mySql Database
In order for everything to work some changes will need to be made to your LOCAL mySql database, in order to update it for you new LOCAL user and for the fact that the web address of you site has changed to your local machine.
The following four update queries handle the URL (web address) changes to your database
Note do NOT use trailing backslashes in your web addresses, wordpress does not like those.
update wp_options set option_value = replace(option_value, 'http://www.YourLiveSite.com', 'http://localhost:8888') where option_name = 'home' or option_name = 'siteurl'
update wp_posts set guid = replace(guid, 'http://www.YourLiveSite.com', 'http://localhost:8888')
update wp_posts set post_content = replace(post_content, 'http://www.YourLiveSite.com', 'http://localhost:8888')
update wp_postmeta set meta_value = replace(meta_value, 'http://www.YourLiveSite.com', 'http://localhost:8888')
This final query ensures that the user you created can use the database, this is the user id that wordpress uses in it’s wp-config.php file. Note the use of the "back quote" here rather than the simple single quote.
grant all PRIVILEGES ON `YourDatabaseName`.* to `YourNewUser`@`local`
Verify Web Address Has Changed In Database
Finally you may need to verify that the changes you made to the site url in your database have actually happened, this can be done with the following three queries.
select option_value from wp_options where option_name in('siteurl', 'home') select guid from wp_posts select meta_value from wp_postmeta where meta_value like 'http://%'
You should now be good to go!
Leave a Reply