Install Drupal on IIS

Introduction

Drupal is a free, open-source content management system (CMS) software that lets individuals or communities of users easily publish, manage, and organize a wide variety of content on a Web site.

For more information about Drupal, visit the Drupal Web site.

This article describes how to install and configure Drupal for use with the FastCGI extension on Internet Information Services 7 (IIS 7) on Windows® Web Server 2008. The instructions assume that you have set up and configured the FastCGI extension and the PHP libraries. The instructions have been tested and found to work with the following software versions:

  • PHP 5.2.9
  • MySQL 5.1.34
  • Drupal 6.14

Prerequisites

From the base default configuration file provided by PHP, modify the following lines in your Php.ini configuration:

  • Define extension_dir as c:\php\ext (for example, the location of your PHP extensions directory).
  • Uncomment extension=php_mysql.dll in the extensions list to enable MySQL support.

In order for Drupal to work correctly with IIS 7, it is necessary to install an update for the IIS FastCGI module for IIS 7.

Download and Unpack the Application

First, download the latest stable release of Drupal. For this article, Drupal version 6.14 was used (future versions are likely to be similar to install). Uncompress the Drupal files and copy them to C:\Inetpub\wwwroot\drupal (or another directory of your choosing).

Before running the Drupal installer, create the configuration file Settings.php, which Drupal uses to store key configuration settings. Assign write permissions to it with the command (from the installation directory):

1. Copy the .\sites\default\default.settings.php file to .\sites\default\settings.php.

2. Grant “write” permissions to the file.

C:\inetpub\wwwroot\Drupal\sites\default>icacls settings.php /grant BUILTIN\IIS_IUSRS:(W)

3. The installer will modify the Settings.php file with information provided during the installation process.

4. Check to ensure that the file permissions are set back to “read only” once the installation is complete. If the file permissions did not change back, you must change them manually with the command:

C:\inetpub\wwwroot\Drupal>icacls sites\default\settings.php /reset

5. Drupal uses the Sites\Default\Files directory to store temporary files and therefore must be able to write and modify files in this folder.

6. Create the folder:

C:\inetpub\wwwroot\Drupal>md sites\default\files

7. Grant “modify” permissions to the folder:

C:\inetpub\wwwroot\Drupal>icacls sites\default\files /grant BUILTIN\IIS_IUSRS:(OI)(CI)(M)

Set Up the Database

Before starting the installation procedure for Drupal, you must create a database on your server. Also create a user and grant this user “db ownership” permission to the database. This article uses the following database information:

  • Database name: drupal
  • Database user: drupal
  • Account password: drupal

Run the Installation Script

1. Open a Web browser, and go to http://localhost/drupal/. The first page of the installation script appears. Click Install Drupal in English. The Verify requirements step should proceed automatically unless you are missing requirements.

Figure 1: Choose language page

2. On the Database configuration page, type the following information:

  • Database name: drupal
  • User name: drupal
  • Password: drupal

Click Save and continue. The required database tables are created, and the configuration is saved into the Sites\Default\Settings.php file. Remove the “modify” permissions on this file.

Figure 2: Database configuration page

3. On the Configure site page, enter the required configuration information.

Figure 3: Configure site page

Enable Clean URLs

By default, Drupal uses query string parameters for all the URLs it generates for your Web site. With the URL Rewrite Module, however, you can create “clean URLs.”

IIS 6.0 does not have URL rewriting capabilities, so you can use a third-party URL rewriting product such as ISAPI Rewrite or Ionics ISAPI Rewrite Filter.

IIS 7 has URL rewriting support, which can be enabled by installing the URL Rewrite Module.

The following instructions describe how the URL Rewrite Module for IIS 7 can be used to enable clean URLs in Drupal.

1. Open the Web.config file located in C:\inetpub\wwwroot\drupal folder. If you do not have a Web.config file in the WordPress directory, create it.

2. Copy and paste the following XML code into this file.

<?xml version="1.0" encoding="UTF-8"?>
    <configuration>
        <system.webServer>
            <rewrite>
                <rules>
                    <rule name="Drupal Clean URLs" stopProcessing="true">
                        <match url="^(.*)$" />
                        <conditions>
                            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                        </conditions>
                        <action type="Rewrite" url="index.php?q={R:1}" appendQueryString="true" />
                    </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

3. Save the web.config file.

4. Open a Web browser, and go to http://localhost/Drupal/index.php?q=admin/settings/clean-urls.

Figure 4: Clean URLs page

5. Under Clean URLs, select the Enabled option button, and then click Save configuration. If you successfully changed the URL format, all the URLs are represented in a hierarchical form that does not use query string parameters (for example, http://localhost/Drupal/admin/settings/clean-urls).

 

Note: This article updates: “Drupal on IIS” by Ruslan Yakushev, published on September 19, 2008.

Links for Further Information 

Setting up FastCGI for PHP.

Using FastCGI to Host PHP Applications on IIS 7.0.

Installing PHP on Windows Vista with FastCGI.

Installing FastCGI Support On Server Core.

FastCGI forum.

PHP community forum.

Clean URLs on IIS.

Related Content

Comments

This tutorial is great for getting Drupal online. I would like to run multiple PHP based sites on my IIS installation. For instance, Drupal and phpMyAdmin. I have both of these installed and working in http://www.mydomain.com/Drupal & http://www.mydomain.com/phpMyAdmin, however I'd like to setup DNS so that I can access the sites at http://www.mydomain.com and http://myadmin.mydomain.com.

I create a new site, assign the appropriate bindings and host name settings, and when I attempt to browse the site, I see a message, "No input file specififed". After some additional testing, I see it's looking for PHP files in the docroot of "Default Web Site".

Does anyone know I get PHP working with FastCGI on multiple websites inside IIS7?

Thanks for any ideas.

Oct 12 2008 by spanders

Setting up PHP with FastCGI for multiple web site is as straight forward as it is for a single web site. In fact, if you define FastCGI handler mapping on a server level, all the web sites on that server will work with PHP, unless the explicitly overwrite this handler mapping.

Can you run any PHP files in the new site? Is the doc_root setting in php.ini file set to any value?

Oct 16 2008 by ruslany

Worked well for me.

index.php should be set as one of the default documents

Could all of this be encapsulated into a manifest of some sort? One for multisite installs and one for single site installs. I've been scripting on linux servers, but am interested in the manifest approach for windows as outlined at: http://learn.iis.net/page.aspx/578/application-packaging-guide-for-the-windows-web-application-gallery/

Mar 28 2009 by johnbarclay

Submit a Comment

You must Log In to comment.

Microsoft Communities