Howto Setup PHP (Apache, Mysql) on Windows
First Grab the latest copies of the following:
Apache (MSI with OpenSSL): http://httpd.apache.org/download.cgi
PHP Windows Binary (Zip Package): http://www.php.net/downloads.php
MySql Community Engine (MSI): http://dev.mysql.com/downloads/mysql/5.1.html#win32
MySql Tools (MSI): http://dev.mysql.com/downloads/gui-tools/5.0.html
Once you’ve downloaded the latest files follow these steps below:
- Install Apache
- Network Domain: it doesn’t matter
- Server Name: it doesn’t matter
- Unzip PHP into c:\php
- Install MySql
- Install MySql Tools
- Create a folder c:\websites (or call it what you want)
- Go to My Computer -> Right Click Properties -> Advanced -> Environment Variables
- Select Path -> Click Edit
- Add a ;c:\php on the end
- Restart your computer!
- Browse to the Apache Folder (Should be in Program Files\Apache Software Foundation\Apache
- Go into conf and open httpd.conf
- Change the following and Save
- ServerRoot (Should be set to your Apache folder – nothing should be changed here)
- Listen (In the event you want your Apache WebServer to not run at localhost:80 – you can specify a specific ip/port here
- In the LoadModule section you might want to enable rewriter_module (not necessary!)
- DocumentRoot "C:\websites"
- <Directory "C:\websites"> <– This is about ~15lines below the document root (REQUIRED CHANGE)
- Under the DirectoryIndex save yourself some time and add index.php after index.html with a space separating them
- All Done making configuration changes to Apache
- Copy the index.html file in htdocs to c:\websites
- Click on the Apache Server Monitor in your TaskBar and restart Apache (if you have any problems check the logs folder in the Apache directory)
- Open your Web Browser and Browse to http://localhost – You should see ‘It Works’
- If this failed to work – check the settings you’ve changed (typo’s will break things) also check the error logs in the apache\logs folder (Post any problems you can’t resolve in the comments)
- Now that you have Apache working – lets get PHP working so you can start coding with php/mysql
- Rename php.ini-distribution to php.ini
- Open php.ini
- Change the following and Save
- max_execution_time (Suggested for development to increase to 60)
- max_input_time (Suggested for development to increase to 120)
- memory_limit (Suggested for development to increase to 256M – great for any type of video conversion)
- error_reporting = E_ALL & ~E_NOTICE (Un-comment this and ensure other error_reporting lines are commented
- display_errors = On
- log_errors = On
- session.save_path = "c:\tmp"
- post_max_size = 16M (Suggested for development)
- doc_root = (You can leave this blank)
- extension_dir = "c:\php\ext" (Required)
- upload_max_filesize = 16M (Suggested for development)
- Un-comment the following extensions:
- extension=php_curl.dll
- extension=php_gd2.dll
- extension=php_mbstring.dll
- extension=php_mcrypt.dll
- extension=php_mssql.dll
- extension=php_mysql.dll
- extension=php_openssl.dll
- If you have access to an SMTP server configure SMTP
- Re-open the httpd.conf for apache and add the following lines after the end of the LoadModule section
- LoadModule php5_module "C:/php/php5apache2_2.dll"
- AddType application/x-httpd-php .php
- PHPIniDir "C:/php"
- Restart Apache
- Create a file in c:\websites called test.php
- Put <?php phpinfo(); ?> in the file and save
- Access http://localhost/test.php
- You should see a dump of all the information – All the extensions you’ve loaded above should have a section within the information displayed (If you can’t find mysql on the page for example then the .dll did not load properly – Verify your Environment Path variable (restart if you change it) and try again)
- Don’t forget to look at your log files if you’re having problems – and if php says it can’t load a module that exists in a specific path then it’s likely an Environment Path issue.
- Happy Coding!

May 26th, 2009 at 11:46 am
This is a great tutorial if you want to set up an AMP (apache mysql php) stack from the individual components.
If you are looking for something quick and dirty or a complete novice then xampp would be more ideal. (http://www.apachefriends.org/en/xampp.html)
May 26th, 2009 at 12:30 pm
Hi Kevin,
I’d have to agree with you the the xampp is great for a novice. I think this breaks it down enough so a novice can set it up themselves. While I see the purpose of xampp quick setups I think its always useful to try and understand how things are setup and working. It can really help if you need to make changes/additions/upgrades down the road.
Thanks for the link!
-Dave
May 26th, 2009 at 12:32 pm
Agreed. There are a number of them out there which can actually make it harder to figure out which one to use. (http://en.wikipedia.org/wiki/Comparison_of_WAMPs). The positives are it could work with minimal effort. The negatives can be that versioning is an issue. You’re stuck with whatever versions of the components the latest package release used.
The primary reason we don’t use a packaged solution is because we always want to try and clone the exact environment our production server is running on. No sense testing your application on a completely different platform then what is will be running on. Of course smaller websites this isn’t an issue but full scale applications can become very picky about the smallest difference.