繁体   English   中英

(13)权限被拒绝:访问/cgi-bin/test.cgi被拒绝

[英](13)Permission denied: access to /cgi-bin/test.cgi denied

我是第一次尝试CGI脚本但没有成功。 我已经阅读了很多教程,并且可能会在不同的论坛中使用线程,但我无法使其工作。 我在Fedora 10机器上使用appache web服务器。 我一直有问题

[Wed Oct 21 20:47:36 2009] [notice] SELinux policy enabled; httpd running as context unconfined_u:system_r:httpd_t:s0
[Wed Oct 21 20:47:36 2009] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Wed Oct 21 20:47:36 2009] [notice] Digest: generating secret for digest authentication ...
[Wed Oct 21 20:47:36 2009] [notice] Digest: done
[Wed Oct 21 20:47:36 2009] [notice] Apache/2.2.11 (Unix) DAV/2 PHP/5.2.9 mod_ssl/2.2.11 OpenSSL/0.9.8g configured -- resuming normal operations

我需要帮助。 这就是我的环境。

uname -a
Linux localhost.localdomain 2.6.27.5-117.fc10.i686 #1 SMP Tue Nov 18 12:19:59 EST 2008 i686 i686 i386 GNU/Linux

ls -l /var/www/cgi-bin/
total 36
-rwxrwxrwx 1 root root   106 2009-10-21 18:29 index.html
-rwxr-xr-x 1 root root 11089 2009-02-24 20:11 squidGuard.cgi
-rwxr-xr-x 1 root root  5720 2009-02-24 20:11 squidGuard-simple.cgi
-rwxr-xr-x 1 root root  5945 2009-02-24 20:11 squidGuard-simple-de.cgi
-rwxrwxrwx 1 root root   110 2009-10-21 17:38 test.cgi

apachectl -v
Server version: Apache/2.2.11 (Unix)
Server built:   Mar  6 2009 09:12:25

perl -version
This is perl, v5.10.0 built for i386-linux-thread-multi
Copyright 1987-2007, Larry Wall

我的剧本

cat test.cgi
#!/usr/bin/perl
print "Content-Type: text/html\n\n";
print "Hello, world!\n";

我尝试访问网页服务器“ http://192.168.50.29/cgi-bin/test.cgi ”时出现的错误消息如下所示:

[Wed Oct 21 21:00:27 2009] [error] [client 192.168.50.69] (13)Permission denied: access to /cgi-bin/test.cgi denied

我添加了这一行:

ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"

到/etc/httpd/conf/httpd.conf

我无法让它发挥作用。 谁能帮我?

检查您对test.cgi的操作系统权限,并确保您用来运行您的apache的用户或组具有读访问权限。

编辑 - 问题在于权限,但没有读取权限,因为您正在使用SELinux,您需要担心您的文件上下文。 勾选此线程在Fedora的论坛,它解释了相当多的选项,以解决您的问题。

1 首先检查HTTPD.CONF文件。在httpd.conf中按如下方式编写脚本目录。
在这里,您需要确保找到正确的httpd.conf文件。例如,在我的Debian中,默认的httpd.conf是/ etc / apache2 / sites-avaialbe / default。

<Directory "dir_name">
    Options All
    AllowOverride All
    Order allow,deny
    Allow from all
<Directory>

或者您可以使用默认的/ cgi-bin文件夹。

2.设置测试脚本的执行权限

chmod +x script_name

如果挂载的文件系统有权执行,请检查您的fstab

UUID=xxx-xxx-xxx-xx-xx     /mnt/mountpoint     ext4     rw,user,exec      0      0

执行部分很重要

在我的情况下,SELinux阻止Apache访问cgi脚本。 一个对我有用的快速解决方法是关闭SELinux:

vim /etc/sysconfig/selinux
set "SELINUX=disabled"
reboot

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM