Linux (13)Permission denied:访问/cgi-bin/test.cgi被拒绝
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1599728/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
(13)Permission denied: access to /cgi-bin/test.cgi denied
提问by M.Rezaei
I am trying out CGI-scripts for the first time but without success. I have read many tutorials and followed may threads in different forums but I can not make it work. I am using a appache web server on a Fedora 10 machine. I always have problem with
我第一次尝试 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
I need help. This is what my environment looks like.
我需要帮助。这就是我的环境的样子。
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
My script
我的剧本
cat test.cgi
#!/usr/bin/perl
print "Content-Type: text/html\n\n";
print "Hello, world!\n";
The error message I gen when I try to access the web page server "http://192.168.50.29/cgi-bin/test.cgi" looks like this:
当我尝试访问网页服务器“ 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
I have added the line:
我添加了以下行:
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
to /etc/httpd/conf/httpd.conf
到 /etc/httpd/conf/httpd.conf
I just can not make it work. Can anyone help me?
我只是不能让它工作。谁能帮我?
采纳答案by pedromarce
Check your os permissions for test.cgi and be sure the user or group you are using to run your apache it has read access.
检查 test.cgi 的 os 权限,并确保您用来运行 apache 的用户或组具有读取访问权限。
EDIT - The problem is with permissions, but not with read permissions, as you are using SELinux, you need to worry about your file context. Check this threadat fedora forums, it explains quite a few options to solve your problem.
编辑 - 问题在于权限,而不是读取权限,因为您使用的是 SELinux,您需要担心文件上下文。在 Fedora 论坛上查看此主题,它解释了许多解决问题的选项。
回答by Jichao
1.FIRST CHECK THE HTTPD.CONFFILE.Set the script directory as follows in the httpd.conf.
Here you'd need to make sure you find the right httpd.conf file.For example, in my Debian, the default httpd.conf is /etc/apache2/sites-avaialbe/default.
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>
ORyou could just use the default /cgi-bin folder.
或者你可以只使用默认的 /cgi-bin 文件夹。
2.Set the execute permissionfor the test script.
2.设置测试脚本的执行权限。
chmod +x script_name
回答by Thomas
check your fstab if the mounted filesystem have permission to execute
如果挂载的文件系统有执行权限,请检查您的 fstab
UUID=xxx-xxx-xxx-xx-xx /mnt/mountpoint ext4 rw,user,exec 0 0
the execpart is important
在EXEC部分是很重要的
回答by CCCP
SELinux prevented Apache from accessing the cgi script in my case. A quick-n-dirty fix that worked for me was turning off SELinux:
就我而言,SELinux 阻止 Apache 访问 cgi 脚本。对我有用的快速修复是关闭 SELinux:
vim /etc/sysconfig/selinux
set "SELINUX=disabled"
reboot