If you have installed a local blog on your computer for testing purposes you probably will need some actual ‘real’ content to test out all your theme or other changes. Creating ‘dummy’ content is one option, but it can take awhile to create and is not the same as the actual content that a ‘live’ blog contains.
So if you already have a blog online, you can follow these steps after you have your local environment (Apache, PHP, and MySQL) up and running.
Step 1: Create a backup from your current live blog.
- Log into phpMyAdmin (from a web host account), and select the “Export” tab.
- Select the database your WordPress blog uses.
- Make sure the “SQL” radio button is selected.
- Click the “GO” button.
- A new screen will display with a textarea box containing many SQL statements. These will re-create your entire database, tables with content when executed.
- Copy this script to your favorite text editor
Step 2: Modifying your backup script.
- Since we are restoring to a database from a different blog, we have to ‘tweak’ it a bit (database name and url parameters).
- Change name of the database to the database of your development blog. This should be the first command in the script starting with CREATE DATABASE.
- There are two lines that you need to specify the url of your development (http://localhost/). Do a text search on the ‘wp_options’ table. You will need to change the parameters of two INSERT INTO statements (‘siteurl’ and ‘home’).
Step 3: Copy your blog folder structure.
- Copy the entire folder struture (and all files) of your live blog to your root directory of your local Apache environment. You can create a subfolder in your root if you wish. I discuss where this location is in the lesson.
- Once copied, open up the wp-config.php file and make the neccessary changes. This would involve changing the database name (DB_NAME), database user (DB_USER), and database password (DB_PASSWORD) and MySQL host (DB_HOST). I discuss this in the lesson as well.
Step 4: Execute your modified restore script.
- Open up phpMyAdmin in your local environment
- Select the “SQL” tab.
- Paste the restore script in the textarea box.
- Click the “Go” button.
- Verify that the database and tables have been created.
Step 5: Open up your local blog
- Go to your local blog that you just copied all the files to. This will be http://localhost/. You will specify the subfolder if you created that as well.
- Log into you blog
Now you have an exact local copy of your live blog that you can develop and test.
Note: Since we didn’t change any other parameters in the restore script, some of your plugins may not work. Also, if you use custom permalinks, you may need to modify your .htaccess file. Change your permalinks to the default setting (Settings->Permalinks), if you cannot see certain pages in your local blog.