When developing with PHP, for WordPress or other uses, it is important to test your code prior to uploading them to your site.  This is to make sure that everything functions like you want it. Viewing .php files require slightly more setup than simply opening them your browser like static web pages. This is because PHP runs server-side, meaning that the code is processed by the server, and the web page hits the browser fully generated.

Setting up a local server with WordPress can be made easier with pre-packaged options.  Of course, you always have the option to install and set up Apache, PHP, MySQL, and WordPress individually, but this process can be made easier with pre-packaged solutions.  Depending on your operating system–you can choose XAMPP (mulit-platform) or WAMP (Windows only).  I will be demonstrating both here, though for my daily development needs, I use WAMP.

Whichever package you end up choosing, the first step will be to download and install the packages as you would for any other program.  Please note that neither of them come prepackaged with WordPress, so you may want to download WordPress at this time, just to have it on hand.  Start the localserver, if you have not already done so. On XAMPP’s control panel, you need to start the Apache and MySQL services separately.

XAMPP Control Panel

Installing WordPress on a local server is nearly identical to installing it on a normal hosting server. It does require a MySQL database to run, so the next step will be creating this database.

The following screen shots are from WAMP though the same method can be applied to XAMPP.

Navigate to http://localhost/phpmyadmin. This should display a page like this:

Screenshot of phpmyadmin welcome screen

Clicking the “Database” option will lead you to this screen:

Screenshot of phpmyadmin create database page

Enter in whatever you plan on calling your WordPress database and hit “Create”. There isn’t any need to manually add any tables–those will be created upon installing WordPress.

You should also create a user to manage the database.  You can create a user by clicking on your WordPress database on the bar on the left, and then selecting “Privileges” in the menu across the top.

Phpmyadmin main page Screenshot with WordPress database highlighted

phpmyadmin Screenshot of WordPress database main page with privileges hilighted

Choose to “Add a new user”

phpmyadmin add new user button

On WAMP: Locate the download location of your WordPress files and unzip the files into WAMP’s www folder. (If you used the default install Windows is C:WAMPwww)

On XAMPP: Locate the download location of your WordPress files and unzip the files into XAMPP’s htdocs folder. (If you used the default install on Windows is C:xampphtdocs)

Find the file named wp-config-sample.php.  This should be found in your main WordPress folder. Open the file with a text editor– I use Notepad ++, but you can use whatever you like. Edit the following lines to reflect your database setup.  You shouldn’t need to alter the localhost setting–in theory.

A screenshot of wp-config-sample.php lines 17 to 29

Save the file as wp-config.php

Once this is in place, you should be able to install your WordPress normally. Navigate to http://localhost/wordpress/wp-admin/install.php and follow the on-screen instructions for the 5 minute WordPress installation.

Congratulations!  You should now have a localhost WordPress setup for you to test your WordPress plugins and themes.  If you have any questions, please let me know in the comment section below.  I welcome your feedback!