Liam
Liam

Reputation: 332

Apache 2.2 PHP-FPM, php files receiving 403 forbidden in browser

I'm trying to switch php from fcgid to fpm. I've googled this to great end, and while there are issues that look the same, I still can't resolve it.

I'm running CentOS 6.5, Apache 2.2, PHP 5.4. I installed mod_fastcgi and php-fpm. PHP is working from the shell, but I receive 403 errors via the browser. Obviously, Apache is not passing the requests properly. Post installation, I made the following changes:

renamed /etc/httpd/conf.d/fcgid.conf to fcgid.conf.disabled

Added the following to /etc/httpd/conf.d/fastcgi.conf

<IfModule mod_fastcgi.c>
    DirectoryIndex index.html index.shtml index.cgi index.php
    AddHandler php5-fcgi .php
    Action php5-fcgi /php5-fcgi
    Alias /php5-fcgi /usr/lib/cgi-bin/php5-fcgi
    FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -host 127.0.0.1:9000 -pass$

    <Directory "/usr/lib/cgi-bin">
        Order allow,deny
        <Files "php5.fastcgi">
            Order deny,allow
        </Files>
    </Directory>
</IfModule>

I also made the directory /usr/lib/cgi-bin and chown'd it to apache.apache (not sure if that's necessary).

I did not add anything in any of my virtual host declarations. All other files resolve, just not PHP.

Any help is greatly appreciated. Thanks.

Upvotes: 2

Views: 4385

Answers (2)

Mansur Ul Hasan
Mansur Ul Hasan

Reputation: 3606

This is related to directory level permission in apache you might need to setup directory permission you need to grant your web server to access the file system for your web server.

Here is the directive you might need to add in your httpd.conf file.

<Directory "/var/www/html">
 AllowOverride None
</Directory>

Then restart your apache service this will resolve your issue.

Upvotes: 1

Liam
Liam

Reputation: 332

I was able to resolve this.

/etc/php-fpm.d/www.conf

listen = /tmp/php5-fpm.sock

Restarted php-fpm, then chown'd /tmp/php5-fpm.sock to apache.apache

/etc/httpd/conf.d/fastcgi.conf

<IfModule mod_fastcgi.c>
DirectoryIndex index.php index.html index.shtml index.cgi
AddHandler php5-fcgi .php
Action php5-fcgi /php5-fcgi
Alias /php5-fcgi /usr/lib/cgi-bin/php5-fcgi
FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -socket /tmp/php5-fpm.sock -pass-header Authorization

# For monitoring status with e.g. Munin
<LocationMatch "/(ping|status)">
    SetHandler php5-fcgi-virt
    Action php5-fcgi-virt /php5-fcgi virtual
</LocationMatch>

Lastly, pointed my browser to /info.php and Server API: FPM/FastCGI!

Upvotes: 1

Related Questions