Due to a hardware fault on our old web server I had to move this homepage to a new machine.
Previously we were running on Debian Linux with the Apache web server. The server I had “spare” is a Windows 2003 Server machine. I installed the IIS 6.0 on it and configured the PHP extensions.
I had serious issues getting it up and running on the different web sites so I will show you with this manual how you can easily install PHP on IIS 6.0 and troubleshoot if you have any issues.
Read more to continue…
1. Install PHP
1.1 Download and unzip the latest version of PHP (5.2.3 at the moment) to C:\<Directory>\PHP\
* Download the latest Windows Binaries of PHP from http://www.php.net/downloads.php and unzip it somewhere on your hard drive.
* Download the “PECL 5.2.3 Win32 binaries” zip file and extract the contents of that archive into C:\<Directory>\PHP\ext. It contains required extensions for mySQL or any other PHP addon. Move php5servlet.dll and php5activescript.dll from C:\<Directory>\PHP\ext into C:\<Directory>\PHP\.
1.2 Create php.ini
In your PHP directory, you’ll find a couple of php.ini-* files. For an easy initial setup rename the php.ini-recommended to php.ini.
2. Configure PHP mainly editing php.ini
2.1 Open the php.ini and uncomment cgi.force_redirect in php.ini and set equal to 0
*** This is a very important step, don’t neglect it. ***
2.2 Install a browscap.ini file
For scripts like phpMyAdmin please download the php_browscap.ini from http://browsers.garykeith.com/downloads.asp to the extras directory under your PHP install directory (C:\<Directory>\PHP\extras\php_browscap.ini, for example), and change the browscap variable in php.ini to be the full path to the file (browscap=C:\<Directory>\PHP\extras\php_browscap.ini).
2.3 Create a session state directory and point the session.save_path php.ini variable to it. Create a session directory somewhere on the server or use the existing Windows one e.g. C:\Temp\. This directory will hold many small files with session variable information for PHP. Now change the value of the session.save_path variable in php.ini to be the full path to that directory (session.save_path=C:\Temp).
2.4 Setup the PHP extensions.
Now you have to enable some additional PHP extensions (For information on extensions, visit http://ca3.php.net/manual/en/install.windows.extensions.php)
The most important to start with is the extension=php_mysqli.dll simply remove the ; before it to enable the extension. This one is used for the mySQL database connection.
2.5 Create your PHP directory as variable PATH inside Windows
Make a rightclick onto My Computer – Press Properties – Select the Advanced tab – Click the Environmental Variables Button – Scroll down to PATH and double click same – Enter in there your PHP installation directory e.g. “C:\<Directory>\PHP\;” the final; is very important else none of your PATH info will work and your command prompt is useless 😉
Reboot your PC to enable the made changes.
2.6 Add the IniFilePath into the Registry.
Click Start – Run – fill in regedt32 – and press OK
In the Registry Editor please go the HKLM and create under Software a new Key named “PHP” inside this key you create a new Strink named “IniFilePath” with your PHP installation path as value
3. Configure IIS
Open the IIS mms. Click Start – Administrative Tools – Internet Information Services (IIS) Manager
3.1 First you have to add the Web Service Extensions.
Press the + in front of your PC Name – select the “Web Service Extensions” – press “Add a new Web Service Extension” – Give the extension a nice name e.g. “ISAPI PHP Extension” – click Add and browse to your PHP installation directory ad select the php5isapi.dll – Check the “Set extension status to Allowed” checkbox and click “OK”
3.2 Add new extension (.php)
Now you have to tell the IIS what it should do when a .php file is requested.
Right-click on “Web Sites” in the left pane, then click “Properties” in the menu that pops up – Flip to the “Home Directory” tab – Click “Configuration” – Click “Add…” – Browse to the php5isapi.dll in the “Executable” textbox – Enter “.php” in the “Extension” textbox – Select radial button “Limit to“, enter “GET,POST,HEAD“- Click “OK” all the way out
This will apply to every website.
3.3 Turn on scripting permissions for your websites
Right-click on “Web Sites“, goto Properties – Home Directory – Change the “Execute permissions” dropdown to “Scripts only“.
3.4 Restart IIS
Right-click the local computer in the left pane of IIS Manager, click on All Tasks – Restart IIS… – Enjoy
4. Test your setup
4.1 Create a new file named test.php in one of the websites e.g. C:\Inetpub\wwwroot
As content simply type in the following:
Open the newly created file with the web browser and you will see the php info page that indicates a successfull installation!