How to install PHP for IIS on Home Server

[via wegotserved]

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 

Leave a Reply

You must be logged in to post a comment.