This tutorial will explain how you can get PHP and Mysql working with IIS 7. In IIS 7 several things have changed which will make the installation a little bit complicated then it was in previous versions or as with Apache. I found out the issues myself also and searched on Google for the solutions.
First download the following software:
- PHP 5.x (the zip file is the easiest)
- Mysql 5.x
When you downloaded both software packages we can start with installing. We will divide this is a few steps:
- install PHP
- configure IIS/PHP
- install Mysql
The zip file contains all the files you need, extract them to a location such as c:\Program Files\PHP.
You will see the directory contains a few sub-directories:
Especially the “ext” directory is important because it contains all extensions to expand PHP.
The next step is configuring PHP and IIS. The configuration from PHP will be done by modifying the file “php.ini” which is a simple text file. This file can be found in the root of the PHP directory and needs to be copied to “c:\Windows”. You can make adjustments if you like, for example switch on some extensions.
For using PHP with Mysql we need to remove the “;” in front of the next line: extension=php_mysql.dll.
After this is done we need to copy some files: “php_mysql.dll” which can be found in the “ext” directory, and both “libmysql.dll” and “libeay32.dll” from the PHP directory, all of them need to be copied to “c:\windows\system32”.
When this is done we need to configure IIS. The IIS configuration is not much work but first we have to add some components because they are not installed by default. So start “add and remove programs” and choose the option “windows parts ..”. The next options need to be enabled:
When this is installed we could continue with configuring IIS. Start up the IIS Management and choose the optie “Handler mappings”. When this is opened you will get an option to add a “add script mapping”, when choosing this you will get the following screen:
Fill in all fields as above except “executable/file path” here you need to select the directory where PHP is installed. Press OK, Windows will ask you if this needs to be applied to all IIS parts, click OK this will safe you a lot of time.
The handler mappings will look like this:
To check if PHP is configures OK create a PHP file with the following content:
Safe this file to the root of your webserver and open the file via Internet Explorer. When the installation is successful you will get an overview of all the settings you did in the PHP.ini
The last step is installing Mysql you can use the default steps for this. The only option that may need to be changed is the type of server. For a developers machine you need to select “developer” if you want to use it for production then this option is not recommended.