Setup your local WordPress Blog

Tools, Wordpress

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.

Comments on this entry are closed.

  • Jacob Pellegren Jun 29, 2006 Link

    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!

  • Venu Jun 30, 2006 Link

    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 🙂

  • Ivan Minic Jun 30, 2006 Link

    Very well written tutorial! Excelent!

  • Yvonne Aug 7, 2006 Link

    MAMP for Mac is better, me thinks.

    http://www.mamp.info

    Nice tute =)

  • rnrHKhoQ Oct 5, 2006 Link

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

  • Nick Jan 13, 2008 Link

    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?

  • venukb Jan 13, 2008 Link

    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

  • Nick Jan 13, 2008 Link

    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.

  • venukb Jan 13, 2008 Link

    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
    https://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.

  • Nick Jan 14, 2008 Link

    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

  • lumargin Mar 15, 2008 Link

    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?

  • Andrian Sep 15, 2008 Link

    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

  • josh Oct 21, 2008 Link

    Thanks. I need to run more than one blog. How should I go for the 2nd blog? I tried the same sequence after creating a new database called wp2, then copied a new set of wp files in this folder, and then typed http://localhost/wp2 in the browser window. Gives me an error.
    Thanks for your help

  • Ashish Mishra May 6, 2009 Link

    Hi Dear Friend,

    Thanks a Million for this amzaing article…

    Regards
    Ashish

  • Hermann May 29, 2009 Link

    Hi there, I’ve popped in here because of the infamous and sudden 404 error on my local WP copy.

    Once everything had been installed correctly, my local copy was running smoothly.

    Then I’ve decided to move my WP folder out of the xampp/htdocs folder, into windows-classic mydocuments folder…

    Troubles started.

    I had to configure a virtualserver into httpd.conf, but although doing so, I could only get it work on the home page: as soon as a sublink in my domain was entered, I got a 404 error.

    Now following nick’s sample I have changed the permalink structure to:

    /index.php/%postname%/

    and got it to work, but I think it’s quite ugly! Of course it doesn’t matter too much given the fact this permalink structure is being applied only to my offline WP copy, to “official” WP copy is running with a clean “%postname%” structure.

    I was wondering from an academical point of view, were did the problem lied….