Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make Apache check if PHP file exists before passing it to PHP-FPM?

Tags:

php

apache

I get the following error "No input file specified." instead of a file not found when I request a non-existent PHP file.

So is it possible to make Apache check if PHP file exists before passing it to the PHP-FPM server to avoid "No input file specified." error? or that error is normal/harmless?

This is how Apache is configured to handle PHP files:

<FilesMatch \.php$>
SetHandler "proxy:unix:/var/run/php5-fpm.sock.example|fcgi://localhost"
</FilesMatch>
like image 857
Kassem Avatar asked Dec 10 '14 18:12

Kassem


People also ask

How do I know if PHP-FPM is working?

First open the php-fpm configuration file and enable the status page as shown. Inside this file, find and uncomment the variable pm. status_path = /status as shown in the screenshot. Save the changes and exit the file.

Can you use PHP-FPM with Apache?

By default Apache will use mod_php so now you can configure Apache to use PHP-FPM.

How do I find PHP-FPM?

For example, on CentOS 8, with a single version, all PHP configuration files are located in the /etc directory and the default PHP-FPM pool (www) configuration file is /etc/php-fpm. d/www. conf: To list all PHP configuration files, use the following ls command.

What is PHP-FPM service?

PHP-FPM (FastCGI Process Manager) is an alternative to FastCGI implementation of PHP with some additional features useful for sites with high traffic. It is the preferred method of processing PHP pages with NGINX and is faster than traditional CGI based methods such as SUPHP or mod_php for running a PHP script.


1 Answers

I dislike using the RewriteEngine for that task. Here is the correct configuration to use a SetHandler directive, while checking that the PHP file actually exists :

<FilesMatch "\.(php|php[57]|phtml)$">
    <If "-f %{REQUEST_FILENAME}">
            SetHandler "proxy:fcgi://127.0.0.1:9000"
    </If>
</FilesMatch>

Source : PHP-FPM

like image 67
Tito1337 Avatar answered Oct 06 '22 17:10

Tito1337