How to install PHP on Windows Home Server / IIS 6.0

While there are several tutorials on the Internet that explain how to install PHP on Windows Home Server (WHS) / IIS 6.0, I noticed that many of these tutorials are not precise and some even miss important steps in the process that could benefit the average user. Those who know their way around IIS and have basic knowledge of editing code would not have any trouble following the instructions that are currently out there in “www World.” However, a good portion of WHS users, especially HP WHS users, are not advanced users and need a step-by-step guide that will allow them to install PHP without jumping through hoops and over hurdles. I’m not trying to reinvent the wheel or waste the *online-ink* by writing yet another tutorial on this topic, but I feel it is necessary to cover every step in the process so the installation is flawless. I am going to cover the steps that I believe are the most efficient so we can knock this out.

It is extremely important that each step in the installation process is followed exactly as outlined below. If you read everything carefully you will have PHP running in no time. Although the installation process seems lengthy, it will not take too much time once you get the ball rolling. I went a bit overboard when writing this tutorial, but I rather be thorough so everyone has a shot at a successful installation opposed to cutting corners in my tutorial and leaving people hanging.

What You Will Need

PHP Zip Package – The current version at the time of this writing is PHP 5.2.9-1, but you could use PHP 5.2.6.

PECL Zip Package – There will not be a PECL version released for 5.2.9-1, but the PECL 5.2.6 package works with PHP 5.2.9-1 if you decide to use it.

Installation

1. Download the PHP and PECL Zip files to your desktop or any other location on your server.

  • Zip File Name: php-5.2.6-Win32.zip or php-5.2.9-1Win32.zip
  • Zip File Name: pecl-5.2.6-Win32.zip

2. Create a new directory in your “C:” drive and name it “PHP.” The path should now look like this: “C:\PHP.”

3. Extract the files from the PHP Zip file and place the files in the “C:\PHP” directory.

4. Extract the files from the PECL Zip file and place the files in the “C:\PHP\ext” directory.

5. Locate the file “php.ini-recommended” in the “C:\PHP” directory and rename this file to “php.ini.”

6. Open the “php.ini” file with a text editor and follow steps 7 – 12 for editing the file.

7. Locate the line “;cgi.force_redirect = 1” and change the value from “1” to “0” (without the quotes) and then uncomment the line. “Uncomment” simply means removing the preceding semicolon ( ; ) from the line. The line should look like this:

  • cgi.force_redirect = 0

8. Locate the line “;upload_tmp_dir =” and set it to look like this:

  • upload_tmp_dir = "C:\PHP\upload"

Notice the quotes around “C:\PHP\upload” only. You also need to uncomment this line.

9. Locate the line “;session.save_path = "N;/path"” and set it to look like this:

  • session.save_path = "C:\PHP\sessions"

Notice the quotes around ” C:\PHP\sessions” only. You also need to uncomment this line.

  • Note: If your version does not have a line named “;session.save_path = "N;/path"” look for “;session.save_path =” – not “session.save_path = "N;MODE;/path".”

10. Locate the line “extension_dir = "./"” and set it to look like this:

  • extension_dir = "C:\PHP\ext"

Notice the quotes around “C:\PHP\ext” only. This line should already be uncommented, but if not go ahead and uncomment.

11. Locate the line “;error_log = filename” and set it to look like this:

  • error_log = "C:\PHP\errors.log"

Notice the quotes around ” C:\PHP\errors.log” only. You also need to uncomment this line.

12. Locate the following extensions and uncomment each line as seen below. Feel free to uncomment additional extensions if necessary.

extension=php_fdf.dll
extension=php_gd2.dll
extension=php_gettext.dll
extension=php_mbstring.dll
extension=php_mysql.dll
extension=php_mysqli.dll
extension=php_sockets.dll
extension=php_xmlrpc.dll
extension=php_zip.dll

Save the “php.ini” file and close.

13. Create two new directories in the PHP directory – “upload” and “sessions.”

  • i.e. C:\PHP\upload
  • i.e. C:\PHP\sessions

14. Navigate to your “C:” drive,” right-click the “PHP” directory, and select “Properties” from the context menu. Click the “Security” tab and then click the “Advanced” button. Now click the “Add…” button and add “IUSR_HPSERVER” or perhaps “IUSR_SERVER” (without the quotes) in the field. Click “OK,” tick the “Full Control” checkbox, click “OK,” tick the checkbox that reads “Replace permission on all child objects with entries shown here that apply to child objects,” click “OK,” and then click “Yes” when the security dialog appears. Finally click “OK” to close.

  • Note: The server name is not the name “you” set for your server. It is the name that shipped with your server. If you are running an HP Windows Home Server then “HPSERVER” is more than likely the original name of your server. However, if your server shipped with a different name use that name instead. i.e. “IUSR_ORIGINALSERVERNAME.” If the server throws an object error after you enter the server name this indicates the server name you chose is incorrect and you just need to enter the correct name. When you get everything squared away and enter the correct server name click “OK” so we can exit out and move on to the next step.

15. At the same time, press the “Windows Icon” and the “Pause/Break” keys on your keyboard to access “System Properties.” You could also accomplish this by right-clicking on “My Computer” and selecting “Properties” from the context menu. Once in “System Properties,” click the “Advanced” tab, and then click the “Environment Variables” button.

16. In the section that reads “System variables,” scroll down and locate the “Path” variable, select it so it is highlighted, and then click the “Edit” button. In the field labeled “Variable value,” add “;C:\PHP” to the end without the quotes. Click “OK” on all the dialog boxes to exit.

  • Note: If you choose to add this to the beginning you can drop the semicolon, however, if you add this in the middle or at the end of all the variables you must include the semicolon as a separator. It should look similar to this:
  • C:\WINDOWS\system32;C:\WINDOWS;C:\PHP;C:\MySQL\bin.

17. Now we have to create a new registry entry. Create a new Notepad file on your desktop and copy all the text below – everything – starting from “Windows… and ending with …PHP”.

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\PHP]
"IniFilePath"="C:\\PHP"

18. Paste the text into Notepad and save the file using the name “inifilepath.reg.”

  • Note: Make sure you select “All Files” next to “Save as type,” and for “Encoding” choose “ANSI.” You should now see a registry file on your desktop with the name “inifilepath.”

19. Double-click the file to open and click “Yes” to add this to the registry when you are prompted with a dialog box. If added successfully you can delete the file from your desktop since we have no further use for it.

  • Note: What this did was add a “PHP” key to the registry with the string “inifilepath” set to “C:\PHP” – minus the quotes. Below is what the new entry should look like in your registry. Feel free to type “regedit” in the “Run” dialog box, navigate to this location, and double check our work.
  • i.e. HKEY_LOCAL_MACHINE\SOFTWARE\PHP
  • i.e. String Value Name: IniFilePath
  • i.e. String Value Data: C:\PHP

20. Now open Internet Information Services (IIS) Manager. Start –> All Programs –> Administrative Tools –> Internet Information Services (IIS) Manager.

21. Right-click the “Web Service Extensions” icon and select “Add a new Web service extension…” from the context menu. Type “php” (without the quotes) in the “Extension name” field and then click “Add.” Click “Browse,” browse to “C:\PHP\php5isapi.dll,” and set the extension status to “Allow.” Click “OK.”

  • Note: Make sure you select the correct DLL (php5isapi.dll) because they have similar file names.

22. Right-click the “Websites” icon and select “Properties” from the context menu. Click the “Documents” tab, click “Add…,” and then type “index.php” (without the quotes) in the “Default content page” field. Click “OK.”

23. Click the “Home Directory” tab and click the “Configuration…” button. While in the “Mapping” dialog box, click “Add…,” type “C:\PHP\php5isapi.dll” (without the quotes) in the “Executable” field, type “.php” (without the quotes, but make sure you include the period before “php” i.e. .php) in the “Extension” field, and make sure the “All verbs” radio button is enabled. Click, “OK” on all three dialog boxes to exit.

24. Important: When you receive the “Inheritance Overrides” dialog box make sure you do not select “Home,” “Remote,” or “Upnp.” This could break your website’s functionality, thus you would need to repair the application mappings manually. Please read what it says before you start selecting directories. Click “OK” all the way through to exit.

Create PHP Test File

1. Open Notepad and copy & paste the following PHP code below.

1
<?php phpinfo(); ?>

2. Save the file as “info.php” and place it in the root of your website.

  • i.e. C:\Inetpub\wwwroot

3. Important: You must set permissions on the “info.php” file for it to be accessible from the Internet. Right-click the “info.php” file you just created, select “Properties” from the context menu, click the “Security” tab, and then click the “Advanced” button. Now click the “Add…” button and add “IUSR_HPSERVER” or perhaps “IUSR_SERVER” (without the quotes) in the field. Remember to use your original server name. i.e. “IUSR_ORIGINALSERVERNAME.”

Test Installation

1. Fire up your Web browser and type “http://localhost/info.php” in your browser’s address bar. You should now see the PHP configuration page. If you see this page everything installed correctly and you are ready to run PHP applications on your server.

2. If you are unable to access the “info.php” configuration page using the http://localhost/info.php URL do not panic or have a meltdown. Try typing “http://mediaserver/info.php” in the address bar and see if that works for you.

3. Still no dice? If you already own a domain name (www.yoursite.com) that points to your Windows Home Server go ahead and type “http://www.yoursite.com/info.php” in the address bar and test it. This should work.

4. If all three suggestions above do not work for you make sure you set the permissions for this file. In addition, make sure you placed the “info.php” file in the directory you are attempting to access.

Final Note

If you followed every step in this tutorial you should now have PHP running on Windows Home Server. If by small chance you are unable to access your test page I recommend going back through the steps just to make sure you did not miss anything. The steps outlined in this tutorial work, hands down, so double check everything before you throw in the towel.

Comment Section