为什么Apache中的mod_fastcgi抱怨它没有创build服务器的权限?

这是一个非常古老的FastCGI问题,但我从来没有find满意的答案。

在Google上search短语“(13)权限被拒绝的fastcgi无法创build服务器”会显示有很多人经历了这个问题很长一段时间。

有些人把它归咎于selinux,并build议把它关掉(不能接受的解决scheme)。

其他人认为这是一个奇怪的符号链接权限问题,并build议将Apache日志目录从符号链接转换为纯文本目录。 (不可接受,因为它涉及移动日志文件)请参阅安装FastCGI 。

以下是Apache通常logging的可怕错误。

[Wed Jun 14 22:09:34 2009] [notice] Apache/2.0.40> (Red Hat Linux) configured -- resuming normal operations [Wed Jun 14 22:09:35 2009] [crit] (13)Permission denied: FastCGI: can't create server "/var/rt3/bin/mason_handler.fcgi": bind() failed [/etc/httpd/logs/fastcgi/70d9a528c5892f2bf0c25e5a334bed81] 

希望serverfault能够最终为这个让FastCGI用户困扰多年的令人困惑和烦人的问题提供一个明确的答案。

当没有人真正知道这种疾病的根本原因时,我实施build议的“治疗”感到不自在。 希望能够深究这个谜团。

/usr/lib/errno.h

 #define EACCES 13 /* Permission denied */ 

mod_fcgi通过命名pipe道与fastCGI子进行通信。 Apache在产生子节点之前创buildpipe道。 我会猜测,Apache没有创build权限

 /var/rt3/bin/mason_handler.fcgi 

要检查这个尝试

 su - apache "touch /var/rt3/bin/mason_handler.fcgi" 

如果失败,请适当调整文件系统权限,以便为该目录中的文件创buildapache权限。

我已经解决了这个问题

 chown apache:apache /etc/httpd/logs/ 

要在SELinux下工作,请尝试使用mod_fcgid而不是mod_fastcgi。 我在CentOS 5.6上用SELinux尝试了mod_fastcgi三个小时,并search了一下,没有任何地方。 这是mod_fastcgi试图创buildpipe道/套接字与fastcgi应用程序通信的问题。 我尝试了/ var / log / httpd / fastcgi文件夹(其中mod_fastcgi创build命名pipe道)的每个权限/ SELinux上下文,但没有任何工作。 然后,我切换到mod_fcgid(从rpm.pbone.net下载的EL5 rpm),显然不使用相同的通信方法与fastcgi应用程序对话,并且一切工作都很完美,就像fastcgi应用程序是普通的cgi应用程序一样! 您仍然需要在文件上设置正确的SELinux上下文(请参阅httpd_selinux的手册页)。 例如你想在脚本访问/修改的任何文件上执行chcon -t httpd_sys_script_exec_t fcgiapp和chcon -t httpd_sys_script_r [w | o | a] _t,并且你可能必须设置一些allow_httpd … booleans和setsebool命令。 当然,您也必须正确设置常规文件权限。 有通过典型的mod_fcgiconfiguration的networking教程。

fastcgi进程正在运行的用户没有权限绑定到您要绑定的任何套接字。 可能有多种原因,没有足够的信息来做出有用的诊断。