Apache如何能够把可执行文件当成CGI程序来执行

1)配置一个默认的可当成CGI程序来执行的目录

#
# ScriptAlias: This controls which directories contain server scripts.
# ScriptAliases are essentially the same as Aliases, except that
# documents in the realname directory are treated as applications and
# run by the server when requested rather than as documents sent to the client.
# The same rules about trailing "/" apply to ScriptAlias directives as to
# Alias.
#
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"

#Apache的ScriptAlias属性为了安全性会把指定的物理路径做一个别名/cgi-bin/,以便隐藏在系统中真实的位置。这个物理路径下的所有可执行文件均会当成CGI程序来执行,无论后缀是什么可执行就行。

#
# "/var/www/cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
#
<Directory "/var/www/cgi-bin">
    AllowOverride None
    Options None
    Order allow,deny
    Allow from all
</Directory>

2)配置/cgi-bin/目录以外的其他目录,让该目录下的可执行文件也被当成CGI程序来执行,否则Apache就只会显示文件内容。

<Directory "/var/www/html/abc">
    Options Indexes FollowSymLinks ExecCGI
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

#设置该目录下哪些后缀的可执行文件会被当初CGI程序来执行,我们设置后缀为.cgi和.pl的文件被当初CGI程序来执行,其他可执行文件不会。

AddHandler cgi-script .cgi .pl


转载于:https://my.oschina.net/lionel45/blog/376785

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值