Installing Internet Information Services
You probably heard a lot of bad things about IIS, from various groups. If you were holding off using IIS because of that well now is the time to re-evaluate IIS with version 7. A lot of the problems that plaques IIS were cured way back in IIS 5. Introduced in IIS 7 was a new architecture similar to Apache with its modules. Everything in IIS 7 is a module, an extension that can be removed. Just need a basic HTTP server? No problem! Just remove or deactivate everything but the HTTP service module.
Where do you get IIS? You already have it if you are running Windows Vista Home Premium, Business, Ultimate, or Windows 7 under the same SKUs as Vista. It is also on Windows Server 2008. There are some limitations to be aware of. On Windows Vista and Windows 7 Home Premium is limited to 3 con-current request, Business/Professional, and Ultimate are limited to 10. However this limit will never come into play because this server is for development not production.
Enabling IIS we need to open Windows Features, it can be found in the Control panel in various locations under the name “Turn Windows features on or off” instead of wasting time traversing though the Control Panel open the start menu and use the search box. Typing the first few letters of “turn windo” will bring up the desired item.
Just by selecting “Internet Information Services” will add most of the required defaults, explorer around the list for anything you might think you would like to add. There is one area we do require to change, open the tree for “Application Development Features” you want to enable .NET Extensibility, and CGI. It should take but a moment to fully install.
Windows Features will close once it is done, opening your favorite browser and head to: http://localhost/ should let you know IIS is up and running.
There are two ways to configure IIS, one is to use the GUI control panel, or to modify the XML configuration file in your favorite text editor. This guide is only going to focus on using the GUI. One thing that sets IIS apart from Apache during configuration, you never need to restart IIS either making changes from the GUI or directly to the XML file. IIS will instantly recycle it processes when changes are detected. To open the IIS manager, you can go though the Control Panel to Administrative Tools, or you can simple just type “IIS” into the search box.
The first thing we should do is point our localhost site to the proper location, W:\websites\sandbox. In the far left pane, expand the server (the name of your computer) then expand sites. There should already be an entry for “Default Web Site” just delete it. Right click anywhere in the left pane, select “Add Web Site…” Enter “Sandbox” as the site name, for the physical path W:\websites\sandbox, then hit okay. You should be greeted by site level configuration options.
This can get pretty complicated with the number of options that can be configured and the number of levels available to configure at. There is global settings that affect every site, there is site level settings, and folder level settings. It can get really glandular and confusing quickly. The global settings are access by the root node on the far left pane. Site level is on each site node, expanding the site nodes reveal the folder level nodes.
One of the first global settings you want to change is “Directory Browsing”, double click its icon to change the middle pane’s view. The far right pane changed as well, it will change often based on what options or nodes you enter. Click on “Enable” in the right pane. Afterwards you can go back, either by hitting the back button (top left on the window frame), or selecting the root tree node on the left.
Adding PHP Support
Adding PHP is rather easy, while in the global settings:
- Open Handler Mappings
- On the right pane, select “Add Module Mapping…”
- Following this guide use these options:
- Request path: *.php
- Module: FastCgiModule
- Executable: W:\workspace\environment\language\php\5.3.0\php-cgi.exe
- Name: PHP 5.3 FastCGI
- Click OK
Bonus for Windows 7 users, on the main settings page open FastCGI Settings then double click on the path that leads to PHP which was just configured. You want to change “Monitor changes to file” and point it to php.ini which can be found in PHP’s directory. You will not have to restart IIS when you change PHP’s configuration anymore. For Windows Vista users I have not found a similar option.
There are a few settings that need to be changed in php.ini before we continue. You want to change: cgi.force_redirect, cgi.fix_pathinfo, and fastcgi.impersonate. All but cgi.force_redirect should be set to 1, for cgi.force_redirect you must turn it off so set it to 0.
Once done, restart IIS (if and only if you are using Windows Vista or not followed bonus instructions) then create a PHP file in the sandbox directory with: <?php phpinfo(); then access that file from the browser (http://localhost/). You should be greeted with a long page of information.