尽管我用 Google 搜索了所有解决方法,但仍然出现此错误。
Apache 已加载以下模块:
# /usr/local/apache/bin/apachectl -M | grep proxy
[Thu Mar 14 22:37:35.825542 2024] [core:trace3] [pid 9087:tid 140083932002176] core.c(3472): Setting LogLevel for all modules to trace8
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using *** Set the 'ServerName' directive globally to suppress this message
proxy_module (shared)
proxy_connect_module (shared)
proxy_ftp_module (shared)
proxy_http_module (shared)
proxy_fcgi_module (shared)
proxy_scgi_module (shared)
proxy_uwsgi_module (shared)
proxy_fdpass_module (shared)
proxy_wstunnel_module (shared)
proxy_ajp_module (shared)
proxy_balancer_module (shared)
proxy_express_module (shared)
proxy_hcheck_module (shared)
我的VirtualHost配置:
<VirtualHost 1.2.3.4:8181>
ServerName example.com
ServerAlias www.example.com
ServerAdmin [email protected]
DocumentRoot /home/example/sites/example.com
UseCanonicalName Off
# ScriptAlias /cgi-bin/ /home/example/sites/example.com/cgi-bin/
#CustomLog /usr/local/apache/domlogs/example.com.bytes bytes
#CustomLog /usr/local/apache/domlogs/example.com.log combined
ErrorLog /usr/local/apache/domlogs/example.com.error.log
suPHP_Engine off
# Redirect to the proxy
<FilesMatch \.php$>
ProxyFCGISetEnvIf "true" SCRIPT_FILENAME "/sites/example.com%{reqenv:SCRIPT_NAME}"
SetHandler proxy:unix:/run/php-fpm/php-fpm-unix.sock
</FilesMatch>
<Directory "/home/example/sites/example.com">
Options -Indexes -FollowSymLinks +SymLinksIfOwnerMatch
AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
</Directory>
</VirtualHost>
php-fpm.d/www.conf
listen = "/run/php-fpm/php-fpm-unix.sock"
我在 CentOS 7 上的 CWP 管理控制面板上使用 Nginx -> Apache2.4 -> php-fpm
UPD1:(可能已解决)
我将 php-fpm 设置为使用 TCP 端口 9000:
listen = 127.0.0.1:9000
<Proxy "fcgi://localhost:9000/" enablereuse=on max=10>
</Proxy>
# Redirect to the proxy
<FilesMatch \.php$>
SetHandler proxy:fcgi://localhost:9000
</FilesMatch>
可以,但是代理到 UNIX 不起作用。可能的原因:
{{ # 如果您的 httpd 版本是 2.4.9 或更新版本(或具有反向移植功能),则可以使用 unix 域套接字}}
{{ #SetHandler "proxy:unix:/path/to/app.sock|fcgi://localhost/"}}
https://cwiki.apache.org/confluence/display/HTTPD/PHP-FPM
我的 Apache 版本是:
# /usr/local/apache/bin/apachectl -V
Server version: Apache/2.4.57 (Unix)
也许,问题已经解决了。