【发布时间】:2014-07-15 19:37:51
【问题描述】:
当我尝试在我的 Apache 服务器上执行一个基本的 Perl 脚本时,我收到了这个错误。在我的浏览器中,我输入localhost/cgi-bin/first.pl,我收到了这个错误:
(13)权限被拒绝:'/usr/lib/cgi-bin/first.pl'的执行失败
这是我的 perl 脚本:
#!/usr/lib/cgi-bin
print "Content-type: text/html\n\n";
print "Hello, World.";
这是我在sites-available 文件夹中的默认文件。如您所见,/usr/lib/cgi-bin 中的每个文件都应被识别为 CGI 文件。而且,/usr/lib/cgi-bin 正是first.pl 所在的位置。
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /home/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /home/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AddHandler cgi-script .cgi .py
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
另外,我确实做到了chmod a+x first.pl。
【问题讨论】:
-
脚本上的 shebang 不是脚本的位置...它是脚本解释器的位置。
标签: perl permissions apache2 cgi execution