<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Blog &#124; BenHollis.net &#187; IIS7</title>
	<atom:link href="http://benhollis.net/blog/tags/iis7/feed/" rel="self" type="application/rss+xml" />
	<link>http://benhollis.net/blog</link>
	<description>News about BenHollis.net and articles about Ben&#039;s interests</description>
	<lastBuildDate>Fri, 04 Jun 2010 05:39:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Setting up IIS7 (with bonus PHP instructions!)</title>
		<link>http://benhollis.net/blog/2008/03/09/setting-up-iis7-with-bonus-php-instructions/</link>
		<comments>http://benhollis.net/blog/2008/03/09/setting-up-iis7-with-bonus-php-instructions/#comments</comments>
		<pubDate>Mon, 10 Mar 2008 05:16:00 +0000</pubDate>
		<dc:creator>Ben Hollis</dc:creator>
				<category><![CDATA[Random]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[Xbox 360]]></category>
		<category><![CDATA[IIS7]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Windows Vista]]></category>

		<guid isPermaLink="false">http://brh.numbera.com/blog/index.php/2008/03/09/setting-up-iis7-with-bonus-php-instructions/</guid>
		<description><![CDATA[Every time I try to set up IIS7 on a Windows Vista machine I run into the same series of problems. You&#8217;d think I&#8217;d have learned by now, but I usually just struggle through the cryptic error messages and get it working one way or another, then forget about it until the next time I [...]]]></description>
			<content:encoded><![CDATA[<p>Every time I try to set up IIS7 on a Windows Vista machine I run into the same series of problems. You&#8217;d think I&#8217;d have learned by now, but I usually just struggle through the cryptic error messages and get it working one way or another, then forget about it until the next time I need IIS7 on a machine that doesn&#8217;t have it. Finally I&#8217;d had enough and so I decided to write myself a little guide here so I won&#8217;t waste as much time next time. These instructions are basically the same as <a href="http://hajuria.blogspot.com/2007/11/installing-iis7-php5-25-on-windows.html">these</a>, but with additional detail and screenshots. </p>
<p><span id="more-158"></span></p>
<p>The first step is to actually install IIS7. Unlike in Windows XP, IIS isn&#8217;t installed by default. That&#8217;s great, but it can be kind of hard to find it when I need it.</p>
<p class="blogimage"><a href='http://brh.numbera.com/blog/wp-content/uploads/2008/03/windows-features-control-panel.png' title='Add or remove Windows features'><img src='http://brh.numbera.com/blog/wp-content/uploads/2008/03/windows-features-control-panel-thumb.png' alt='Add or remove Windows features' /></a></p>
<p>You&#8217;ve got to click this link that says &#8220;Turn Windows features on or off&#8221; which will (after some time) bring up a big tree of features you can check or uncheck.</p>
<p class="blogimage"><a href='http://brh.numbera.com/blog/wp-content/uploads/2008/03/windows-features-iis.png' title='Windows Features - IIS'><img src='http://brh.numbera.com/blog/wp-content/uploads/2008/03/windows-features-iis-thumb.png' alt='Windows Features - IIS' /></a></p>
<p>You&#8217;re going to want most of &#8220;World Wide Web Services&#8221;. If you are also interested in installing PHP, make sure everything I&#8217;ve circled in red is checked. I just added everything to be safe. What&#8217;s important is that you have the ISAPI and CGI stuff. I also checked the IIS6 compatibility bit so that installers for things like PHP might have a better chance at automatically configuring things (fat chance).</p>
<p>At this point you can start dropping things into <tt>C:\inetpub\wwwroot</tt> and everything should be peachy. I don&#8217;t put my sites there since I have them checked out into various folders in my Documents folder. So I need to create some virtual directories to point to my sites. This probably won&#8217;t work off the bat &#8211; you&#8217;ll get 403 errors that complain about wrong permissions or something. You need to make sure that the &#8220;IIS_IUSRS&#8221; and &#8220;Authenticated Users&#8221; users have read access to the directory. I&#8217;m not sure why &#8220;Authenticated Users&#8221; needs to be there but it made it work. Make it look like this:</p>
<p class="blogimage"><a href='http://brh.numbera.com/blog/wp-content/uploads/2008/03/permissions.png' title='Setting permissions for IIS7'><img src='http://brh.numbera.com/blog/wp-content/uploads/2008/03/permissions-thumb.png' alt='Setting permissions for IIS7' /></a></p>
<p>At this point your folder should be accessible from the virtual directory, and any ASP.NET stuff will probably work. If you&#8217;re not interested in installing PHP, you can stop here.</p>
<h3>Installing PHP on IIS7</h3>
<p>PHP doesn&#8217;t really play well with IIS. However, we can get it going good enough for local testing of your PHP code. First, go install PHP5 from <a href="http://php.net/">php.net</a>. Choose to install it as an ISAPI extension for IIS, but don&#8217;t worry too much, since it won&#8217;t work anyway. Now open up IIS Manager. If you&#8217;ve followed the steps above (specifically, selecting the correct &#8220;Windows features&#8221;), your IIS manager should look something like this:</p>
<p class="blogimage"><a href='http://brh.numbera.com/blog/wp-content/uploads/2008/03/what-to-look-for-iis.png' title='IIS Manager with ISAPI and CGI'><img src='http://brh.numbera.com/blog/wp-content/uploads/2008/03/what-to-look-for-iis-thumb.png' alt='IIS Manager with ISAPI and CGI' /></a></p>
<p>What&#8217;s important is that you have the parts outlined in red &#8211; the &#8220;CGI&#8221; icon, the &#8220;ISAPI Filters&#8221; icon, and the &#8220;ISAPI and CGI Restrictions&#8221; icon. Those mean the right bits are installed. </p>
<p>Now double-click the &#8220;Handler Mappings&#8221; icon, and click &#8220;Add Script Map&#8230;&#8221; Fill out the form like this:</p>
<p class="blogimage"><a href='http://brh.numbera.com/blog/wp-content/uploads/2008/03/edit-script-map.png' title='Add PHP script map'><img src='http://brh.numbera.com/blog/wp-content/uploads/2008/03/edit-script-map-thumb.png' alt='Add PHP script map' /></a></p>
<p>Make sure it&#8217;s pointing to your real copy of php5isapi.dll. At this point your Handler Mappings screen should look like this:</p>
<p class="blogimage"><a href='http://brh.numbera.com/blog/wp-content/uploads/2008/03/handler-mappings.png' title='IIS handler mappings'><img src='http://brh.numbera.com/blog/wp-content/uploads/2008/03/handler-mappings-thumb.png' alt='IIS handler mappings' /></a></p>
<p>Also make sure that your &#8220;ISAPI Filters&#8221; screen looks like this:</p>
<p class="blogimage"><a href='http://brh.numbera.com/blog/wp-content/uploads/2008/03/isapi-filters.png' title='ISAPI filters'><img src='http://brh.numbera.com/blog/wp-content/uploads/2008/03/isapi-filters-thumb.png' alt='ISAPI filters' /></a></p>
<p>If not, add PHP like this:</p>
<p class="blogimage"><a href='http://brh.numbera.com/blog/wp-content/uploads/2008/03/edit-isapi-filter.png' title='Edit ISAPI filters'><img src='http://brh.numbera.com/blog/wp-content/uploads/2008/03/edit-isapi-filter-thumb.png' alt='Edit ISAPI filters' /></a></p>
<p>If you&#8217;re running the 64-bit version of Vista like I am, there&#8217;s one last thing to do in IIS Manager. Since the PHP ISAPI extension is a 32-bit app, you&#8217;ll need to set your app pool to run in 32-bit mode. I&#8217;ve already <a href="http://brh.numbera.com/blog/index.php/2007/03/27/using-myodbc-with-aspnet-in-iis7-on-vista-x64/">written one blog post on this</a> (to get MySQL working with ASP.NET), and the instructions are the same. Basically open up the app pool&#8217;s advanced settings dialog and flip it to 32-bit mode:</p>
<p class="blogimage"><img src="http://brh.numbera.com/blog/wp-content/uploads/2007/03/iis32bit.png" alt="IIS 32-bit app pool" /></p>
<p>If you forget this you&#8217;re likely to get errors that look like &#8220;Calling LoadLibraryEx on ISAPI filter &#8220;C:\Program Files (x86)\PHP\php5isapi.dll&#8221; failed&#8221;.</p>
<p>If you load up your PHP files you&#8217;ll probably get something like &#8220;failed opening required&#8221; blah blah. This is because the PHPRC environment variable isn&#8217;t set correctly by the PHP installer. We&#8217;ll have to do it ourselves. Go to the Control Panel and search for &#8220;env&#8221;:</p>
<p class="blogimage"><a href='http://brh.numbera.com/blog/wp-content/uploads/2008/03/control-panel-env.png' title='Environment variable link'><img src='http://brh.numbera.com/blog/wp-content/uploads/2008/03/control-panel-env-thumb.png' alt='Environment variable link' /></a></p>
<p>Now add a System environment variable like this (point it at the directory PHP is installed):</p>
<p class="blogimage"><img src='http://brh.numbera.com/blog/wp-content/uploads/2008/03/edit-system-variable-thumb.png' alt='PHPRC env variable' /></p>
<p>At this point you must reboot your computer to get the environment variable to take effect. Annoying but true. At this point PHP should work, more or less.</p>
<p>I still have some problems with PHP the way I&#8217;ve described configuring it. The most obvious is that the IIS worker crashes every once in a while:</p>
<p class="blogimage"><img src='http://brh.numbera.com/blog/wp-content/uploads/2008/03/iis-crash.png' alt='IIS worker crash because of PHP' /></p>
<p>I suspect reconfiguring PHP to be run as a CGI handler instead of an ISAPI module would help here, but it hasn&#8217;t been annoying enough to make me go change it. Another avenue to investigate is the new <a href="http://learn.iis.net/page.aspx/272/installing-php-on-windows-vista-with-fastcgi/">FastCGI support that&#8217;s available for IIS7</a>.</p>
<p>The other problem I&#8217;ve had is that I have a handful of image files in one of my sites that are managed by <a href="http://subversion.tigris.org">Subversion</a> and get locked and unlocked pretty frequently. After I&#8217;ve committed an image, it loses its permissions and can&#8217;t be served from IIS anymore, and I need to go reset the permissions. That&#8217;s pretty annoying, and I&#8217;m not sure if it&#8217;s a bug in Subversion or in one of my SVN clients (<a href="http://tortoisesvn.tigris.org">TortoiseSVN</a> and <a href="http://subclipse.tigris.org">Subclipse</a>).</p>
<p>At least this setup works enough to try things out quickly. I hope it helps anyone else who&#8217;s struggling with one of these setups.</p>
<p><strong>Update:</strong> You might want to try out the new <a href="http://www.microsoft.com/web/channel/products/WebPlatformInstaller.aspx">Microsoft Web Platform Installer</a> which purports to set up PHP along with anything else you might need.</p>
 <div class="postAdsense">
<script type="text/javascript"><!--
google_ad_client = "pub-0806135767465122";
/* BRH Blog Post */
google_ad_slot = "2708897180";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
]]></content:encoded>
			<wfw:commentRss>http://benhollis.net/blog/2008/03/09/setting-up-iis7-with-bonus-php-instructions/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
