Gallery 3, Windows 2008 R2, and IIS 7

EDIT: Gallery’s maintainers decline to fully support Gallery 3 on IIS. See for more info.

Yes, you can run Gallery 3 on Windows 2008 and IIS 7. Here’s how I did it:

  1. Clean install of Windows 2008 R2 x64. NOTE: These days, 32 bit is pretty ridiculous. The instructions below are only guaranteed to work on x64.
  2. Install the Web Server (IIS) role. I think this will also force a portion of the Application Server role to be installed, too.
  3. Install PHP 5.3. Just go through the default installation steps. I used the latest VC9 x86 Non Thread Safe version from the Windows binary download page.
  4. Install MySql Community Edition for Windows x64. I used default options through the process.
  5. Download phpMyAdmin. Unzip and copy files to C:\inetpub\wwwroot\phpmyadmin.
  6. Visit http://localhost/phpmyadmin, sign in using your MySql’s root account, and create a new database for Gallery 3.
  7. Download Gallery 3. As of this writing, the latest version is beta 2.
  8. Extract files and place in C:\inetpub\wwwroot\gallery3.
  9. If you run Gallery right now, it will squawk about missing some PHP settings that are in its .htaccess file. That file is not read by IIS, so you must implement differently:
    1. Create C:\inetpub\wwwroot\gallery3\.user.ini (more info on .user.ini) and open with a text editor. (Might need to use Notepad launched as administrator because of the protection Windows gives to files in C:\inetpub\.) Yes, you do need the period before user in the filename.
    2. Add these lines:
      short_open_tag    =    1
      magic_quotes_gpc   =   0
      magic_quotes_sybase =  0
      magic_quotes_runtime = 0
      register_globals  =    0
      session.auto_start =   0
      upload_max_filesize =  20M
      post_max_size =      100M
      date.timezone = "America/Chicago"

      Note that the date.timezone is because of an additional problem with Gallery 3’s underlying Kohana framework and PHP 5.3 (link).
  10. Create a new directory at C:\inetpub\wwwroot\gallery3\var. Edit its permissions and give the Users and IIS_IUSRS groups Modify permissions. NOTE WELL: Generally, you should use the principle of least privilege and only give enhanced privileges to the smallest number of users possible, which means not the Users group. I’ll revise in the future if I confirm that only IIS_IUSRS–or even a specific account–is all you need.
  11. Set up mod_rewrite:
    1. Download and install the URL Rewrite Module x64.
    2. In Server Manager, click on Server Manager > Roles > Web Server (IIS) > Internet Information Services (IIS) Manager. To the right, find your gallery3’s directory under your web server under Sites. Click on that directory.
    3. Click URL Rewrite then Import Rules…
    4. Copy the mod_rewrite rules, including the IfModule directives, from the end of Gallery3’s .htaccess file and paste into the Rewrite rules field of the Import mod_rewrite rules screen. Remove the # characters at the beginning of each line; otherwise, they are just code comments.
    5. Delete the line containing RewriteBase. It is not supported, and the rules will not import until that is fixed.
    6. Click Apply on the right hand side.
  12. Now run Gallery 3 setup at http://localhost/gallery3.

Viola, you have Gallery 3 on IIS.

This may seem like a lot of steps, but it’s actually not much different than a setup on Ubuntu. It’s easier than how it used to be with IIS 6 or PHP 5.2. Kudos to Microsoft and The PHP Group for a dramatically easier setup process.

6 thoughts on “Gallery 3, Windows 2008 R2, and IIS 7”

  1. Hi.. I am new to web site and have just installed the win2k8r2 version and followed your procedure but when i try to follow item; 6.Visit http://localhost/phpmyadmin, sign in using your MySql’s root account it fails to load the login page giving the following error:

    Error Summary
    HTTP Error 403.14 – Forbidden
    The Web server is configured to not list the contents of this directory. Detailed Error Information
    Module DirectoryListingModule
    Notification ExecuteRequestHandler
    Handler StaticFile
    Error Code 0x00000000
    Requested URL http://localhost:80/phpmyadmin/
    Physical Path C:\inetpub\wwwroot\phpmyadmin\
    Logon Method Anonymous
    Logon User Anonymous

    an you help please

  2. I continued with the procedure and tried to import the rules but what ever i place in the window it states its invalid the details below are everythink within the ‘htaccess file what should i keep/remove?

    php_flag short_open_tag On
    php_flag magic_quotes_gpc Off
    php_flag magic_quotes_sybase Off
    php_flag magic_quotes_runtime Off
    php_flag register_globals Off
    php_flag session.auto_start Off
    php_flag suhosin.session.encrypt Off
    php_value upload_max_filesize 20M
    php_value post_max_size 100M

    # Try to disable the parts of mod_security that interfere with the Flash uploader

    SecFilterEngine Off
    SecFilterScanPOST Off

    # Improve performance by uncommenting this block. It tells the
    # browser that your images don’t change very often so it won’t keep
    # asking for them. If you get an error after uncommenting this, make
    # sure you specify “AuthConfig Indexes” in your Apache config file.
    # ExpiresActive On
    # # Cache all files for a month after access (A).
    # ExpiresDefault A2678400
    # # Do not cache dynamically generated pages.
    # ExpiresByType text/html A1

    # You can use the mod_rewrite Apache module to get rid of the
    # “index.php” from your Gallery 3 urls. Uncomment the block below
    # inside the … lines and then edit the
    # RewriteBase line to match your Gallery 3 URL.
    # Here are some RewriteBase values:
    # Gallery 3 URL RewriteBase line
    # ============= ====================
    # RewriteBase /gallery3
    # RewriteBase /~bob/photos
    # RewriteBase /
    # Then just use your Gallery 3 without the index.php in the url.
    # NOTE: future upgrades of Gallery 3 will overwrite this file! If you
    # want these changes to be persistent, talk to your system admin about
    # putting this block into your Apache config files.
    # RewriteEngine On
    # RewriteBase /
    # RewriteCond %{REQUEST_FILENAME} !-f
    # RewriteCond %{REQUEST_FILENAME} !-d
    # RewriteRule ^(.*)$ index.php?kohana_uri=$1 [QSA,PT,L]
    # RewriteRule ^$ index.php?kohana_uri=$1 [QSA,PT,L]

  3. what abt the using graficsmagic instead of GD as it does not allow file size of more than 2mb upload, also m not able 2 run ffmpeg

Leave a Reply

Your email address will not be published. Required fields are marked *