Setting up WordPress on a local Web server

Note: This guide should work equally well for WordPress 2.0.2 and above. For a guide on upgrading this 2.0.1 install, see Upgrading (our local install of) WordPress.

In our previous tutorials, we setup an Apache-based Web server, on a Windows XP home computer. The Web server is also running PHP and MySQL, as well as ColdFusion MX. This time, we'll be installing WordPress onto our local Web server. This installation will require us to work with both PHP and MySQL, and we'll be able to setup any number of WordPresses after we have completed this one.

Downloading WordPress

First, we'll need to download the latest version of WordPress, from As of this writing, that version is 2.0.1.

Once we've downloaded WordPress, we can extract the zip file into the same folder that we downloaded the zip to (in my case, c:\home\downloads\). Now move the wordpress folder from within this folder, to c:\home\. Once you've done this, the path to the license.txt should be something like c:\home\wordpress\.

Configuring localhost

Now that we've extracted the WordPress installation, we'll want to point a quick URL to this folder. We'll use http://wordpress.localhost/ to do this.

First, open the httpd.conf file using your shortcut, or the Start menu. At the bottom of this file, we'll need to add a new VirtualDirectory for wordpress.localhost. My addition looked like the below.

ServerName wordpress.localhost
DocumentRoot c:\home\wordpress
ErrorLog logs/wordpress-error.log
TransferLog logs/wordpress-access.log

Now, save this file and close it.

Next, open the hosts file, using a shortcut, or by scrolling to it. At the end of this file, add a new entry for the VirtualDirectory we just created. wordpress.localhost

Again, save this file and close it.

Finally, we'll need to restart Apache in order for our change to take effect, using the Services control panel.

Configuring MySQL: Creating the WordPress user and database

Now that WordPress is extracted, and we've setup http://wordpress.localhost/, we'll need to create a MySQL user account and database for WordPress to use. First, start up MySQL Administrator. Type in the root password, and click on User Administration. Press the New User button. Fill in the MySQL User and Password fields, and Apply changes. The user name I used was simply wordpress. Right click on this new user name, select Add Host From Which This User Can Connect, and type localhost in the window. Press OK.

Next, click on the Catalogs item, right click on an empty area in the Schemata area, and select Create New Schema. For the Schema name, I once again simply used wordpress.

Now that we've setup a database, we'll need to associate the wordpress item with it. Click on User Administration, then on wordpress, then on localhost beneath it. Next, click on the wordpress Schemata, and move all available privileges to assigned privileges. Select Apply Changes.

Note that we could have done this in a different order if we would have liked. Namely, we could have first setup our database/catalog, and then created our user.

Now that we've created our user, we'll have to do the work-around to get the password correct. Open the Command Prompt and type the following.

mysql -u root -p

Press enter, and type in the root password. Finally, we'll change the password for wordpress for all hosts.

UPDATE mysql.user SET Password = OLD_PASSWORD('your_password') WHERE User = 'wordpress';

Remember to substitute your_password with the password you would like to use. Once you've done this, log on to phpMyAdmin to verify that the password works as expected, and you can view the wordpress database. http://phpmyadmin.localhost/.

Setting up the WordPress configuration file

Now that we've created our MySQL user and database, we'll need to setup a configuration file for WordPress. Navigate to c:\home\wordpress\, and copy the wp-config-sample.php file. Now, rename our copy to wp-config.php. Finally, open this file in Notepad.

If you look at the top of this file, you'll notice four fields that start with "define". We'll need to add the relevant information into the first three fields. First, verify that the DB_NAME is what you just setup in MySQL Administrator. The default is wordpress, which is what I setup above. Change DB_USER appropriately – in my case, wordpress is again used. Finally, change DB_PASSWORD to your password. Yes, we are entering this information into a text file. However, visitors won't be able to see this information, so long as you keep this file a PHP file.

Save the wp-config.php file, and close it, once you have made these changes.

Installing WordPress

That we've created the wp-config.php file, we can visit http://wordpress.localhost/ to get a link to actually install WordPress. Otherwise, you can visit the installation file directly, at http://wordpress.localhost/wp-admin/install.php.

On the installation page, click the First Step link. Now, enter a Weblog title, and your email address. I used wordpress and my email, accordingly. Click to the next step.

Now, it will give you a username, admin, and a password, which should be random. Make a note of both of these, and do what it suggests – log in. http://wordpress.localhost/wp-login.php

Now that you've logged in, there's two things to do. The first is to setup your profile and change you password (the second bullet), and the second thing is to write a test post.

Once you do so, you'll have two posts on your site, one from the installation, and one from the user you just setup. To view you post, visit http://wordpress.localhost/.

Congratulations – you've successfully setup WordPress. Now, you can remove the installation's post and comment, and begin working on creating a unique style.

At this point, I should also point out the boon of creating a local WordPress. Backing up your WordPress is one of the best things that you can do. If you setup a WordPress, using the same username/password as the one you actually use on the Web, with the same database information (if you know that), you can backup your WordPress, and be able to work with your actual content when you work on style revisions. Killing two birds with one stone is always enjoyable.

In a later guide, we'll walk through backing up your WordPress installation, and when a new version of Wordpress is released, we'll walk through upgrading our installation. Until then, have fun playing around with WordPress.

View all of the steps to creating a local Web server, for development.