So, you got it in your head for some reason that you want to run a webserver on your Windows machine? With PHP, MySQL and all that fancy jazz? Well so did I, so I wrote this little guide after mucking about for two days, following various guides that didn't work, were incomplete, incorrect or outdated.
If you're like me, you have been using one of the preconfigured packages, like EasyPHP or XAMPP. The problem is, after using that for about a year, new versions of PHP, Apache and MySQL popped up left and right. And new versions of those handy packages don't come out overnight. Lucky for you, it's possible to download the components separately, mash it all together and have it come out a working WAMP server!
The following howto is a guide helping you on your way with setting up Apache 2.2, PHP 5 and MySQL 5.0 on a Windows XP machine. Windows 2000 or newer works as well, Windows 98/ME will NOT (stick with Apache 1.3 for those). I tried to make it as detailed as possible without including screenshots of each step in the install process and adding 'click Next on this screen'.
Get the software
First, you'll need to download everything so you can install everything in one big swoop.
- Apache 2.2 - the actual webserver. Select a mirror, then click the link for Win32 Binary (MSI Installer).
- PHP 5 - the scripting language that will be the middle man between Apache and the MySQL database. Click the link for PHP 5.2.0 zip package (the installer does not have all extensions).
- MySQL 5 - the database software. Click on 'MySQL Community Server', then click 'Select a mirror' for Windows (x86) ZIP/Setup.EXE. Skip past the form and click one of the HTTP links for a mirror close to your location.
- phpMyAdmin - a PHP 'program' that allows you to configure MySQL. You could use the commandline programs that come with MySQL, but this is way easier. Click the link for english.zip.
IMPORTANT: If you plan on doing ANY kindof IP-based filtering in Apache, or use PHP for any kind of IP-based verification (with $_SERVER['REMOTE_ADDR']), do
NOT get Apache v2.2.4!!
There is a bug in this Apache version together with PHP 5 that makes it return 0.0.0.0 instead of the correct IP. This bug also affects any kind of IP address filtering with allow/deny in httpd.conf/.htaccess. Get Apache v2.2.3 instead, it works fine and does not have this bug.
Install everything
This is dead easy. Follow my lead.
Base directory: to keep things together, you might want to create a central folder where you're going to put everything. Preferably without spaces in the name. I chose to make
C:\WAMP. If you prefer something else, substitute your path wherever it says C:\WAMP in the below steps.
Apache: Open the MSI installer file and click through the screens. Accept all the default settings until you reach the
Destination Folder, where you will change it to
C:\WAMP\Apache. If all goes well, you should be seeing a little Apache feather with a green icon in the system tray:
This is the Apache Service Monitor, which keeps an eye on the Apache process itself. It's handy for controlling Apache, but if you like, you can shut down the monitor without closing Apache itself.
Now go to
http://localhost. If you get the message below, you did everything right.
PHP: Open the PHP install zip and extract everything to
C:\WAMP\PHP. Make sure all the subdirectories are created.
MySQL: Open the MySQL install zip and double-click the Setup.exe file inside to start it. Pick the
Custom install, then change the install path to
C:\WAMP\MySQL. Let it install MySQL, skip the 'MySQL.com Sign-Up' and continue to configuring the MySQL server.
At the screen for
'default character set', select your best option.
At the screen for
'set security options', enter a root password.
Everywhere else, accept the default setting. Click Execute at the end to configure the MySQL server and you're done!
phpMyAdmin: Open the phpMyAdmin install zip and extract everything to
C:\WAMP\Apache\htdocs. Make sure all the subdirectories are created. Open the install folder and rename the long-ass
phpMyAdmin-2.x.x-english directory to
pma.
You now have four separate pieces of software installed! Next up: tieing everything together into a neat WAMP package.
Configuring
If you did everything correctly, Apache is already up and running. Now all we need to do is:
- Make Apache understand PHP
- Make PHP understand MySQL
- Make Apache understand MSQL
- Configure phpMyAdmin
Sounds easy? Well it's not really all
that easy, but that's what this guide is for.
Step 1:
Find the file
C:\WAMP\Apache\conf\httpd.conf and open it in Notepad (or whatever you prefer).
Find the section with all the
LoadModule lines, and add this one to the bottom:
LoadModule php5_module "c:/WAMP/php/php5apache2_2.dll" (note: use forward slashes)
This makes Apache load the PHP module.
Next, find the line that starts with
DirectoryIndex. Change it so it reads:
DirectoryIndex index.php index.htmlThis makes Apache understand index.php (default) files.
Now find the section with the
AddType lines. Add these two:
AddType application/x-httpd-php .php .phtml .inc .php3
AddType application/x-httpd-php-source .phpsThis makes Apache know what to do with the .php filetype.
Save the file and close it.
Next, go back to your
C:\WAMP\PHP directory and do this:
- Copy the php5ts.dll file to C:\WAMP\Apache\bin.
- Copy the php.ini-recommended file to C:\WAMP\Apache.
- Rename the file to php.ini.
Open the
php.ini file in Notepad, and change this line:
short_open_tag = Offto:
short_open_tag = OnThis allows for writing php using the short
<? .. ?> tags.
While you're at it, change this line:
;session.save_path = "/tmp"to:
session.save_path = "c:\windows\temp" (or wherever your temp folder is)
This lets PHP know where to store sessions.
Double-click the Apache icon in the system tray and click
Restart to make Apache read the new configuration. Apache is now configured to understand PHP!
To test this, create
C:\WAMP\Apache\htdocs\index.php. Then open it in Notepad and type
<?phpinfo()?>. Save the file and close it.
Go back to
http://localhost and refresh. If you see a boatload of PHP information, you did it!
Step 2:
Now the next part is adding MySQL support to PHP.
Find the file
C:\WAMP\Apache\php.ini and open it. Find the line:
extension_dir = "./"and change it to:
extension_dir = "C:\WAMP\PHP\ext"This lets Apache know where to find the MySQL extension for PHP.
Find the line:
;extension=php_mbstring.dlland change it to:
extension=php_mbstring.dllThis loads the multi-byte string extension so phpMyAdmin can handle strings correctly.
Find the line:
;extension=php_mysql.dlland change it to:
extension=php_mysql.dll
extension=php_mysqli.dllThis lets Apache load the two MySQL extensions from the PHP extension directory.
Save the file and close it. PHP is now configured to use MySQL!
Step 3:
All you need to do now is make Apache load MySQL. Easy enough!
Find the file:
C:\WAMP\MySQL\bin\libmySQL.dllCopy it to:
C:\WAMP\Apache\bin\libmySQL.dllThis makes Apache load the MySQL library.
Go back to the Apache Service monitor again (double-click the icon in the system tray) and restart Apache once more to load all the new settings and libraries.
Step 4:
Now go to
http://localhost/pma to load phpMyAdmin.
Since you haven't configured it yet, it can't access the MySQL database.
To do this:
- Go to the C:\WAMP\Apache\htdocs\pma directory.
- Rename the config.sample.inc.php file to config.inc.php.
- Open the file in Notepad and find this line:
$cfg['Servers'][$i]['auth_type'] = 'cookie';
- Change it to:
$cfg['Servers'][$i]['auth_type'] = 'config';
- Below it, add this line:
$cfg['Servers'][$i]['user'] = 'root';
- Below that, add this line:
$cfg['Servers'][$i]['password'] = 'your MySQL root password';
- Find the line with controluser and delete the part pmauser between the quotes.
- Find the line with controlpass and delete the part pmapass between the quotes.
- Save the file and close it.
If you reload
http://localhost/pma now, it should give you the main screen for phpMyAdmin.
You're done! Everything is setup now. Your WAMP server is finished!
Problems?
- If you can't get to http://localhost, Apache isn't running. Go to Start > Run > services.msc, find Apache2 in the list and start it. If it's not in the list, reinstall Apache.
- If Apache doesn't start, there is an error in the httpd.conf configuration file.
- If no one can get to your webserver, make sure your firewall and/or router allows it.
- Make sure you did everything correctly!