How To Install PHP on Windows (IIS)
I needed to install YUI's PHP loader on my server recently so that I could deliver combo'd CSS/JS files over SSL. Somehow the Google and YAHOO CDNs don't support all the features I needed (SSL, YUI 3 / YUI 2 support, combo'd delivery). This process was a pain in my ass, so I hope I can make it easier for the next person!
There are lots of tutorials on how to do this, but for some reason I had a problem with just about every one of them. Please don't take my word as gospel, but maybe this info will help you:
PHP Install Steps
- Download PHP 5.
Even this part was confusing. I've packaged up my PHP installation (download) including my adjustments to get everything working. - Extract the contents of the PHP zip file to C:\PHP
- Add C:\PHP to your system PATH.
Open the System dialog (from Control Panel), click the "Advanced" tab and click "Environment Variables." Edit your PATH variable to include C:\PHP (you will probably need to append ";" to the end of the existing path before adding C:\PHP). - In the C:\PHP folder, rename php.ini-recommended to php.ini (not needed if you downloaded my installation from step 1)
- For Windows 64-bit only:
You must run IIS in 32-bit mode for PHP to work. Open a command prompt and run this command to enable IIS in 32-bit mode:
cscript %SYSTEMDRIVE%\inetpub\adminscripts\adsutil.vbs SET W3SVC/AppPools/Enable32bitAppOnWin64 1Now navigate to C:\WINDOWS\Microsoft.NET\Framework\v2.xxx. Run "aspnet_regiis.exe -i" (it's imperative that you are in the "Framework" folder and not the "Framework64" folder).Open IIS, expand Web Service Extensions, and make sure that ASP.NET 32-bit is set to "Allowed." - Open IIS, expand Web Service Extensions, and click the link to add a new extension. Name it something like "PHP ISAPI Extension" and select the C:\PHP\php5isapi.dll file. Make sure the extension is set to "Allowed."
- Open IIS, right-click "Web Sites", and then "Properties." Under the "Home Directory" tab click "Configuration." Add a new extension mapping, setting ".php" as the extension and C:\PHP\php5isapi.dll as the executable path. You can limit verbs to "GET,POST,HEAD" if you like.
- Install the PHP registry settings. I've packaged them up for conveinence (just extract and then double-click the .reg file).
- I had to copy my php.ini file to the C:\WINDOWS directory and run "iisreset" to get everything working.
- Create a file in one your sites named "phpinfo.php" and include the text below. After doing so, navigate to that page in a browser and you should be able to see a dumping of PHP information.
<?phpphpinfo();?>
YUI PHP Loader Install Steps
I also had a few problems with the out-of-the-box PHP Loader for YUI (download my finished YUI folder):
- In combo.php, I had to change getenv("QUERY_STRING") to $_SERVER("QUERY_STRING").
- In combo.php you'll need to change PATH_TO_LIB to your server's web url.
- In all of the files in /lib/meta, you'll need to change the urls to match your server.
- I had to adjust my PHP install to ensure that the cURL was working. If you didn't download my PHP installation above, you need to ensure that php_curl.dll is in your C:\PHP\ext folder. Then edit your php.ini file: set the extension_dir value to C:\PHP\ext\ and uncomment the line extension=php_curl.dll
After all of that mess, the combo loader worked perfectly for me!
You can test your installation by visting your server's url at /phploader/test/test-loader.php. Use the checkboxes to select a few items and then visit the CSS/JS urls that it creates to see if the YUI loader works for you.
UPDATE: Looks like the PHP Loader isn't quite working correctly for me. Lots of extra data is being pulled; when I compare a sample request on YAHOO!'s loader to mine, there is a huge discrepency in the number of KBs written. After spending over a day on this I had to move on to a different solution.