IIS Configuration Guide

From CTRNet Wiki
Jump to: navigation, search

This guide will walk you through the configurations required to run ATiM on IIS. It is assumed that you have already installed it and configured it to work with PHP. Note that this guide is based upon IIS 6. There might be discrapencies between it and IIS 7+. Also note that the steps detailed above are known to work. There might be unnecessary steps.

Contents

Download iismod_rewrite

ATiM uses mod_rewrite. It comes built-in in apache, but not in IIS! As of this writing, this module can be found

  • On our server [1]
  • On some friendly guy server [2]

Extraction

You have to extract mod_rewrite.dll somewhere. If you installed IIS at the default location, you can extract it to C:\Inetput\modRewrite\

Create the rewrite rules

In the same directory, create a new file named "mod_rewrite.ini" and open it. If ATiM is installed right into webroot and not in any subfolders (ex.: webroot/atim2/), you can copy paste the following code into it. Otherwise you'll have to alter the following configuration.

Debug 1
Reload 5000
RewriteRule ^/img/(.*) /app/webroot/img/$1 [L]
RewriteRule ^/js/(.*) /app/webroot/js/$1 [L]
RewriteRule ^/css/(.*) /app/webroot/css/$1 [L]
RewriteRule ^/$ /app/webroot/index.php [L]
RewriteRule ^/administrate/(.*) /app/webroot/index.php?url=administrate/$1 [L]
RewriteRule ^/pages/(.*) /app/webroot/index.php?url=pages/$1 [L]
RewriteRule ^/app/(.*)$ APPJUMP$1 [L]
RewriteRule ^/(.*)\?(.*)$ APPJUMPwebroot/index.php?url=$1&$3 [L]
RewriteRule ^/(.*)$ /app/webroot/index.php?url=$1 [L]
RewriteRule ^APPJUMP(.*)$ /app/$1 [L]

Files permissions

Note: Security controls are available only to Administrator or users with administrative rights. So make sure you login as one. And security can only be set in an NTFS partition. If you are in a FAT partition, you can skip to the next part.

IIS will need to access mod_rewrite.ini and mod_rewrite.dll. It hereby needs to be granted permission to do so. You may want to first observe the permissions of the webroot folder (located in Inetpub) to give you an idea of what users you need to add. As of this writing, a similar visual guide is available. [3]. An easy way to find out under which user IIS is running is to use the php get_current_user function.

  1. Right click on the directory
  2. Select properties
  3. Select the security tab. If you can't see the security tab you must
    1. In an explorer window, click on the Tools at the menu bar, then click on Folder Options.
    2. Click on View tab.
    3. In the Advanced Settings section at the bottom of the list, uncheck and unselect (clear the tick) on the “Use simple file sharing (Recommended)” check box.
    4. Click OK.
  4. In the top section, there is two users you should be interested in
    1. IIS_WPG
    2. IUSR*
  5. It is important that you note the user itself and the prefix before the backslash.
  6. Close the properties windows
  7. Open the properties window for modRewrite directory.
  8. Head over to the security tab and click add.
  9. Set the location as the prefix you noted previously.
  10. In the object names section, enter the two users you noted.
  11. Click check names. If you entered the parameters properly, thew will both be underlined. Otherwise there will be some pop-up.
  12. Once the names are ok, click ok.
  13. For each of those names, click on "full control" on the lower section.
  14. Repeat steps 7 to 13 for mod_rewrite.dll and mod_rewrite.ini.

Set mod_rewrite in IIS

You must now configure IIS to use mod_rewrite.

  1. Open IIS manager
  2. Right click on your website (within the website directory) and select properties.
  3. Click on the ISAPI Filters tab
  4. Click add
  5. Enter some name. Ex.: URL Rewrite Filter
  6. Select mod_rewrite.dll as the filter executable
  7. Click ok twice to close both windows
  8. Restart IIS. Note: On some servers the IIS manager restart commands Are somehow broken and don't entirely restart IIS. The restart_iis.bat file found in the mod_rewrite zip file is known to do it properly.

Enable file writing [Optional but required for caching]

If you intend on activating structures/menus caching, you must configure IIS to allow PHP to create files.

  1. Open IIS manager
  2. Right click on your website (within the website directory)
  3. Reach the Home Directory tab
  4. Check the write option
  5. Click apply
  6. Click ok
  7. Restart IIS

See if it works

  1. Reopen the properties window of the website directory and go to ISAPI filters. Your newly added filter should be preceded by an up green arrow. If it's a down red arrow, it's not working. Most of the time files permissions are the problem.
  2. If you have the green arrow, open a browser and type in a URL related to your IIS installation.
  3. Open the directory where you put mod_rewrite.dll and see if you have the mod_rewrite.txt file.
  4. Open it.
  5. If you have two lines, one stating something like "Received URL" and the other stating "Rewritten URL", then congratulations! It works! If you have some error message, your mod_rewrite.ini file contains bogus code and needs to be rewritten. You need to restart the server each time you want to try a new configuration and remember: The stop/start command cannot be relied upon. Use the restart_iis.bat script instead.
Personal tools