我第一次尝试CGI脚本,但没有成功。我读了很多教程,并在不同的论坛上关注了我的帖子,但我不能让它工作。我在Fedora10机器上使用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
我就是不能让它工作。有谁可以帮我?
发布于 2009-10-21 17:40:04
检查你的操作系统对test.cgi的权限,并确保你用来运行apache的用户或组具有读取权限。
编辑-问题出在权限上,而不是读权限上,因为你使用的是SELinux,你需要担心你的文件上下文。在fedora论坛上查看这个thread,它解释了相当多的选项来解决你的问题。
发布于 2013-02-03 18:52:58
如果挂载的文件系统具有执行权限,请检查fstab
UUID=xxx-xxx-xxx-xx-xx /mnt/mountpoint ext4 rw,user,exec 0 0exec部分很重要
发布于 2014-11-12 16:48:14
在我的例子中,SELinux阻止Apache访问cgi脚本。一个对我有效的快速修复方法是关闭SELinux:
vim /etc/sysconfig/selinux
set "SELINUX=disabled"
reboothttps://stackoverflow.com/questions/1599728
复制相似问题