Quote of the day : "Saying that Java is nice because it works on all OS's is like saying that anal sex is nice because it works on all genders." Alanna

Next quote in 1.1 hours. [suggest a quote]

Installing an Apache server on Windows

This is an old version (11 june 2006) of our tutorial. For the latest version, see here.

Introduction

This tutorial will guide you, step by step, through the installation of Apache, along with PHP and MySQL (and phpMyAdmin), under Windows.
For this tutorial, we used apache_2.0.54-win32-x86-no_ssl.msi, php-5.0.4-Win32.zip, mysql-essential-4.1.12a-win32.msi and phpMyAdmin-2.6.3-pl1.zip, on a machine running Windows XP Home SP2 (but this tut works fine with XP Pro, but there is a little problem with Win 2000 - but that won't prevent you from running the full server though).
Warning : in this tutorial, we are configuring a server that will send error and warning messages that will help you for development, but may reveal security breaches to potential hackers. So, DO NOT use this server for hosting purpose, use it only for development (unless you edit the configuration files as appropiate).
Note : this tutorial doesn't work with Apache 2.2.x (different httpd.conf file and the PHP 5 module doesn't support this version yet). Please use Apache 2.0.x for the moment.

Summary

All links

Apache

Running the installer

On the Server Information screen : On the Setup Type screen : choose Custom.

On the Custom Setup screen : choose what you want to install. You can leave all the default values if you want. We left the default component settings (full installation), and changed the install path to C:\Program Files\SERVER\Apache Group\.

Configuring Apache

First, let's remove a useless feature : open the Start menu, go to Programs → Startup and delete Monitor Apache Servers. In the taskbar, you can locate and exit the Apache Monitor if you want. That's what we did.

Then, go to your Apache folder (for us it's C:\Program Files\SERVER\Apache Group\Apache2), and open httpd.conf (located in the conf folder). Here are a few important parameters (there is more help about them in the httpd.conf file itself, so we just list them) :

Result

Congrats, you're done with Apache ! Wanna see the result ? Okay, but not too long, we still have some work to do.
In the Start menu, go to Programs → Apache HTTP Server 2.x → Control Apache Server → Start Apache in Console. Huh ? It's rather raw, isn't it ? Don't worry, that's not your site :).
Put some html pages in the folder you entered in the DocumentRoot field (see above).
Open your favorite browser (I hope it's not MSIE, btw ;)), and in the address bar, type http://127.0.0.1:8080 Here are your pages, and you could share it with anyone on the web, if they had your IP and if you let Apache go through your firewall.

PHP

Close Apache (not mandatory but let's act cleanly).

Unzipping the stuff

Extract your php file (for us it was php-5.0.4-Win32.zip) in some folder. We extracted it in C:\Program Files\SERVER\PHP.

Configuring PHP

Go to your PHP folder (for us it's C:\Program Files\SERVER\PHP). Copy php.ini-dist as php.ini, and open this php.ini.

Configuring Apache to work with PHP

Go to your Apache folder and open httpd.conf (located in the conf folder) : In your PHP directory (for us, C:\Program Files\SERVER\PHP), copy the file libmysql.dll and paste it into the bin directory of your Apache folder (ie, for us C:\Program Files\SERVER\Apache Group\Apache2\bin).

Hello World

Well, time for another break. With notepad, create a file named somename.php, containing :
<?php phpinfo(); ?>
Save it into your server directory (for us it's C:/SERVER/HTTP). Now launch Apache. With your browser go to http://127.0.0.1:8080/somename.php. You should see a page listing a lot of things about your server :)

MySQL

Close Apache (not mandatory but...)

Running the installer

On the Setup Type screen : choose Custom.

On the Custom Setup screen : choose what you want to install. You can leave all the default values if you want. We left the default component settings (full installation), and changed the install path to C:\Program Files\SERVER\MySQL\MySQL Server 4.1\.

On the MySQL.com Sign-Up screen : do whatever you want... we chose Skip Sign-Up.

On the Wizard Completed screen : leave the Configure the MySQL server now checkbox ckecked. This opens the MySQL Server Instance Configuration Wizard.

Configuring MySQL

If it isn't already opened, launch the MySQL Server Instance Configuration Wizard (In the Start menu, go to Programs → MySQL → MySQL Server 4.1 → MySQL Server Instance Config Wizard).

On the Please select a configuration type screen : choose Standard Configuration.

On the Please set the Windows options screen : uncheck Install As Windows Service.

Creating the links to launch and close MySQL

Go to the bin folder in your MySQL folder (for us it's C:\Program Files\SERVER\MySQL\MySQL Server 4.1\bin).
Create a file called MySQL_launch.bat (you can choose another name, but the extension must be .bat), right-click on it and choose Edit. In the notepad windows that appear, type
mysqld-nt.exe
and save and close the file.
Create a file called MySQL_stop.bat right-click on it and choose Edit. In the notepad windows that appear : Now, to launch the MySQL Server, all you have to do is run MySQL_launch.bat. To close the MySQL Server, run MySQL_stop.bat. You can create a link to these batch files and put these links in the start menu, but this tut isn't the place to explain this).
If you get stuck because of these files, tell us on the forum : we can send you our batch files.

Result

Sorry, nothing new to see here. Move on to the next section, there'll be much more things to see.

phpMyAdmin

Unzipping the stuff

Extract your phpMyAdmin file (for us it was phpMyAdmin-2.6.3-pl1.zip) in a folder within your server's folder. We extracted it in D:\SERVER\HTTP\Restricted\phpMyAdmin. Move all the files and folders into D:\SERVER\HTTP\Restricted\phpMyAdmin (instead of leaving them in the original D:\SERVER\HTTP\Restricted\phpMyAdmin\phpMyAdmin-2.6.3-pl1).

Configuring phpMyAdmin

Open config.inc.php (in your phpMyAdmin directory) with Wordpad (it contains caracters not compatible with notepad) : Launch Apache, and with your browser, go to http://127.0.0.1:8080/Restricted/phpMyAdmin/ (or to wherever you installed phpMyAdmin).
Click on Privileges, then edit the root account to add it a password. Then, you'll be kicked from phpMyAdmin, since you set a new password :).
Open config.inc.php again, search for $cfg['Servers'][$i]['password'] and enter your password there.
In your browser, hit F5 to reload phpMyAdmin. Click on Privileges, then Edit the Any account and remove all privilieges.
Here you are, phpMyAdmin is configured.

Just a last security feature

You probably noticed that you don't need any password to use phpMyAdmin, which means that virtually anyone can access your database through phpMyAdmin. Let's add some protection.
To sum up : for instance, we have 3 files : Now go back to your browser, to http://127.0.0.1:8080/Restricted/phpMyAdmin/ : it asks for a username and a passord, for us it's patheticcockroach and mypassword.

Finally

Congrats, you now have a brand new Apache HTTP Server with PHP and MySQL support, running phpMyAdmin as a database administration tool.
What's more they won't launch by themselves, since we remove their startup entries as they added them. And your phpMyAdmin folder (and perhaps other folders, or even your whole server) is secured by a password.
Do not forget to keep links to Apache.exe (in the bin folder of Apache), MySQL_launch.bat and MySQL_stop.bat (in the bin folder of MySQL).
Comments :
No comments yet
[Add a comment]