为什么Apache打印我的PHP文件的内容而不是将其传递给PHP-FPM?
我在为什么Apache打印我的PHP文件的内容而不是将其传递给PHP-FPM?,php,apache,Php,Apache,我在站点下启用了以下配置文件。我正在使用mod\u proxy\u fcgi ServerName local.dev <Directory /var/www/local/> AllowOverride all Require all granted </Directory> <VirtualHost *:80> # The ServerName directive sets the request scheme, hostnam
站点下启用了以下配置文件
。我正在使用mod\u proxy\u fcgi
ServerName local.dev
<Directory /var/www/local/>
AllowOverride all
Require all granted
</Directory>
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
ServerAlias *.local.*.com
SetEnv CURRENT_ENVIRONMENT ENV_DOCKER
ServerAdmin webmaster@localhost
VirtualDocumentRoot /var/www/local/%3/trunk/%3+-%1/site/www
ProxyPassMatch "^/var/www/local/(.*/trunk/.*/site/www/.*\.php.*)$" "fcgi://php:9000/var/www/local/$1"
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
LogLevel debug
ErrorLog /var/log/apache2/error.log
CustomLog /var/log/apache2/access.log combined
</VirtualHost>
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
ServerAlias local.*.com
SetEnv CURRENT_ENVIRONMENT ENV_DOCKER
ServerAdmin webmaster@localhost
VirtualDocumentRoot /var/www/local/%2/trunk/%2+/site/www
ProxyPassMatch "^/var/www/local/(.*/trunk/.*/site/www/.*\.php.*)$" "fcgi://php:9000/var/www/local/$1"
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
LogLevel debug
ErrorLog /var/log/apache2/error.log
CustomLog /var/log/apache2/access.log combined
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
ServerName local.dev
允许超越所有
要求所有授权
#ServerName指令设置请求方案、主机名和端口
#服务器使用来标识自身。这在创建时使用
#重定向URL。在虚拟主机的上下文中,服务器名
#指定必须在请求的主机:标头中显示的主机名
#匹配此虚拟主机。对于默认虚拟主机(此文件),此
#该值不是决定性的,因为它被用作最后的宿主。
#但是,必须为任何其他虚拟主机显式设置它。
ServerAlias*.local.*.com
SetEnv当前_环境环境_DOCKER
服务器管理员webmaster@localhost
VirtualDocumentRoot/var/www/local/%3/trunk/%3+-%1/site/www
ProxyPassMatch“^/var/www/local/(*/trunk/*/site/www/*\.php.*)”fcgi://php:9000/var/www/local/$1"
#可用日志级别:trace8、…、trace1、调试、信息、通知、警告、,
#错误、暴击、警报、紧急情况。
#还可以为特定应用程序配置日志级别
#模块,例如。
日志级调试
ErrorLog/var/log/apache2/error.log
CustomLog/var/log/apache2/access.log组合
#ServerName指令设置请求方案、主机名和端口
#服务器使用来标识自身。这在创建时使用
#重定向URL。在虚拟主机的上下文中,服务器名
#指定必须在请求的主机:标头中显示的主机名
#匹配此虚拟主机。对于默认虚拟主机(此文件),此
#该值不是决定性的,因为它被用作最后的宿主。
#但是,必须为任何其他虚拟主机显式设置它。
ServerAlias local.*.com
SetEnv当前_环境环境_DOCKER
服务器管理员webmaster@localhost
VirtualDocumentRoot/var/www/local/%2/trunk/%2+/site/www
ProxyPassMatch“^/var/www/local/(*/trunk/*/site/www/*\.php.*)”fcgi://php:9000/var/www/local/$1"
#可用日志级别:trace8、…、trace1、调试、信息、通知、警告、,
#错误、暴击、警报、紧急情况。
#还可以为特定应用程序配置日志级别
#模块,例如。
日志级调试
ErrorLog/var/log/apache2/error.log
CustomLog/var/log/apache2/access.log组合
#vim:syntax=apachets=4sw=4sts=4srnoet
事实证明,我只需要在Apache配置中使用一个SetHandler
指令
<FilesMatch "\.php$">
SetHandler "proxy:fcgi://php:9000"
</FilesMatch>
SetHandler“代理:fcgi://php:9000"
hmmm。。。在ProxyPassMatch上,我使用未加引号的字符串(不确定它是否重要),而不是fcgi://php:9000/blabla
,我配置了fcgi://127.0.0.1:9000/blabla
。。。当然,假设您的php fpm在localhost上运行。我的php fpm没有在localhost上运行-它在名为php
的docker容器中运行。我也试过不用引号,但没有骰子。mod_proxy_fcgi文档中的官方示例有引号,并且“php”是可解析的(DNS方面的),在这里运行apache。另外,在apachemime config.Aha中肯定有一个AddType应用程序/x-httpd-php.php
!是的,php在DNS方面是可解析的,但我认为我的Apache mime配置中没有。我尝试将其添加到包含的配置文件中,但似乎没有任何影响。还有其他想法吗?