Gallery:Windows Sever 2003和IIS6上的安装

来自站长百科
跳转至: 导航、​ 搜索

在托管环境下的IIS上安装Gallery2是不可能的,除非你在该服务器上具有本地管理员权限。

该指导假定已安装了Windows 2003 Server和Internet Information Server 6.0。

要求[ ]

你必须下载最新版本的MySQL和PHP.

MySQL:

  • 从以下地址下载最新的"MySQL必备安装程序(MSI)整合包":
http://dev.mysql.com/downloads/mysql/4.1.html

PHP:

  • 下载最新版本的PHP:确保你下载的是.zip格式的归档文件,而不是Windows安装程序!安装程序不以任何方式帮助准备IIS并会丢失重要的.dll文件,如php-gettext
http://php.net/downloads.php

UPDATE: PHP 5.2.0安装程序会帮助你完成IIS整合的大部分工作。你也可以指定想要启用的扩展(gettext及GD2等)。你唯一需要做的事就是配置应用程序映射并重启IIS。这显然是一个bug,希望在未来的版本中能够自动完成这些。

安装MySQL[ ]

MySQL安装程序的默认设定都没问题,但有几点重要的需要注意:

  • 确保你设定了root密码!
  • 在安装程序的第八个屏幕上选择"Transactional"

建立数据库[ ]

在此知道中我们使用"gallery2"作为你gallery的数据库名称,如果需要的话你可以用其他的名字。

  • 启动MySQL命令行客户端
开始菜单-> MySQL -> MySQL Server 4.1 -> MySQL命令行客户端
  • 输入(在MySQL安装中所定义的)root密码并按"回车"
  • 为gallery创建一个数据库。输入如下语句并按"回车"。
CREATE DATABASE gallery2;
  • 创建一用户以访问数据库。将"yourPasswordHere"替换为你的密码。输入如下语句并按"回车"。
GRANT USAGE ON * . * TO 'gallery2'@'localhost' IDENTIFIED BY 'yourPasswordHere';
  • 赋予新数据库上新建用户的权限。输入如下语句并按"回车"。
GRANT SELECT , INSERT , UPDATE , DELETE , CREATE , DROP , ALTER ON `gallery2` . * TO 'gallery2'@'localhost';
  • 离开MySQL命令行客户端。输入如下语句并按"回车"。
exit

安装PHP.[ ]

用于PHP的路径仅为举例,如果需要你可以使用别的路径。

  • 将归档文件解压到C:\PHP(必要的话可以重命名)
  • 重命名 C:\PHP\php.ini-recommended为C:\PHP\PHP.INI

配置对话目录[ ]

  • 打开C:\PHP\PHP.INI

确认移除了开头的分号!

  • 找到
;session.save_path = "/tmp"

将其替换为

session.save_path = "C:\WINDOWS\TEMP"
  • 找到
; **针对IIS,你可以实际上也必须安全地关闭它。**
; cgi.force_redirect = 1

将其替换为

; **针对IIS,你可以实际上也必须安全地关闭它。**
cgi.force_redirect = 0

配置PHP扩展[ ]

  • 找到
; 可载入扩展(模块)所在目录。
extension_dir = "./"

将其替换为

; 可载入扩展(模块)所在目录。
extension_dir = "C:\PHP\EXT"

如果在C:\PHP\PHP.INI文件中找不到"extension_dir",就将其添加到文件底部。

MySQL extension[ ]

由于Gallery2使用数据库来存储其元数据,你需要启用PHP中的数据库支持。此知道使用的是MySQL,但过程与Postgres或Oracle是相似的。

  • 找到
;extension=php_mysql.dll

将其替换为

extension=php_mysql.dll

Gettext扩展[ ]

  • In order to make the localization of g2 (multi-language) work you need the gettext extension of php. This can be enabled in php.ini. G2 does hint you for that. However gettext is a little strange extension.
  • 找到
;extension=php_gettext.dll 

将其替换为

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.

GD2扩展[ ]

Find the extension in your php.ini and remove the # in front of the line ;extension=php_gd2.dll

  • 找到
;extension=php_gd2.dll 

将其替换为

extension=php_gd2.dll

PHP.INI键值[ ]

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.

  • 找到 the following values and set to your needs.
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)

使PHP可用于IIS[ ]

设定系统路径以包括C:\PHP[ ]

  • 点击我的电脑 -> 属性 -> 高级 -> 环境变量
  • 下拉到系统变量(底部窗口)并双击PATH变量
  • 在结尾添加如下内容(别忘了开头的分号)
;C:\PHP
  • 点击确定

使PHP.INI可用于PHP[ ]

  • 现在还是打开环境变量窗口并点击新建
  • 变量名栏中输入
PHPRC
  • 变量值设定为
C:\PHP

这将使得PHP.INI可用于PHP(稍后我们会对此做确认)

配置IIS[ ]

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 [1]
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.

在IIS web服务扩展上添加PHP ISAPI扩展[ ]

  • Click on Start -> Administrative Tools -> Internet Information Services (IIS) Manager
  • Expand the local computer in the left pane
  • Click on "Web Service Extensions" in the left pane
  • In the right pane, click the blue underlined text, "Add a new Web service extension..."
  • Enter "PHP5 ISAPI" as the "Extension name"
  • Click the "Add..." button and browse to the php5isapi.dll file in your C:\PHP install directory
  • Click Open -> OK
  • Check the "Set extension status to Allowed" checkbox and click "OK"

向IIS站点添加PHP解析[ ]

注: 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.


  • In the left pane, expand Web Sites
  • Right Click the website you want to configure, and select properties
  • Open the Home Directory tab
  • Click Configuration
  • Then go to the Mappings tab
  • Click Add...
  • Enter the full path to php5isapi.dll in the "Executable" textbox or click the Browse button to browse your way to it. If you have followed the path recommendations in this guide, the fill path should be C:\PHP\php5isapi.dll
  • Enter .php in the Extension textbox
  • Select Limit to, enter GET,POST,HEAD
  • Click OK and verify that .PHP is now included in the Application extensions listbox
  • Click OK

This configures IIS to understand what to do with files ending with .php

添加脚本权限[ ]

  • While still having the Web Site Properties dialog box open, click Home Directory
  • Make sure that "Execute permissions" dropdown is set to "Scripts only".
  • Click OK

建立FastCGI[ ]

A good set of instructions for setting up FastCGI can be found here [2]. The basics are below.

  • Make sure you have PHP 4.3.x or later installed. Earlier versions of PHP require extra work to get FastCGI working.
  • Download the files at [3] and unpack isapi_fcgi.dll to c:\php\isapi_fcgi.dll.
  • Create a file using notepad named fastcgi.reg and insert the following text into it
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"
  • Double click the file you just created to merge those settings into the registry.
  • Next setup FastCGI the same way as you would the ISAPI filter, except everywhere you see C:\PHP\php5isapi.dll you should replace that with C:\PHP\isapi_fcgi.dll

测试PHP[ ]

  • In the left pane, right-click on the website you are working with and select Properties
  • Then go to Home Directory
  • Check the Local Path. This shows you were that websites root directory is located (If you are working with the default IIS website, the location will be C:\INETPUB\WWWROOT\)
  • Create a new file called test.php in that location
  • The contents of test.php should be:
<?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

  • Perform this for both the IUSR and NETWORK SERVICE accounts
  • Open My Computer
  • Right-click C:\PHP
  • Select Properties'
  • Go to the Security tab
  • Click Add
  • In the Enter object names to select textbox, enter IUSR
  • Click Check Names and it should expand it to NETWORK SERVICE/IUSR_ServerName
  • Click OK'
  • Verify that the Read & Execute, List Folder Contents and Read values are set to Read.
  • Click OK'

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.

安装二进制[ ]

  • 在IIS6(Windows Server 2003)中添加Windows/IIS权限:g2data\tmp 目录上的IIS_WPG权限。
  • 在IIS5(Windows XP)中给予g2data\tmp目录IWAM权限。在命令行提示中输入如下的命令:
C:\>cacls \path\to\g2data\tmp /E /G %COMPUTERNAME%\IWAM_%COMPUTERNAME%:F
  • 另见: [[Gallery:常见问题#我在Windows/IIS下G2安装程序的模块步骤得到了许多"Warning: exec(): Unable to fork [cmd /c ...]"(ImageMagick模块)这样的警告提示,该怎么办?|我在Windows/IIS下G2安装程序的模块步骤得到了许多"Warning: exec(): Unable to fork [cmd /c ...]"(ImageMagick模块)这样的警告提示,该怎么办?]]

ImageMagick[ ]

  • 从http://imagemagick.org/script/binary-releases.php#windows下载ImageMagick-6.2.3-0-Q16-windows-static.exe
  • 安装到C:\IM(或者你自定的位置,不过最好放在不含空隙的文件夹结构中)
  • 给予IUSR帐户在C:\IM上的读/执行权限
  • 给予IUSR帐户cmd.exe的读/执行权限

NetPBM[ ]

  • 从http://www.4wiseguys.com/filemgmt/singlefile.php?lid=19下载NetPBM-10.18.4-Win2k3或从http://mirror.geesu.net/gallery/netpbm_1.4-pl1.zip下载最小化的必要文件(包括bmptopnm和ppmtobmp)
  • 将其解压到C:\netpbm(或者你自定的位置,不过最好放在不含空隙的文件夹结构中)
  • 给予IUSR_machinename在C:\netpbm上读/执行权限(也包括文件)

jhead[ ]

Ffmpeg[ ]

  • celtic-druid下载最新的SVN快照版。它以7z格式打包,因此你可能需要7-Zip文件管理器来将其解压。为了方便起见,你可以从geesu下载一个zip版本(rev9133)。
  • 在Ffmpeg模块配置中指定的executable。

Dcraw[ ]

Zip/UnZip[ ]

  • 下载如下文件:
    • zip
    • unzip
    • 注:这些zip和unzip整合包来自cygwin,在同一目录下必须含有对应的dll文件以使其正常运行。
  • 将文件解压到C:\zip
  • 给予IUSR_machinename在C:\zip上的读/执行权限

疑难解答[ ]

常见问题[ ]

Why am I getting a CGI Application Error on my website or a "Error: HTTP POST failed (HTTP 502 Bad Gateway )" with gallery remote?[ ]

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.


Why am I receiving a "Invalid access to memory location" error message?[ ]

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.


备忘录[ ]

  • 在拷贝后,确保在ggalery2 dir上设定了权限。当文件/目录被复制到同一个卷之中时,权限将无法被继承。
  • 在站点配置中将index.php作为目录索引进行添加
  • 在g2data dir!! <--- !!!!上的权限
  • gallery2/config.php权限
  • cmd.exe,给予(IUSR)执行权限(模块激活),或自命令行运行[cacls %COMSPEC% /E /G %COMPUTERNAME%\IUSR_%COMPUTERNAME%:R]
  • c:\windows\temp,给予(USR)写权限或使用上传小程序上传后的"Upload error: Upload failed"消息。

设定文件权限的相关提示:

你应当使用XCACLS而不是CACLS来设定权限,CACLS无法正确地设定沿袭性。

获取XCACLS:

http://www.microsoft.com/downloads/details.aspx?amp;amp;displaylang=en&familyid=0ad33a24-0616-473c-b103-c35bc2820bda&displaylang=en

{{{ XCACLS.vbs <你的站点路径>\gallery /E /G IUSR_<computernamehere>:M

e.g.

XCACLS.vbs E:\inetpub\wwwroot\mysite.com\htdocs\gallery /E /G IUSR_WEBSERVER1:M }}}