问题
我将PHP
版本从更新7.2
至8.0.5
我跟着本指南更新我的PHP
我运行这个sudo apt-get purge php7.*
来删除我的 php 7 版本。
现在,当我浏览我的网站时,我只会得到 php codeliek
<?php
/* ton of code here */
当我启用
sudo a2enmod proxy_fcgi setenvif
sudo a2enconf php8.0-fpm
我收到错误
Service Unavailable
The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later
浏览网站时
编辑1:
[Sat May 22 12:21:03.453315 2021] [proxy:error] [pid 511723] (2)No such file or directory: AH02454: FCGI: attempt to connect to Unix domain socket /run/php/php8.0-fpm.sock (*) fai>
[Sat May 22 12:21:03.453398 2021] [proxy_fcgi:error] [pid 511723] [client 102.223.225.133:63119] AH01079: failed to make connection to backend: httpd-UDS
编辑2:
跑完之后sudo systemctl list-units --failed
我看见
● php8.0-fpm.service loaded failed failed The PHP 8.0 FastCGI Process Manager
编辑3:
我的 apache 用户是safe-www
编辑4:
/var/log/apache2/error.log
[Sat May 22 12:33:52.354558 2021] [mpm_prefork:notice] [pid 2763] AH00163: Apache/2.4.41 (Ubuntu) mod_fcgid/2.3.9 OpenSSL/1.1.1f configured -- resuming normal operations
[Sat May 22 12:33:52.354654 2021] [core:notice] [pid 2763] AH00094: Command line: '/usr/sbin/apache2'
站点错误日志
[Sat May 22 12:33:54.737169 2021] [proxy:error] [pid 2765] (2)No such file or directory: AH02454: FCGI: attempt to connect to Unix domain socket /run/php/php8.0-fpm.sock (*) failed
[Sat May 22 12:33:54.737233 2021] [proxy_fcgi:error] [pid 2765] [client 102.223.225.133:63281] AH01079: failed to make connection to backend: httpd-UDS
编辑5:
/var/log/apache2/error.log
[Sat May 22 12:45:10.817186 2021] [mpm_prefork:notice] [pid 5482] AH00163: Apache/2.4.41 (Ubuntu) mod_fcgid/2.3.9 OpenSSL/1.1.1f configured -- resuming normal operations
[Sat May 22 12:45:10.817273 2021] [core:notice] [pid 5482] AH00094: Command line: '/usr/sbin/apache2
站点错误日志
AH01070: Error parsing script headers
[Sat May 22 12:45:13.311597 2021] [proxy_fcgi:error] [pid 5484] (22)Invalid argument: [client 102.223.225.133:63477] AH01075: Error dispatching request to :
编辑6:
[ - ] apache-htcacheclean
[ + ] apache2
[ + ] apparmor
[ + ] apport
[ + ] atd
[ + ] chrony
[ - ] console-setup.sh
[ + ] cron
[ - ] cryptdisks
[ - ] cryptdisks-early
[ + ] dbus
[ + ] grub-common
[ - ] hwclock.sh
[ - ] iscsid
[ - ] keyboard-setup.sh
[ + ] kmod
[ - ] lvm2
[ - ] lvm2-lvmpolld
[ + ] multipath-tools
[ - ] open-iscsi
[ - ] open-vm-tools
[ + ] php8.0-fpm
[ - ] plymouth
[ - ] plymouth-log
[ + ] procps
[ - ] rsync
[ + ] rsyslog
[ - ] screen-cleanup
[ + ] ssh
[ + ] udev
[ + ] ufw
[ + ] unattended-upgrades
[ - ] uuidd
[ - ] x11-common
编辑7:
答案1
如果你卸载了 PHP 7.x后安装 PHP 8.0,那么可能存在一些重叠,导致 PHP 8.0 安装失效。可能需要重新安装。
尝试这个:
sudo apt install --reinstall php8.0 libapache2-mod-php8.0
sudo a2enconf php8.0-fpm
sudo service apache2 restart
这将重新加载 PHP 8.0,确保模块就位且完整,启用 FastCGI 进程管理器,然后重新启动 Apache。一般来说,这是当 PHP7.x 出现类似问题时人们需要遵循的流程。
跟进...
有时这AH01079: failed to make connection to backend: httpd-UDS
是由需要重新启动的无用服务引起的。我没有使用 PHP8.0,因此无法猜测服务的名称,但您可以像这样列出系统上运行的所有服务:
sudo service --status-all
这将为您提供一个服务列表,其中[-]
表示它处于非活动状态,[+]
表示它正在运行。您需要查找类似以下内容的服务php80-php-fpm
并重新启动它:
sudo service php80-php-fpm restart
这也许能解决问题。
如果遇到代理问题...
有时,如果使用proxy_fcgi
并且发送缓冲区未填充一帧数据,则可能会出现问题。可以通过编辑受影响站点的 Apache 配置以包含以下内容来解决此问题:
<IfModule proxy_module>
ProxyPassMatch ^(.*\.php)$ fcgi://127.0.0.1:9000/var/www/html/$1
</IfModule>
<IfModule mod_deflate.c>
SetOutputFilter DEFLATE
# Don't compress images
SetEnvIfNoCase Request_URI \.(?:gif|jpeg|jpg|png)$ no-gzip dont-vary
# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary
</IfModule>
希望这可以解决最后的问题。
答案2
升级到 Ubuntu 22.04 (jammy) 后,我遇到了类似的问题。升级安装了 php8.1,之后 apache 不再执行 .php 文件。error.log 中没有错误消息。
我确信我已经安装了 php8.1 所需的所有软件包。最终帮我解决这个问题的是:
sudo apt install libapache2-mod-php8.0
sudo service apache2 restart