如何使Apache在将PHP文件传递给PHP-FPM之前检查其是否存在? [英] How to make Apache check if PHP file exists before passing it to PHP-FPM?

查看:48
本文介绍了如何使Apache在将PHP文件传递给PHP-FPM之前检查其是否存在?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

出现以下错误未指定输入文件".而不是当我请求不存在的PHP文件时找不到的文件.

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

因此可以使Apache在将PHP文件传递给PHP-FPM服务器之前检查是否存在PHP文件,以避免未指定输入文件".错误?还是那个错误是正常/无害的?

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?

这是配置Apache处理PHP文件的方式:

This is how Apache is configured to handle PHP files:

<FilesMatch \.php$>
SetHandler "proxy:unix:/var/run/php5-fpm.sock.example|fcgi://localhost"
</FilesMatch>

推荐答案

我不喜欢为该任务使用RewriteEngine.这是使用SetHandler指令的正确配置,同时检查PHP文件是否确实存在:

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>

来源: PHP-FPM

这篇关于如何使Apache在将PHP文件传递给PHP-FPM之前检查其是否存在?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆