php - 试图让 PHP-FPM 工作 (Apache 2.4.33)
问题描述
- CentOS 7.5
- 阿帕奇 2.4.33
- PHP-FPM 7.2(通过 Remi repo 安装)
所以我试图让这个手动编译的 Apache 版本与 PHP 一起运行。Apache 一切都很好而且很花哨,但我不确定我是否在 PHP 端正确安装了东西,或者问题是否出在我的虚拟主机配置中。我将尝试添加任何相关信息:
当前安装的 PHP 包
mod_fcgid-2.3.9-15.el7.x86_64
php-7.2.7-1.el7.remi.x86_64
php-cli-7.2.7-1.el7.remi.x86_64
php-common-7.2.7-1.el7.remi.x86_64
php-fpm-7.2.7-1.el7.remi.x86_64
php-gd-7.2.7-1.el7.remi.x86_64
php-json-7.2.7-1.el7.remi.x86_64
php-mbstring-7.2.7-1.el7.remi.x86_64
php-mysqlnd-7.2.7-1.el7.remi.x86_64
php-opcache-7.2.7-1.el7.remi.x86_64
php-pdo-7.2.7-1.el7.remi.x86_64
php-xml-7.2.7-1.el7.remi.x86_64
php-xmlrpc-7.2.7-1.el7.remi.x86_64
加载的模块
access_compat_module (shared)
auth_basic_module (shared)
authn_core_module (shared)
authn_file_module (shared)
authz_core_module (shared)
authz_groupfile_module (shared)
authz_host_module (shared)
authz_user_module (shared)
autoindex_module (shared)
core_module (static)
deflate_module (shared)
dir_module (shared)
env_module (shared)
fcgid_module (shared)
filter_module (shared)
headers_module (shared)
http2_module (shared)
http_module (static)
log_config_module (shared)
mime_module (shared)
mpm_event_module (static)
proxy_fcgi_module (shared)
proxy_module (shared)
reqtimeout_module (shared)
rewrite_module (shared)
setenvif_module (shared)
socache_shmcb_module (shared)
so_module (static)
ssl_module (shared)
unixd_module (shared)
version_module (shared)
Apache 的用户是 httpd,组是 www-data。
下面是虚拟主机配置(尝试根据一些文章将事物混合在一起,但实现对我来说并不完全清楚)。
<VirtualHost *:80>
ServerName domain.com
ServerAlias www.domain.com
DocumentRoot /var/www/domain.com/httpdocs
ErrorLog /var/www/domain.com/logs/error_log
CustomLog /var/www/domain.com/logs/access_log combined
# <LocationMatch "^/(.*\.php(/.*)?)$">
# ProxyPass fcgi://127.0.0.1:9000/var/www/domain.com/httpdocs/$1
# </LocationMatch>
<IfModule mod_fastcgi.c>
AddHandler php7-fcgi-webmin .php
Action php7-fcgi-webmin /php7-fcgi-webmin
Alias /php7-fcgi-webmin /usr/lib/cgi-bin/php7-fcgi-webmin
<Directory "/usr/lib/cgi-bin">
Require all granted
</Directory>
<FilesMatch ".+\.ph(p[345]?|t|tml)$">
SetHandler php7-fcgi-webmin
</FilesMatch>
</IfModule>
<Directory /var/www/domain.com/httpdocs>
AllowOverride All
Require all granted
Options +FollowSymLinks -Indexes -Includes
</Directory>
</VirtualHost>
以下是该站点的 FPM 池配置。
[domain_com]
user = webmin
group = www-data
listen = 127.0.0.1:9000
listen.allowed_clients = 127.0.0.1
listen.owner = webmin
listen.group = www-data
pm = dynamic
pm.max_children = 50
pm.start_servers = 2
pm.min_spare_servers = 2
pm.max_spare_servers = 35
slowlog = /var/www/domain.com/logs/php_fpm_slow_log
php_flag[display_errors] = off
php_admin_value[error_log] = /var/www/domain.com/logs/php_fpm_error_log
php_admin_flag[log_errors] = on
php_admin_value[memory_limit] = 64M
php_admin_value[open_basedir] = /var/www/domain.com/httpdocs
php_value[session.save_handler] = files
php_value[session.save_path] = /var/lib/php/session
php_value[soap.wsdl_cache_dir] = /var/lib/php/wsdlcache
这就是我所在的地方。当我访问 phpinfo 页面时,它只打印 PHP 文件的内容。Apache 或 PHP-FPM 日志中没有记录任何内容。有人能告诉我哪里可能出错了吗?如果需要,我可以再次运行整个过程,或者在可能的情况下进行修复。
解决方案
使用 apache 2.4,最好的方法是使用 FPM 和 SetHandler 来代理
SetHandler "proxy:fcgi://127.0.0.1:9000"
您可以阅读PHP 配置提示,其中解释了切换到 FPM。
您可以删除“php”包(它提供了不需要的 mod_php)
推荐阅读
- python - 在 Linux 上为 Python 3.9 打包 GDAL
- sql - 如何始终只显示 SQL 查询结果表中相同值的第一个值?
- sql - SQL:如何仅将 where 应用于某些字段?
- python - 在 Windows 上将 pytorch 和 matplotlib 与 MKL 一起使用的正确方法是什么?
- javascript - 在for循环中使用时如何为按钮标签提供动态ID
- python - 尝试在 Python 中发送发布请求以从网站下载 csv 文件
- c# - 图像压缩导致 C# 中某些图像的方向错误
- java - 资源泄漏:'yourName' 从未关闭
- sql-server - SSRS 13 (SQL 2016) 报告缓存问题
- python - 如何将搜索功能添加到“list_filter”的输入栏?