As a WordPress bloggers, plugin developers or themes designers you should have a local server for a testing environment. In Ubuntu you can easily install apache and mysql as it is bundled in default installation cd. And in Windows you can use XAMPP as a handy web server (you can refer to my previous post Local Server For Testing Environment With XAMPP On Windows for more details). And you can use XAMPP for Mac as well. But the point is you need a local server environment to designing, developing and testing your WordPress blog before your go live.
So if you already have a live self hosted WordPress blog, it is very recommended that you use the current server data and files to test new plugins, new themes or whatever. So to use the current server data, you need to download the whole database and files to your local server, which i would make the step by steps instruction to make exact mirror of your live WordPress blog into local server installation.
Here is the step by steps guide to bring your WordPress blog to local server for testing environment, i’m assuming that you use CPanel as most hosting server using this:
Download database file
- Login to your server CPanel and go to Databases > PhpMyAdmin
- It will have another tab open PhpMyAdmin, select your WordPress database
- Choose Export tab and leave all the default choices
- Check the “Save as file” check box and press Go button
- It will take a while to download your database into single sql file
Download WordPress files
- Still in server CPanel, choose Files > File Manager, choose your wordpress installation folder and GO.
- The file manager will open in another tab.
- Usually your WordPress files is under public_html folder, but if you install your blog under subdirectory (example /blog), then it will under blog directory.
- Compress public_html or root of your WordPress files to gzipped compression.
- Download the compressed file via FTP client.
Extract the WordPress files
- Now we are working in your local computer
- Move the downloaded compressed file into your webserver default directory, usually it is under htdocs.
- Create the subdirectory under htdocs, called it any name you want, but in this example i use “blog”.
- Extract the compressed file to blog directory
Import database file
- Open PhpMyAdmin, it is usually http://localhost/phpmyadmin, but if you have it different then you should know where you installed it.
- Create a new database, i called it blog
- Choose blog database, and go to import page
- Select the downloaded databse file and import it
- After it finish, go to wp_options table and find “site_url” and “home” in options name
- Change it to http://localhost/yoursubdirectory, in this example it would be http://localhost/blog
- Open the blog folder and open wp-config.php
- Change database name, database username, and database password. In this example i’m using:
database name: blog
database username: root
database password: toor
Okay now you can login to your wordpress admin (wp-admin) and use same username and password as in your server. Now set the permalink to use the default permalink, as you don’t need it pretty permalink in your localhost. And then you can delete your .htaccess, because sometimes it wouldn’t work in XAMPP default installation. Now it is recommended to deactivate some plugins that you don’t need, such as wp super cache, hypercache, db backup manager, akismet (as no one will spam your localhost), wp stat, other stats plugin, and other plugins as you feel you don’t need it.
Now you have a complete mirror of your WordPress blog in your local server. You can play with it as you like, and test any plugins before your go live. Test and tweak your themes before you applied. Do as you want to do in your local testing environment. If it break, revert back to old database and files.