我正在尝试设置 FastCGI 以与 Apache 2.4.6(CentOS)上的 PHP 一起工作。
我逐字逐句地遵循文档中的说明:https://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html
/etc/httpd/conf/httpd.conf
:
...
<Directory "/var/www/mybin">
Options all
Order allow,deny
Allow from all
</Directory>
FcgidMaxRequestsPerProcess 10000
Alias /phpapp/ /var/www/myphpapp/
<Location "/phpapp/">
Options +ExecCGI
AddHandler fcgid-script .php
FcgidWrapper /var/www/mybin/php-wrapper .php
Order allow,deny
Allow from all
</Location>
...
ls -al /var/www/{,mybin,myphpapp}
(请注意所有相关内容的 0777 权限)
/var/www/:
total 4
drwxr-xr-x. 6 root root 68 Sep 18 20:51 .
drwxr-xr-x. 20 root root 4096 Sep 18 01:04 ..
drwxr-xr-x. 4 root root 32 Sep 18 15:02 html
drwxrwxrwx. 2 root root 24 Sep 18 20:35 mybin
drwxrwxrwx. 2 root root 18 Sep 18 20:20 myphpapp
/var/www/mybin:
total 4
drwxrwxrwx. 2 root root 24 Sep 18 20:35 .
drwxr-xr-x. 6 root root 68 Sep 18 20:51 ..
-rwxrwxrwx. 1 root root 23 Sep 18 20:01 php-wrapper
/var/www/myphpapp:
total 4
drwxrwxrwx. 2 root root 18 Sep 18 20:20 .
drwxr-xr-x. 6 root root 68 Sep 18 20:51 ..
-rwxrwxrwx. 1 root root 19 Sep 18 20:03 a.php
systemctl start httpd
失败了,让我们看看哪里出了问题systemctl -l status httpd
:
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Sun 2016-09-18 20:53:46 EDT; 58s ago
Docs: man:httpd(8)
man:apachectl(8)
Process: 6963 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=1/FAILURE)
Process: 6961 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)
Main PID: 6961 (code=exited, status=1/FAILURE)
Sep 18 20:53:46 localhost.localdomain systemd[1]: Starting The Apache HTTP Server...
Sep 18 20:53:46 localhost.localdomain httpd[6961]: AH00526: Syntax error on line 264 of /etc/httpd/conf/httpd.conf:
Sep 18 20:53:46 localhost.localdomain httpd[6961]: Wrapper /var/www/mybin/php-wrapper cannot be accessed: (13)Permission denied
Sep 18 20:53:46 localhost.localdomain systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
Sep 18 20:53:46 localhost.localdomain kill[6963]: kill: cannot find process ""
Sep 18 20:53:46 localhost.localdomain systemd[1]: httpd.service: control process exited, code=exited status=1
Sep 18 20:53:46 localhost.localdomain systemd[1]: Failed to start The Apache HTTP Server.
Sep 18 20:53:46 localhost.localdomain systemd[1]: Unit httpd.service entered failed state.
Sep 18 20:53:46 localhost.localdomain systemd[1]: httpd.service failed.
它在第 264 行(即带有 的行)处发出抱怨FcgidWrapper
,说“权限被拒绝”。
我可以在哪里指定允许 Apache 访问我的php-wrapper
文件?
答案1
我遇到了同样的问题,正如 HBruijn 指出的那样,问题出在 Selinux 上。
我跑了:
setenforce 0
然后我在 /etc/selinux/config 中禁用它:
SELINUX=disabled