Quantcast
Channel: David Pratt » php
Viewing all articles
Browse latest Browse all 6

How to set up a local server on Windows

$
0
0

Have you ever wondered how to set up a local server on your windows box running with Apache, MySQL and PHP? I have. Here’s how I did it.

Mission 1: Download everything

Create a folder on your desktop and put the following downloads in it:

Mission 2: Install everything with default settings

Install the applications in the order that I have listed.

Apart from PHPMyAdmin. Park that.

Make sure that you write down with a pen and paper all of your paired usernames and passwords – you do not want to be in a situation where you end up sitting there wondering whether the default username was root, admin, guest and whether you paired it with your usual password, a special easy one or no password at all!

So, if you do cock up and can’t remember your username and password (as I did for MySQL) then you’ll need to uninstall it with a special tool as the windows one will keep you locked out on reinstall. You’ll need Revo univstaller unless you fancying hitting F3 about 50 times in regedit.

Mission 3: Configure Apache

Unfortunately everything doesn’t work and play nice straight out of the box. It needs some love (as most things tech do).

Enable Apache mod_rewrite module

This is the feature that allows sexxy clean urls (permalinks in WordPress) with none of this .php?foo=blah rubbish.

  1. Open your httpd.conf configuration file (C:Program FilesApache Software FoundationApache2.2confhttpd.conf) with Notepad.
  2. Remove the # on the #LoadModule rewrite_module modules/mod_rewrite.so line so it becomes LoadModule rewrite_module modules/mod_rewrite.so only.
  3. Save httpd.conf .

Enable AllowOverride for web directory folder (htdocs)

This allows the rule set in .htaccess file to over-ride the main one. A bit like upping the specificity in CSS if thats your thing…

  1. Open your httpd.conf configuration file (C:Program FilesApache Software FoundationApache2.2confhttpd.conf) with Notepad.
  2. Under the directory C:Program FilesApache Software FoundationApache2.2htdocs section, change the line that says “AllowOverride None” to “AllowOverride All”.
  3. Save your httpd.conf .

Mission 4: Create and run info.php

Create a file called info.php, place it in the directory C:Program FilesApache Software FoundationApache2.2htdocs and put the following code in it:

<?php
phpinfo();
phpinfo(INFO_MODULES);
?>

Now fire up your web browser and type in the url http://localhost/info.php and the page should render with a load of information. On it you should see that “rewrite module” is enabled and gd library is active, zend php is working.

Mission 5: Get PHP to talk to MySQL

Now that we know PHP works we can configure it to work with MySQL, but first we need to do a quick restart of Apache – double click on the Apache system tray icon and click restart.

Next it is time to find PHPMyAdmin.zip you have sitting in that desktop folder, unzip it to this location: C:Program FilesApache Software FoundationApache2.2htdocsphpmyadmin

Open your browser and navigate to http://localhost/phpmyadmin/

Enter all of the details that you wrote down on that piece of paper from earlier.

And do restart you local Apache web server. Now your can enable the pretty permalink structure from the WordPress dashboard and it will work nicely after that.

There you have it;  One local server that doesn’t do a lot. You could have just installed this if you want the easy option! I’ll do a follow up post about some of the things that you might want to do with your local server soon…


Viewing all articles
Browse latest Browse all 6

Trending Articles