1

I am trying to setup FastCGI to work with PHP on Apache 2.4.6 (CentOS).

I am following the instructins verbatim from the docs: 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} (note the 0777 perms on everything relevant)

/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 fails, so let's see what's wrong with 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.

It complains on line 264, which is the line with FcgidWrapper, saying Permission denied.

Where can I specify that Apache should be allowed to access my php-wrapper file?

1 Answers1

0

I had the same issue and as HBruijn pointed out, Selinux was the issue.

I ran:

setenforce 0

Then I disabled it in the /etc/selinux/config:

SELINUX=disabled
  • Click help my friend, and take a look on how to write a good Q or A. Then come back here and improve your question by editing. Rember that it's not all about someone's issue and your experience on how to fix it, it has to be made useful for the whole community. – Marco Sep 11 '17 at 18:53