Centos 5.5-从多个位置运行 cgi 脚本

Centos 5.5-从多个位置运行 cgi 脚本

我希望能够从 /var/www/cgi-bin 以外的其他位置运行 cgi 脚本,例如:

/var/www/folder1/cgi-bin
/var/www/folder2/cgi-bin
/var/www/folder3/cgi-bin

我该如何配置服务器来执行此操作?

编辑:这是从我个人托管的网络服务器上的网站运行 cgi 脚本。

答案1

ScriptAlias 是你的叔叔。

从:http://httpd.apache.org/docs/2.2/mod/mod_alias.html#scriptalias

Description:    Maps a URL to a filesystem location and designates the target as a CGI script
Syntax: ScriptAlias URL-path file-path|directory-path
Context:    server config, virtual host
Status: Base
Module: mod_alias

The ScriptAlias directive has the same behavior as the Alias directive, except that in addition it marks the target directory as containing CGI scripts that will be processed by mod_cgi's cgi-script handler. URLs with a case-sensitive (%-decoded) path beginning with URL-path will be mapped to scripts beginning with the second argument, which is a full pathname in the local filesystem.
Example:

ScriptAlias /cgi-bin/ /web/cgi-bin/

A request for http://example.com/cgi-bin/foo would cause the server to run the script /web/cgi-bin/foo. This configuration is essentially equivalent to:

Alias /cgi-bin/ /web/cgi-bin/
<Location /cgi-bin >
SetHandler cgi-script
Options +ExecCGI
</Location> 

答案2

有两种方法可以实现这一点:

1)设置虚拟主机,并在每个虚拟主机下指定ScriptAlias /cgi-bin/ "/your/location"

2)在下面创建子文件夹/var/www/cgi-bin并使用子文件夹链接到它们,但是使用此方法,您无法离开/var/www/cgi-bin目录树。

相关内容