Setup your local Wordpress Blog

by venukb on June 26, 2006

One of the most frequent things you do after setting up a blog is posting content (Obvious you might say).

I initially started posting content using the WYSIWYG editor built into WordPress. However the editor was very slow especially when you try to edit an already existing post and this used to discourage me from making any changes in the post.

In this post I am going to run down the steps needed to setup a local version of your WordPress blog. Other than posting content easily, it helps you in trying out with new templates/themes and also play with the different WordPress plugins before you put it live on your web site.

Prerequisites

To Run WordPress, you need to have following things !

  • PHP version 4.2 or greater
  • MySQL version 3.23.23 or greater
  • Wordpress recommends Apache or Litespeed as the most robust and featureful server for running WordPress, but any server that supports PHP and MySQL will do.

Many people know from their own experience that it’s not easy to install an Apache web server and it gets harder if you want to add MySQL, PHP and Perl.

XAMPP is an easy to install Apache distribution containing MySQL, PHP and Perl.

At the moment there are four XAMPP distributions:

I am going to continue with the XAMPP for Windows scenario, however for other platforms there shouldn’t be much changes.

Installation of XAMPP

Note: If you have already installed Apache and MySQL as service, stop the service before configuring XAMPP.

You can either install the XAMMP full version or the XAMPP Lite version. I would suggest the EXE format of the full version. XAMPP

One thing to note while installing is the path of installation: I happened to suffix an additional XAMPP in the installation path and I ended with

C:\Program Files\Xampp\Xampp

The installation should finish with the configuration of Apache and MySQL. You will also be prompted whether to install these applications as a Windows Service.

To check if XAMPP is properly installed, type the following URL in the browser

http://localhost/xampp/

You should be prompted with a welcome screen confirming the status of the installation.

Install/Copy WordPress into XAMPP

  • If you want to make a fresh install of WordPress, i.e. if you don’t want to import any data from your website, proceed with the Famous 5-Minute Installation of WordPress. The only step to change is w.r.t. database configuration in wp-config.php.

// ** MySQL settings ** //

define(’DB_NAME’, ‘WP’); // The name of the database

define(’DB_USER’, ‘root’); // Your MySQL username

define(’DB_PASSWORD’, ”); // …and password ?

define(’DB_HOST’, ‘localhost’); // 99% chance you won’t need to change this value

Copy the Wordpress folder under

[XAMPP_INSTALL_DIR]/htdocs

  • If you want a exact replica of your website blog, use an FTP tool to download all the contents including images and plugins. Modify the wp-config.php as shown above. file Copy the blog directory under [XAMPP_INSTALL_DIR]/htdocs

The file structure should look similar to this:

Wordpress in XAMPP

Create Database

Wordpress stores all the posts/comments in the MySQL database. Create a database named “WP“using the following steps:

  1. Click on phpMyAdmin under the Tools Section.
  2. Create the “WP” database as shown below

Create Local Database

Exporting data from your blog (WebSite)

Export your WordPress blog data using WordPress Database Backup Plugin. The plugin also has the option of exporting data from the tables used by some WordPress plugins. The plugin exports the data into an SQL file. Additionally you have to use the FTP tool to download images and the plugins used in your blog.

Now you cannot import this SQL file into the local “WP” database as such. This is because most of the content/links will still be referring to your website.

Make a copy of the backup file. Open the SQL File in a text editor such as Textpad. Use the Find/Replace option to replace your website URL with your XAMPP URL as shown below:

Find/Replace

Importing Modified SQL file into your local database

After modifying the SQL file, follow these steps to import the file into your local database.

  1. Select the”WP” database
  2. Select the “import” option
  3. Select the modified SQL file in the “File To Import Section”.
  4. Click on Import.

Import SQL file

Now assuming you have named the local blog as “wordpress”, your local blog should be up and running at

http://localhost/wordpress

In case you have imported blog data from your web site , the users and administrator settings will also be imported and the same can be used to login to your local WordPress administration page.

Popularity: 12% [?]

{ 15 comments… read them below or add one }

1 Jacob Pellegren 06.29.06 at 11:41 pm

I’m using Mac OS X, and I have a local copy of Wordpress running, I didn’t go through much trouble to install, the only trick was keeping it outside of the “Documents” folder under the Webserver folder, allowing me to use mod_rewrite for nice permas. I believe I downloaded the MYSQL/PHP 5 package from Entropy ( http://entropy.ch ). Thanks for the great article!

2 Venu 06.30.06 at 1:45 am

The entropy link doesn’t seem to be working .. Checked your site, looks very professional..

Incidentally, few hours ago I was checking about OS X and steps of how to install it on a PC ..Any tips on that ?

By the way great mockup of the MacBook :)

3 Ivan Minic 06.30.06 at 3:57 am

Very well written tutorial! Excelent!

4 Yvonne 08.07.06 at 10:47 am

MAMP for Mac is better, me thinks.

http://www.mamp.info

Nice tute =)

5 Wordpress - Plugins/Themes at Online Diary 08.31.06 at 10:36 am

[...] There are so many themes for wordpress and it makes it hard to decide on one theme. I have currently stuck to the K2 theme, and its working like a charm. Even then I am always on the lookout for much better looking themes and I am always buzy testing different themes on my local wordpress setup:) [...]

6 rnrHKhoQ 10.05.06 at 3:18 am

Hello nice page? really i like it! thx will be bookmark

7 Wordpress 2.1 RC1 - Online Diary 01.20.07 at 9:12 pm

[...] I setup the 2.1 release on my local Wordpress setup. Here are some snapshots of the new features ! [...]

8 June 2007 Roundup - Online Diary 07.05.07 at 11:41 am

[...] Setup you local wordpress blogStep by Step instruction to help you setup a blog on your local machine [...]

9 Nick 01.13.08 at 12:17 am

nice tutorial. i got here looking for a solution to this. so far i’ve gotten everything imported from online and running locally on the pc.
admin area works fine.. i can see the posts and the comments.
One problem: i can’t click on any posts without gettting a 404 / object not found. says that ‘referring URL’ may not be valid. its set to http://localhost/wordpress, just like yours.
i tried editing the mySQL database to replace all the instances of the path on my server (/home/myusername/public_html/mysitename/wp-content) with (http://localhost/wordpress/wp-content).
still not getting anywhere. 404 error. all admin area works fine.
everything done in your tut has been done as well.
any ideas?

10 venukb 01.13.08 at 12:22 am

Nick, assuming that you have replaced your weblog URL with http://localhost/wordpress, you have to finally do one more thing:

Go to options page and select permalinks. Choose the permalinks option that you had set in your blog. Even if its set properly, do “update permalink structure”. Open the site again and you should be all set

11 Nick 01.13.08 at 2:25 am

thanks for your prompt reply.
i did try to update the permalinks without succcess.
also want to confirm that i did make the URL to http://localhost/wordpress.
i need to mention that i did make some chages to the database that are noted above in my comment.
i’ll try with the original mySQL backup and them update permalinks again.
will those path’s (that i mentioned above) affect the operation of this?
thanks again.

12 venukb 01.13.08 at 10:34 pm

Nick, not sure what the problem is, but please check if these things are in order

1.wordpress folder should be in the htdocs folder of xampp
2.check that apache and mysql service are running
3. I checked again the text that you replaced, I guess its wrong.

In my case, I replaced my web url
http://www.venukb.com/blog
with
http://localhost/wordpress

I am not sure how you ended with /home/myusername/public_html/mysitename/wp-content

I guess wp-content shouldn’t be there at the end.
Let me know how it goes.

13 Nick 01.14.08 at 6:41 am

again, thanks for your reply.
it’s working now. :)
first though, i changed that path as a final effort.. and now its working with the change, so i assume it doesn’t affect it either way.

you actually mentioned my solution was in your first comment… and i’m glad to say that i did that before i found your post.
what i had neglected to see was right in front of me!
since i use the ‘custom’ field for the permalinks, when i updated them it was missing this (/index.php) before my custom choice.
hence, the field to customize my permalinks is’ /index.php/%postname%/’, rather than /%postname%

yeah, sometimes i’m a dork ;)
wanted to thank you for your time and suggestions, and post my solution in case someone else runs across this. now i want to try to install this on a portable/pen drive.
i’ll be visiting your blog often. :)
-Nick

14 lumargin 03.15.08 at 8:08 pm

Hi thanks for the very helpful post.

I managed to get a local copy of my blog on my PC. Everything seems to be working very well except that for some strange reason themes in my local themes folder do not appear to show on the themes tab of my local dashboard.

I initially thought it was a caching issue with my browser but having cleared my cache several times and also check every setting I understand but it still doesn’t show up on my local dashboard.

Would you happen to know why?

15 Andrian 09.15.08 at 10:54 pm

Hey, very nice tutorial, almost makes me wish i downloaded Xamp instead of Mamp…
My question is such:
any similar tutorials for MAMP? all is done and installed, now the simple task of importing the wordpress stuff into MAMP (pardon my newbieness)
Thanks in advance

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>