Installing PHP for IIS on Windows Home Server

Tue, Mar 4, 2008

  |  Terry Walsh

If you’re interested in running a website from your home server, you may have considered various options, including running PHP. But running PHP with IIS can be fraught with problems – or at least was, until WGS reader, Christopher Courtney, wrote the following guide to installing PHP for IIS on Windows Home Server. Over to Christopher…

Because running IIS and Apache really isn’t feasable, one needs to be able to install PHP into IIS. If you have tried before or searched for how, you will notice many different ways, and a lot of problems with doing so. I’ve tried several times and gotten the same problem, but finally fixed it and got PHP working under IIS. Now I am going to share it.

What You Will Need

What to Do

You will need to download PHP. There are a number of issues with the installer, so we are going to be using the zipped file. Make sure the zip file is accessible from the server (it needs to be in one the shares, or on the SYS drive of the server.

You will need then need to gain remote access to your Windows Home Server box (Use a Remote Desktop Connection or Advanced Admin Console).

Install PHP

  1. Extract the files from the PHP zip and place the files in “C:\php”. Extract the PECL modules to “C:\php\ext”.PHP Directory
  2. Rename C:\php\php.ini-recommended to “C:\php\php.ini”.
  3. Open both the php.ini file you have now and uncomment cgi.force_redirect in php.ini and set it to 0PHP.ini Settings
  4. Find SMTP = localhost and make sure it is uncommented. If your mail server is somewhere else you may specify it here. Also set this line just below the above: sendmail_from = someone@yourhost.com
  5. Change session.save_path as “session.save_path=C:\php\sessions” and make the directory C:\php\sessions
  6. Set the line “extension_dir” as “extension_dir = “C:\PHP\ext”.
  7. Uncomment the following extensions:
    extension=php_mssql.dll
    extension=php_msql.dll
    extension=php_mysql.dll
    extension=php_mysqli.dll
    extension=php_java.dll
    extension=php_ldap.dll
    extension=php_iisfunc.dll
    extension=php_imap.dll
    extension=php_filepro.dll
    extension=php_gd2.dll
    extension=php_gettext.dll
    extension=php_dba.dll
    extension=php_dbase.dll
    extension=php_dbx.dll
    extension=php_mbstring.dll
    extension=php_pdf.dll
    extension=php_pgsql.dll
    extension=php_sockets.dll
    extension=php_xmlrpc.dll
    extension=php_xsl.dll
    extension=php_zip.dll
  8. This will enable you to use pretty much any database you may have installed. Additionally, it should allow you to use most functions for php that you will need.
  9. This part may not be necessary, but it was definitely for me. Go to “C:\” an right click on “Properties”. Go to the Security Tab, and click on the “Advanced Button”. Enable “Replace permission entries on all child objects with entries shown here that apply to child objects”, and click okay.PHP Security Settings
  10. Go to Control panel > System Properties > Advanced Tab > Click “Environment Variables”.
  11. Now add “C:\PHP;” to the very beginning.PHP Path
  12. Now run “regedit.exe” or Start Registry Editor (same program)
  13. Add HKEY_LOCAL_MACHINE\SOFTWARE\PHP\IniFilePath = “C:\php” to the registry.Editing the Registry
  14. Open Internet Services Manager which is in your Administrative Tools.
  15. Right Click on Web Service Extensions located on the left hand side and choose Add a new web service extension. Enter in php and click add. Browse to C:\php\php5isapi.dll. Also set extension status to allow. Click “Okay”.Adding PHP to IIS
  16. Right Click on websites and choose properties. Go to the Documents tab and add index.php as a start document. Go to the Home Directory Tab and click on Configuration. Now go to the mappings tab and click on add. Enter .php for the extension and enter “C:\php\php5isapi.dll” in the executable textbox. Make sure all verbs is checked and click ok, click ok, click ok. You are done installing it. Now you need to test it.Default Web Site Properties Add/Edit Extension Mapping
  17. Go to C:\Inetpub\wwwroot and make a new text file and name it phpinfo.php. Open it up with your text editor ant put this in it: <?php phpinfo(); ?>.
  18. Open a web Browser and go to http://SERVER/phpinfo.php
  19. If you followed all the instructions, it should work fine.

Installing Your Database

Once you have downloaded the MySQL installer, run it on the server. I would run step by step through the install, but pretty much all the defaults are optimal for what we want. It’s going to run using as little resources as possible, and a small number of concurrent connections. This is what we want, because this the enviroment we are going to be running. We’re not running a dedicated database server after all.

So, that’s how to install PHP for IIS on Windows Home Server – we’ll be featuring a number of technical guides from Christopher over the next few weeks, all of which will be stored on the forthcoming We Got Served Wiki.

More Info: WGS Wiki

 

Similar Posts:

This post was written by:

Terry Walsh - who has written 1291 posts on We Got Served.

Hi - I'm Terry and I'm the Owner of We Got Served. The site's been covering everything to do with Windows Home Server since February 2007. I live in Silverstone, UK with my wife and work in the Consumer Electronics industry.

Contact the author

This website uses IntenseDebate comments, but they are not currently loaded because either your browser doesn't support JavaScript, or they didn't load fast enough.

No Responses to “Installing PHP for IIS on Windows Home Server”

  1. Alexander K Says:

    Personally I find that any non Microsoft technology on a Microsoft platform is full blown aftermarket, like Japanese car parts on say a German car.…Don’t get me wrong – PHP is a force to be recond with on the *NIX platforms- I just think one is better of installing Ubuntu / Apache /PHP in say a virtual pc if one really needs to have it on the WHS or not at all ;-)

    Reply

  2. Christopher Courtney (Drashna) Says:

    The thing is, Windows Home Server already has a very nice website installed. And I am not alone in the idea that it would be shame to remove it, especially because of add-ins like Whiist, or to use multiple programs to get all the content that you want. PHP is very widely used, and very useful, so why not use it with IIS?
    And as for aftermarket, so installing OpenOffice, or games, or anti-virus programs, or other utilites all fall into the same category. They are not needed per se, but doesn’t mean you shouldn’t. Apache works fine on windows, and PHP works great on that, better in fact. But for some of us with Windows Home Server boxes, running apache and IIS side by side by is not a solution, but installing php on IIS is. That is why its here. That, and I believe in sharing knowledge that others want and need.

    Reply

  3. Christoph Voigt Says:

    Great Step-By-Step Guide Terry, I’m sure it will be useful for many of your readers. However, uncommenting all of the PHP-extensions is something I can’t recommend due to security reasons.

    The following extensions will probably never be used by anybody EXCEPT they know what they do and need and should not be enabled by default:

    extension=php_mssql.dll (SQL Server on WHS anybody?)
    extension=php_msql.dll (These functions allow you to access mSQL database servers.)
    extension=php_mysqli.dll (experimental! http://de2.php.net/manual/en/ref.mysqli.php)
    extension=php_filepro.dll (These functions allow read-only access to data stored in filePro databases.)
    extension=php_dba.dll (These functions build the foundation for accessing Berkeley DB style databases.)
    extension=php_dbase.dll (These functions allow you to access records stored in dBase-format (dbf) databases.)

    Reply

  4. Christopher Courtney (Drashna) Says:

    Sorry about that. Though, I cannot find anything about php_mysqli.dll be experimental at all. In fact, I have had issues connecting to MySQL databases without it. And if somebody does have SQL Server on their WHS box, php_mssql.dll would be useful, but other than that, yeah. The other entries have been removed on the wiki tutorial.

    Reply

  5. Christoph Voigt Says:

    I just found out the notice about MySQLi beeing experimental is only in the german PHP manual (see http://de2.php.net/manual/de/ref.mysqli.php).
    About MS SQL Server: there’s no reason for average joe to have a SQL server in his home environment but I agree it would be useful for somebody who has. However, I’d expect such a person to have enough IT knowledge to enable this explicit extension.

    Reply

  6. Fernando Dominguez Says:

    As an average Joe, I would appreciate a lot some advise about how to make a better use of the internal WEB Page already present inside our Home Server. The point is that they made this software available to thousands of “joeS’ and now we need to make it more and more useful for them and not only for PhDs in Networking and computing. If “average Joes” need WHS is because they haven’t been able to make use of Windows NT, WIndows 2000, Windows 2003 (the real core behind WHS), .in their homes. Thanks for your effort for average Joes, and keep things on track fro them, please

    Reply

  7. Tim Picraux Says:

    I am not familiar with PHP, but have identified one useful (to me) PHP application, and uses a sql db …
    Given my needs for a family usable photo library I have been evaluating an open source product “Gallery V2″ and like the concept. It is based on PHP, and given I have WHS (OEM version) I wouldn’t want to put it somewhere else, either.
    Gallery is described at: http://gallery.menalto.com/

    They have a link within for help installing on IIS, including PHP, MYSQL, …
    http://codex.gallery2.org/Gallery2:Installation_Requirements#IIS

    I didn’t have the benefit of this wiki, likely would have made the install a bit smoother … but still, not too many problems following the directions …
    I have a P4 1.8GHZ, with 1.3gb RAM and 1.3TB storage. So far seems to run fine – for family use I don’t plan on high volume …
    …other potentially useful PHP apps might be??? …

    Reply

  8. Xavier Caeruleus Says:

    That is a very nice gallery. And this would be a nice bonus to the best reason I can think of for PHP and MySQL

    MediaWiki, the same wiki that wikipedia uses.

    Directions for installing MediaWiki with IIS found here:
    http://learn.iis.net/page.aspx/299/php-app-title/

    And this is a case where an average user would need to enable extension=php_mysql.dl

    Reply

  9. joe Says:

    wow….my head hurts. This is a great tutorial and i’m doing my best to follow it but I’ve hit a few road blocks and just need some advice if anyone can help. I didn’t see a forum to ask questions, so, if I should be posting somewhere else, please let me know.

    #4 Find SMTP = localhost and make sure it is uncommented. If your mail server is somewhere else you may specify it here. Also set this line just below the above: sendmail_from = someone@yourhost.com

    If I’m using gmail and not running my server….would i put smtp=smtp.gmail.com.

    #11Now add “C:\PHP;” to the very beginning.PHP Path

    If I click on path and edit this is the path thats currently there C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;c:\jre1.4.2_13\bin

    Where do I placethe c:\php path? Just worried if I put it in the wrong place it would screw it up, it just didn’t look like the screen shot.

    Thanks for any help anyone can give me.

    Joe

    Reply

  10. rich Says:

    with MySql and PHP integrated into IIS, is it then possible to use phpMyAdmin? would phpMyAdmin go into “wwwroot”?

    Reply

  11. irishking Says:

    what version of mysql do i download?

    and what windows type ?

    Windows Essentials

    Windows ZIP/Setup.EXE

    Without installer

    which out of these three?

    Reply

  12. Drashna Says:

    You would install the Zip/setup.exe for mysql. Sorry for not stating that, will update in the wiki.

    Reply

  13. Sippervixx Says:

    Corrections needed…

    9. Go to C:\php and right click…Doing this to the C: drive may cause irrecoverable changes to file permissions and may break other things like add-ins, apps, etc.

    16. Open WebSites and right click on ‘Default Web Sites’ (like in the picture). If you apoply these changes to the entire web sites folder, it may break your built-in WHS web server…

    I never checked the screenshots, just went by the text and had to rebuild the WHS. However, the good news is the re-install was easy and to re-connect a client, just go to the Windows Home Server foler in Program Files and run ‘Discover.exe’

    Reply

  14. Jeremy Says:

    I broke my WHS built in web server as I followed the directions. is there a way to fix this without re-installing wHS?

    Reply

  15. Drashna Says:

    @Sippervixx: A number of these issues have been added to the wiki version based on feedback and me breaking my website and server.

    Reply

  16. difool Says:

    just followed the wiki and it worked!
    now I just have to learn PHP :-)

    Reply

  17. Franky Says:

    Hi,

    It looks easy but it’s not :) I followed it to the letter but at the end when trying I get a “Internet Explorer cannot display the webpage” error.

    The only thing that does not went the same as the tutirion is part 8 where I have to uncomment thos extensions. Some of there are not in the php.ini file. Also in the beginnen their is talk about both php.ini files. Wath the hell do you mean by that :d ?

    Thx alot !

    Reply

  18. Bram Says:

    Hey guys,

    I’ve followed this tutorial three times now, but i have a strange problem:

    PHPworks just fine but it seems that the PHP install blocks the connector software from connecting.

    Every time after installment of php i cannot login via the connector any more. Backups are just allright, but cannot login to the console.

    gr. bram

    Reply

  19. Mario Says:

    hi
    i did falow your guide step by step but i still geting the error (“The page cannot be found”) what am i doing wrong?

    Reply

  20. Marcellus Says:

    In regards to step 9:

    I don’t think this is a real good idea since you might change permissions in other child object that shouldn’t be changed.

    Instead, do this:

    Right click and select properties for the c:\php folder.
    In the Security tab, select Advanced.
    Remove all Permission entries that say in the “Inherited From” column.
    Check both the “Allow inheritable permissions…..” box and the “Replace permission entries on all child objects…..” box, then click OK, and OK again.

    Doing this limits permission entry changes to the PHP folder and all folders and files contained therein. By following the above instructions, this will remove all eroneous permissions generated at creation time and inherit permissions directly from the root directory.

    Reply

  21. Marcellus Says:

    EDIT to my above post…..

    Where it says:
    Remove all Permission entries that say in the “Inherited From” column.

    Should read:
    Remove all Permission entries that say “not inherited” in the “Inherited From” column.

    Sorry for any confusion here. Without thinking about it, I used greater than and less than signs since that’s how it’s displayed in the properties dialog and was cut out since it’s recognized as an html tag.

    Reply

  22. JT Says:

    I have been having some problems getting my PHP to work. I have followed the tutorial, ran through the basic troubleshooting and I have no idea what more I can do.
    When I load the page, the PHP isnt being read. SO I get a blank page.
    I want to know what I should do if the extensions mentioned are not in the list of extensions that are already in my php.ini file.
    I need to know if theres anything else that I can do that might help me fix this problem.
    I would appreciate a response to this, or you can email me your suggestions at: JT081970 @ gmail . com
    thanks for your help and time.
    -JT

    Reply

  23. Keith Says:

    No offense, but after getting a failed install of PHP by following this tutorial, I went hunting for answers. I found a great guide here: https://technocore.homeserver.com/wiki/index.php?title=Category:PHP_for_Windows_Home_Server. It includes some steps not mentioned here – specifically the one about setting security on the C:\PHP folder, which probably caused my original problems if I had to guess.

    Reply

  24. PJ Says:

    To put it bluntly, i screwed around for ages trying to get php setup on whs. then I stumbled onto this article (hosted elsewhere http://www.tryphp.com/how-to-install-php-for-iis-on-home-server/ ). I followed the link back here to leave a message saying, Thanks so much! :)

    I followed the step by step and it worked first time.

    The only thing that threw me a bit was the lack of some DLLs in the extensions list. I didnt know if I should add them, or how the list was populated… was it automatically updated as new packages installed etc? Anyway, It works, and i’m happy :)

    Thanks!
    PJ

    Reply

  25. Rob Says:

    @Alexander K – I’ve been running PHP on IIS for years and have never had problems.

    Reply

  26. Steven Lodge Says:

    @Rob -
    I agree with Rob.
    I’ve been running PHP and MySQL on windows web server 2003 for years.
    I’m now intersted in building a windows home server and using the same applications to host Gallery on this server.

    Reply

  27. $Me Says:

    thank you it works for me

    Reply

Trackbacks/Pingbacks

  1. How-To: Create a Website with Whiist and ASP.NET | We Got Served - 21. Apr, 2008

    [...] but how many of of you have wondered what else could you do with it? We’ve shown you how to install PHP for IIS, but that isn’t something that is built into IIS.  Through much trial and error via email [...]

  2. Try PHP » Blog Archive » How to install PHP for IIS on Home Server - 15. Aug, 2008

    [...] [via wegotserved] [...]

  3. Installing PHP for IIS on Windows Home Server « Staging AnoopGeorge.com - 12. Mar, 2009

    [...] more [...]

  4. Installing PHP for IIS on Windows Home Server « AnoopGeorge.com - 12. Mar, 2009

    [...] more [...]

Leave a Reply