IIS tips and tricks
Running multiple versions of the .NET framework in IIS
When you install a new .NET framework in your IIS server some applications can stop working showing you the following error:
Server Application Unavailable
In the event viewer you will find this:
It is not possible to run two different versions of ASP.NET in the same IIS process. Please use the IIS Administration Tool to reconfigure your server to run the application in a separate process.
This happens because different .NET frameworks can run in the same server, but cannot share the same application pool, so, to solve this:
- In IIS Manager (Control Panel > Administrative Tools) create a new Application Pool (using default values is ok).
- In Default Web Site right click your application folder and select Properties.
- In the Virtual Directory page, in Application Settings click the Create button and write a name for your application (you can use the recommended name). In the Application Pool list select the application pool you just created.
- In the ASP.NET page select the framework version you want to use.
- Press the Ok button and voila!, go and enjoy!
The IUSR account
IIS will by default install a couple accounts in your system: IUSR and IWAM. IUSR is in charge of all anonymous requests. So, to give anonymous access to a folder, file, asp, etc. you must ensure the IUSR account has read (and execute for asp’s) permissions.
Firefox cannot load “localhost”, while IE can
I installed IIS on a reformatted computer and when trying to access the home page using Firefox I was asked for my username and password. After many tries and permission checkings (check this first!) I used IE and it worked… I googled a little bit and found this solution:
- Open up Firefox and type in about:config as the url
- In the Filter type ntlm
- Double click “network.automatic-ntlm-auth.trusted-uris” and type localhost and hit enter
After I did that everything worked ok.
Installing PHP in few steps
- Download PHP (no installer version)
- Unzip it to C:Inetpubphp
- Add read and execute permissions on this folder to the IUSR account
- Open php.ini-recommended (located inside C:Inetpubphp)
- Set display_errors to On
- Set extension_dir = “C:Inetpubphpext”. It must point to your extensions folder
- Remove the # for any module you might need (ie: mysql)
- Save this file as C:Windowsphp.ini
- Add C:Inetpubphp and C:Inetpubphpext folders to the your PATH (Control Panel > System > Advanced > Environment Variables > System Variables). If you skip this stepÂ some DLL’s (like MySQL) will not be loaded!
- Open the IIS Administrator
- Right click on your website and select Properties. Select Home Directory. Click on Configuration. Click on Add. Click on Browse and select “php5isapi.dll” located in your php folder. Write .php in the extension box and click Ok. Click Ok, and click ok again.
To completely restart the IIS services it is not enough to press the restart button from the IIS Admin Console. You have to restart all the related services.
You can accomplish this by typing the following commands in a Windows Console:
net stop iisadmin net start w3svc