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.
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
- Remote Desktop Connection or Advanced Admin Console
- PHP 5.2.5 files zipped
- PECL modules for PHP 5.2.5 - For added support, functionality, and compatibility.
- MySQL Download - optional but recommended, many php applications require sql. And MySQL has a free version.
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).
- Extract the files from the PHP zip and place the files in “C:\php”. Extract the PECL modules to “C:\php\ext”.
- Rename C:\php\php.ini-recommended to “C:\php\php.ini”.
- Open both the php.ini file you have now and uncomment cgi.force_redirect in php.ini and set it to 0
- 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 = firstname.lastname@example.org
- Change session.save_path as “session.save_path=C:\php\sessions” and make the directory C:\php\sessions
- Set the line “extension_dir” as “extension_dir = “C:\PHP\ext”.
- 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
- 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.
- 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.
- Go to Control panel > System Properties > Advanced Tab > Click “Environment Variables”.
- Now add “C:\PHP;” to the very beginning.
- Now run “regedit.exe” or Start Registry Editor (same program)
- Add HKEY_LOCAL_MACHINE\SOFTWARE\PHP\IniFilePath = “C:\php” to the registry.
- Open Internet Services Manager which is in your Administrative Tools.
- 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”
- 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.
- 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(); ?>.
- Open a web Browser and go to http://SERVER/phpinfo.php
- 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.
Microsoft, WHS, Windows Home Server, PHP, IIS, Web Server, Installation, How To, Guide, Walkthrough, Tips, Tricks, Knowledgebase, Tips and Tricks