Installing Gallery 2 on IIS in a hosted environment is not possible, unless you have local administrator permissions on the server.
This guide assumes that Windows 2003 Server and Internet Information Server 6.0 is already installed.
You have to download the latest Versions of MySQL and PHP.
MySQL:
http://dev.mysql.com/downloads/mysql/4.1.html
PHP:
http://php.net/downloads.php
Make sure you download the .zip archive, not the Windows installer! The installer doesn't help preparing the IIS anyway and misses invaluable .dll files like php-gettext
UPDATE: PHP 5.2.0 installer does most of IIS integration for you. You can also specify which extensions you want to enable (gettext, GD2, etc.). The only thing that you need to do is to configure Application mapping and restart IIS. Apparently, it's a bug, so expect this to be done automatically in future versions.
The default Setting of the MySQL Installer are mostly good, but there are some important things:
In this guide we use "gallery2" as the databasename for your gallery, you can choose another if you want.
Start Menu -> MySQL -> MySQL Server 4.1 -> MySQL Command Line Client
CREATE DATABASE gallery2;
GRANT USAGE ON * . * TO 'gallery2'@'localhost' IDENTIFIED BY 'yourPasswordHere';
GRANT SELECT , INSERT , UPDATE , DELETE , CREATE , DROP , ALTER ON `gallery2` . * TO 'gallery2'@'localhost';
exit
The path used for PHP is just an example, you can choose another if you want.
Make sure you remove the initial semicolons!
;session.save_path = "/tmp"
replace it with
session.save_path = "C:\WINDOWS\TEMP"
; **You CAN safely turn this off for IIS, in fact, you MUST.** ; cgi.force_redirect = 1
replace it with
; **You CAN safely turn this off for IIS, in fact, you MUST.** cgi.force_redirect = 0
; Directory in which the loadable extensions (modules) reside. extension_dir = "./"
replace it with
; Directory in which the loadable extensions (modules) reside. extension_dir = "C:\PHP\EXT"
If you can't find "extension_dir" in your C:\PHP\PHP.INI file, add it to the bottom of the file.
As Gallery 2 uses a database to store it's metadata, you need to enable database support in PHP. This guide uses MySQL, but the procedure would be similar for Postgres or Oracle.
;extension=php_mysql.dll
replace it with
extension=php_mysql.dll
;extension=php_gettext.dll
replace it with
extension=php_gettext.dll
But now comes the crux. php_gettext.dll is depending on \php-install-dir\dll\iconv.dll All other extensions work flawlessly for me. But gettext.dll required me to put iconv.dll into a dir that is included in the searchpath. E.g. /windows/system32 I then overreacted and copied all dll's to that /system32 dir. The manual of php 4 tells you to copy the dll's to the /php-install-dir/ but that only works if you add manually the php dir into the path statement of windows.
Find the extension in your php.ini and remove the # in front of the line ;extension=php_gd2.dll
;extension=php_gd2.dll
replace it with
extension=php_gd2.dll
Changing key php.ini values to suit the bigger demands of G2: The following values should be working for most of the gallery users. The max times have been upped just as a precaution. But I think that G2 overrides them anyway.
max_execution_time = 300 ; Maximum execution time of each script, in seconds max_input_time = 300 ; Maximum amount of time each script may spend parsing request data memory_limit = 32M ; Maximum amount of memory a script may consume (8MB) upload_tmp_dir = "C:\Inetpub\wwwroot\uploads" ; Temporary directory for HTTP uploaded files. post_max_size = 7M ; Maximum size of POST data that PHP will accept. upload_max_filesize = 6M ; The maximum allowed size for uploaded files. open_basedir = [path you want to use]. See: [1]
Set upload_max_filesize and post_max_size to whatever you need, but post_max_size MUST be >= the value you set for upload_max_filesize, and must be < the value in memory_limit.
;C:\PHP
PHPRC
C:\PHP
This will make PHP.INI available to PHP (We will verify this later)
You have a choice of whether to setup PHP to use the ISAPI extension, CGI executable, or using FastCGI. The ISAPI extension is not fully stable, and the CGI executable's performance is very poor because after every request the php-cgi.exe executable is unloaded. So if the php-cgi.exe executable is always loaded into memory then that would greatly increase the performance. There are two ways of doing this.
1. Spend $500 for Zend's own WinEnabler [2]
2. Setup the free FastCGI program that does the same thing as WinEnabler
The recommended way of running PHP on IIS is using FastCGI. Below you will find instructions on how to setup PHP using ISAPI but if your site is going to serve lots of pages, you will probably want to go with FastCGI.
Note: You can add this either on the top-level Web Sites or to individual web sites beneath it. If you add it to the top-level web sites node in the left pane, it applies to all websites on the IIS instance. You can also choose to only install it on specific websites beneath the top-level node, in that case it will only apply to that site. The procedure for adding is the same for both scopes.
Be careful when applying this to the top-level node, as it will override settings defined in the individual websites beneath it.
This configures IIS to understand what to do with files ending with .php
A good set of instructions for setting up FastCGI can be found here [3]. The basics are below.
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\FASTCGI]
"StartServers"=dword:00000005
"IncrementServers"=dword:00000002
"MaxServers"=dword:00000019
"Timeout"=dword:00000258
[HKEY_LOCAL_MACHINE\SOFTWARE\FASTCGI\.php]
"AppPath"="c:\\php\\php-cgi.exe"
"BindPath"="php-fcgi"
<?php phpinfo(); ?>
Now, you need to give the anonymous internet user account and NETWORK SERVICE account read/execute permissions on the C:\PHP directory, to allow IIS to parse the .PHP files. You do this by
Open the test.php file via your browser, example: http://www.example.com/test.php
A page showing your PHP configuration settings should now appear. If not, make sure you have followed ALL the steps outlined earlier in the guide.
Verify that PHP uses C:\PHP\PHP.ini by looking at the column for Configuration File (php.ini) Path Also, verify that MySQL support is loaded, and that the session_save.path is set to the correct values. If not, edit C:\PHP\PHP.ini again, set the values as outlined and then restart the IIS Web Service (IIS Manager->Right Click <servername>(Local computer)->All Tasks->Restart IIS).
After you have verified your PHP install, delete the test.php file from your website.
C:\>cacls \path\to\g2data\tmp /E /G %COMPUTERNAME%\IWAM_%COMPUTERNAME%:F
NOTE: The 6.4.2 windows binaries do not seem to play well with G2. After much testing, I finally installed the 6.4.1 binaries that i had working on my WinXP box, and that made IM work. See forum post: http://galleryproject.org/node/79750 for more info and the binary I used. -Jrevillini 15:02, 18 July 2008 (UTC)
NOTE: I had trouble successfully configuring the Image Magick plugin in Gallery unless the binaries were installed in a folder higher than the location set in open_basedir. Until I tried that all of the plugin path tests would fail. --Scn095 06:12, 1 January 2009 (UTC)
Give COMPUTERNAME/IUSR_COMPUTERNAME Modify permission on the gallery2 data directory.
This can occur if you are uploading a file that takes over 300 seconds. Changing the max_execution_time variable in the php.ini above the default IIS value will not fix this problem. You need to change the CGITimeout property which is in the IIS metabase.
Some scripts are offered to help change this variable, but I prefer a GUI. Download this IIS Administration Pack and it will install metabase explorer.
Run the metabase explorer, then expand LM, and find W3SVC. Under this you will see a CGITimeout property, it should be set to 300 (that is the default). Increase this value so that your script can take longer to upload a file. Please realize though that ANY page hosted by IIS will have this timeout value, this is not set on a per site basis.
Assuming you have installed PHP using the ISAPI dll. You now need to restart IIS. To do this, click start, then run, and type "iisreset /restart" then click ok. The problem *should* now be fixed.
hints for setting filepermissions:
You should use XCACLS, not CACLS to set permissions, CACLS doesn't correctly set inheritance.
Get XCACLS here:
{{{ XCACLS.vbs <path to your website>\gallery /E /G IUSR_<computernamehere>:M
e.g.
XCACLS.vbs E:\inetpub\wwwroot\mysite.com\htdocs\gallery /E /G IUSR_WEBSERVER1:M }}}