header
 
     
 
pixel
pixel pixel

Installing Apache, PHP and MySQL on Windows

Here are the steps I went through to install Apache, PHP and MySQL on my Windows XP Pro computer. Whether this works for all versions of windows, I can't guarantee. I've made a point of referring directly to the files you need to download - it's more specific than most tutorials which just tell you to 'download Apache'. Note - this article was written on 7 Oct 2004 and updated on 29 July 2006 so current release versions may be different.

Installing Apache Server

You want to download the MSI Installer Package (eg - apache_2.2.3-win32-x86-no_ssl.msi). This can be found in the binaries/win32 directory. Select a download mirror directly from: http://www.apache.org/dyn/closer.cgi/httpd/binaries/win32/ Once you run the downloaded setup file, click Next through the initial steps until you get to Server Information, where you enter the following info:
Network Domain: localhost
Server Name: localhost
Administrator's Email Address: your own email
Check "Run as a service for All Users"
Click Next. Under Setup Type, select Complete. Once finished, open a browser and type the URL http://localhost/ (or just click the link) to ensure the server is properly installed.

Installing PHP

Download PHP from http://www.php.net/downloads.php. I downloaded the PHP 5.1.4 installer package (packaged as Windows installer to install and configure PHP). Run the installer - it's an executable file. For "Please select the type of installation you require", select Standard. Under Mail Configuration, enter 'localhost' for the SMTP server. For 'from' address, leave the default 'me@localhost.com'. Mail isn't important if you're setting this up for local testing as you'll be the only person using your local server. For Server Type, click Apache. You will receive a message about having to manually configure Apache. We'll do this after PHP has finished installing. Once PHP has finished installation, select Start > Program File > Apache HTTP Server > Configure Apache Server > Edit the Apache httpd.conf Configuration File. Go to the end of the text file and if you don't see the following code, cut and paste it in:
ScriptAlias /php/ "c:/php/"

AddType application/x-httpd-php .php

Action application/x-httpd-php "/php/php-cgi.exe"
To configure your default index page, look for the line DirectoryIndex index.html. Change it to the following line: DirectoryIndex index.php index.html When you've finished updating the Apache Config File, restart Apache so it reads the new configuration: Start > Program File > Apache HTTP Server > Control Apache Server > Restart To test whether Apache is configured correctly with PHP, open up a text editor (eg - Notepad) and copy and paste the following code:
<?PHP phpinfo(); ?>
Save it as phpinfo.php (the filename isn't important, the main thing is you use the extension .php) and save it in the directory C:\Program Files\Apache Group\Apache\htdocs. This is the location of your local website http://localhost/. Just a warning, watch your text editor doesn't add a .txt extension to your file.

Installing MySQL

Download MySQL from http://dev.mysql.com/downloads/mysql/4.0.html. Go down to the Windows Downloads section and download Windows (x86). Click Next through the various steps, selecting Typical for Setup Type. Once installation is complete, you need to set up the root account, the admin who controls the system. Click on Start > Run and type cmd to open the command prompt. Type the following commands:
cd c:mysql
cd bin
mysqladmin -u root password YourPassword

Installing PHPMyAdmin

This last step is optional but I find PHPMyAdmin, a web based database editor, indispensable for creating and editing my local databases. Download it from http://www.phpmyadmin.net/home_page/. I downloaded the latest stable version 2.8.2 (ZIP compressed). Extract all the files from the PHPMyAdmin download and save them in a subdirectory of htdocs. Eg - htdocs/phpMyAdmin/. Then go in there and open the file config.inc. There are a few variables you need to configure in here to help PHPMyAdmin work. Look for the following variables and set them to the values I've given:
$cfg['PmaAbsoluteUri'] = 'http://localhost/phpMyAdmin/';
$cfg['Servers'][$i]['controluser']   = 'root';
$cfg['Servers'][$i]['password']      = 'rootpass';
Then point your browser to http://localhost/phpMyAdmin/ to start creating and editing your databases!

Unhelpful Helpful Rating 3.6 (score out of 5, no. of ratings: 52)
Comments
Comment by Ivan on 2005-10-13
I managed to login to PHPMYADMIN after doing the whole password thing,much appreciated.

Comment by Dario on 2005-02-01
Thanks a lot !!! Was exactly what i was looking for !

Comment by ty on 2005-02-23
this is by far the best tutorial i've found for a beginner like myself. trying to setup a small php/mysql intranet for my business so that employees can update inventory and sales without me having to input it from a hardcopy. THANKS, this was awesome.

Comment by erik on 2005-02-27
This was concise and great. Thank you!

Comment by Andy on 2005-03-14
This is an excellent tutorial. Clear and simple and in non-geek language. There's something about the official documentation that just doesn't quite read right. This page doesn't fall into that trap.

Comment by Charbel on 2005-05-06
I had tried tutorials from various websites but they weren't very helpful. PHP tutorials are excellent. Thanks!

Comment by sharif on 2005-05-16
I need to know the configuring step of PHP,MySQL and PHP

Comment by Dan on 2005-05-22
This tutorial was great! However, if you want to use phpmyadmin, you may have problems with the updated password encryption used in mySQL (41 bytes vs. 16 bytes). To get around this, you can change the passwords in mySQL into the old format. First, change the current password to something different (assuming you want to keep the original password) by using: SET PASSWORD FOR 'some_user'@'some_host' = PASSWORD('newpass'); Then, you can change it back to the original passwod and put it in the old mySQL format with this command: SET PASSWORD FOR 'some_user'@'some_host' = OLD_PASSWORD('originalpass');

Comment by Oliver Quirke on 2005-05-24
This is just what I was looking for, nothing else worked. Thanks so much!!!

Comment by hamed on 2005-06-07
thanks a lot!That's the exact onei needed.

Comment by trev on 2005-06-10
It was helpful, but when I typed in that stuff into the command prompt it said "mysqladmin: connect to server at 'localhost' failed error: 'Can't connect to MySQL server on 'localhost' (10061)' Check that mysqld is running on localhost and that the port is 3306. You can check this by doing 'telnet localhost 3306'"

Comment by Tim on 2005-07-05
To Trev: You need to start mysqld service before you setup the admin account. To do that, you need to execute mysqld.exe located under "C:/mysql/bin/". Hope that help!

Comment by Rafa Minu on 2005-08-02
Very Helpful

Comment by Premal Balan on 2005-08-03
How do i change the content of my localhost (intranet)main page

Comment by theresa on 2005-08-30
Did anyone get the #1045 - Access denied for user:'root@localhost'(Using password:NO) resolved? I am frustrated and unable to connect using phpmyadmin.

Comment by ale on 2005-09-01
i have got the same thign i dont know what i have done wrong #1045 - Access denied for user 'root'@'localhost' (using password: NO)

Comment by Ale on 2005-09-23
i have edited the variables but i dont know what i have done wrong i get this: phpMyAdmin tried to connect to the MySQL server, and the server rejected the connection. You should check the host, username and password in config.inc.php and make sure that they correspond to the information given by the administrator of the MySQL server. Error MySQL said: #1045 - Access denied for user 'root'@'localhost' (using password: NO)

Comment by john on 2005-09-25
I just had the same problem with "Access denied for user 'root'@'localhost' (using password: NO)" and I opened config.inc.php and added the root password there. I added it here: $cfg['Servers'][$i]['user'] = 'root'; // MySQL user $cfg['Servers'][$i]['password'] = '**your_password_here**'; // MySQL password (only needed // with 'config' auth_type)

Comment by john on 2005-09-25
I just had the same problem with "Access denied for user 'root'@'localhost' (using password: NO)" and I opened config.inc.php and added the root password there. I added it here: $cfg['Servers'][$i]['user'] = 'root'; // MySQL user $cfg['Servers'][$i]['password'] = '**your_password_here**'; // MySQL password (only needed // with 'config' auth_type)

Comment by john on 2005-09-25
oops, my apologies for the double post, and what i just said is listed above in the tutorial. sorry 'bout that.

Comment by Douglas on 2006-03-03
This site is awesome. Your site is really nice! I really enjoy your site! Just cool site! No any words else to say...

Comment by Alex on 2006-04-10
Is more tremendous! I yet did not meet on the Internet of a drain of games and the information about texas holdem game! Very much it was pleasant. Thanks founders for a good site

Comment by Alexander on 2006-03-03
What is the most important information I should know about Cymbalta?

Comment by Marko on 2006-03-22
Hi. Beautiful content and website design. Sorry for my english. I am from albania.

Comment by jeeva on 2006-12-26
people .....tell me how to config mysql with dreamweaver 8. when i connect , i got error Unable call myql_function.help Me. note : i yet config the php.ini for mysql (remove ;extension)

Comment by Jonathan on 2006-10-18
John my man, you are a legend. That double post was well worth it my friend :)))

Comment by Paul on 2007-09-22
Iv not gone through the procedure of instalation yet, but the reason im gonna use this site to help me is because of the the user comments, afterall, they are the ones with the experience of the system. Nice1!

Post a Comment
Name
Email
(optional)
Comment
RatingUnhelpful Helpful
Security Image* (this is just to prevent spam submissions)
Security Image