Install TomatoCMS on IIS 7 with FastCGI and URL Rewrite module

From TomatoCMS Documentation

Jump to: navigation, search

It's very nice that TomatoCMS can be installed on IIS 7 with FastCGI and URL Rewrite module installed. Follow steps provided by this article to see how easy it is.

Contents

Install IIS 7 with FastCGI

From your Windows Explorer, goto Start > Control Panel. Click on Programs

File: control_panel_programs.png

Next, click on Turn Windows features on or off

File:turn_windows_features.png

Select Internet Information Services and make sure CGI is checked under World Wide Web Services > Application Development Features. Press OK button to install IIS with CGI.

File: iis_cgi.png

Add PHP file handler

This section is to set PHP file handler for IIS. In another word, what you are going to do is that allows PHP file to run in IIS.

  • Goto Start and enter InetMgr.exe
  • Click on Handler Mappings


In new dialog, you can see the list of available handler mappings in IIS. Click on Add Module Mapping on the right side:


At Edit Module Mapping dialog:

  • Enter *.php in Request path textbox
  • Select FastCgiModule from the list of modules
  • Browse and select the php-cgi.exe from PHP installed directory.

(If you have not installed PHP on your system, follow this guide)
Press OK button and click on Yes button if you see the confirm message box.

File:iis_edit_module_mapping.png

Set IniFilePath in Registry

By default, Windows will find the php.ini in windows directory, C:\Windows, not in the PHP installed directory. To fix this, you have to set IniFilePath in Windows Registry by following steps:

  • From Start > Run, enter regedit.exe
  • In Registry Editor, open HKEY_LOCAL_MACHINE\SOFTWARE\PHP
  • Right click on PHP, select New > String Value

File:php_registry.png

Rename the name to IniFilePath and set its value as PHP installed directory. In this case, it is C:\php_5.2.13_nts

File:php_registry_ini_file_path.png

After this step, you can run PHP file in IIS via FastCGI module.

Install URL Rewrite module

  • Download URL Rewrite module from IIS official website
  • Click on download file and follow the install wizard.

Install TomatoCMS

  • Download latest TomatoCMS from its official website.
  • Unzip it into a directory, C:\tomatocms, for example.
  • Go to Start and enter InetMgr.exe
  • Click on Sites on the left side and click on Add Web Site on the right side:

In Add Web Site dialog, add the website which will be used to run TomatoCMS:

  • Enter tomatocms in Site name textbox
  • In Physical path text box, point to the TomatoCMS directory. In this case, it is C:\tomatocms
  • In Port text box, enter the port which TomatoCMS run on. Make sure that port is available.

Press OK button.

File:iis_add_site.png

Next, create a file named Web.config in TomatoCMS directory and put the following content to this file:

<configuration>
 <system.webServer>
   <rewrite>
     <rules>
       <rule name="Main Rule" stopProcessing="true">
         <match url=".*" />
          <conditions logicalGrouping="MatchAll">
           <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
           <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
          </conditions>
          <action type="Rewrite" url="index.php" />
       </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

This file will be processed by IIS and it use URL Rewrite module to point all requests to index.php.
Now in IIS Manager, select tomatocms site and click on URL Rewrite icon, you will see the rewrite rules which we have just been added:

Finally, point your web browser to http://localhost:9000/index.php and you will be redirected to Install Wizard at the first time of using TomatoCMS.
Follow Install Wizard to install TomatoCMS.
If you have any problems after following this guide, please leave it in comments. Thanks.

Personal tools