我正在运行一个本地 Web 服务器,该服务器使用共享 IP 连接多个网站。最近我升级到了 Ubuntu 22.04.1 LTS,现在我发现只有一个网站正常运行。我不能肯定地说升级时不存在这个问题,但不久前它还在运行。
etc/hosts
192.168.1.29 secondbase
192.168.1.29 mattiefernworrix.lan
192.168.1.29 mfwsandbox
192.168.1.29 pinkpoodle
192.168.1.29 mfwx
secondbase
是服务器名称。
mattiefernworrix.lan 运行良好,是列表中的第一个。其他三个则不行(mfwsandbox、pinkpoodle 和 mfwx)。实际上,这并不完全正确。如果我请求静态 html 页面,它会按预期出现。如果我请求 .php 文件,它会失败并显示 503 消息。所有 php 文件都从 mysql db 获取数据。
因此据我所知,httpd 没有运行。
jking@secondbase:/sbin$ systemctl status httpd
Unit httpd.service could not be found.
因此我尝试安装 httpd,但失败了。
sudo apt-get update
sudo apt-get install httpd
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package httpd is a virtual package provided by:
nginx-light 1.18.0-6ubuntu14.1
nginx-full 1.18.0-6ubuntu14.1
nginx-extras 1.18.0-6ubuntu14.1
nginx-core 1.18.0-6ubuntu14.1
apache2 2.4.52-1ubuntu4.1
yaws 2.1.1+dfsg-1
webfs 1.21+ds1-12
tntnet 2.2.1-4build2
mini-httpd 1.30-2build1
micro-httpd 20140814-2.1
lighttpd 1.4.63-1ubuntu3
You should explicitly select one to install.
E: Package 'httpd' has no installation candidate
最后,我尝试安装 apache2 包
jking@secondbase:/sbin$ sudo apt-get install apache2
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
apache2 is already the newest version (2.4.52-1ubuntu4.1).
0 upgraded, 0 newly installed, 0 to remove and 13 not upgraded.
不知道接下来该怎么做。卸载 apache2 然后重新安装?
任何帮助是极大的赞赏。
感谢您的答复。
日志文件消息示例(合并):
192.168.1.29 - - [27/Aug/2022:16:36:22 -0700] "GET /index2.html HTTP/1.1" 200 318 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:104.0) Gecko/20100101 Firefox/104.0"
192.168.1.29 - - [27/Aug/2022:16:36:31 -0700] "GET /index.html HTTP/1.1" 200 318 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:104.0) Gecko/20100101 Firefox/104.0"
192.168.1.29 - - [27/Aug/2022:16:37:24 -0700] "GET /search_msqli.php HTTP/1.1" 503 565 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:104.0) Gecko/20100101 Firefox/104.0"
[Sat Aug 27 16:37:24.856332 2022] [proxy:error] [pid 1101] (2)No such file or directory: AH02454: FCGI: attempt to connect to Unix domain socket /run/php/php7.4-fpm.sock (*) failed
[Sat Aug 27 16:37:24.856459 2022] [proxy_fcgi:error] [pid 1101] [client 192.168.1.29:37158] AH01079: failed to make connection to backend: httpd-UDS
192.168.1.29 - - [27/Aug/2022:17:05:04 -0700] "GET /search_msqli.php HTTP/1.1" 503 565 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:104.0) Gecko/20100101 Firefox/104.0"
[Sat Aug 27 17:05:04.820227 2022] [proxy:error] [pid 4836] (2)No such file or directory: AH02454: FCGI: attempt to connect to Unix domain socket /run/php/php7.4-fpm.sock (*) failed
[Sat Aug 27 17:05:04.820254 2022] [proxy_fcgi:error] [pid 4836] [client 192.168.1.29:37160] AH01079: failed to make connection to backend: httpd-UDS
192.168.1.29 - - [27/Aug/2022:17:08:50 -0700] "GET /payments_msqli.php HTTP/1.1" 503 565 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:104.0) Gecko/20100101 Firefox/104.0"
[Sat Aug 27 17:08:50.349738 2022] [proxy:error] [pid 1100] (2)No such file or directory: AH02454: FCGI: attempt to connect to Unix domain socket /run/php/php7.4-fpm.sock (*) failed
[Sat Aug 27 17:08:50.349776 2022] [proxy_fcgi:error] [pid 1100] [client 192.168.1.29:37172] AH01079: failed to make connection to backend: httpd-UDS
我找到了之前的帖子
phpmyadmin“503 服务不可用”:Unbuntu 20.04,MySQL 8.0
搞定了。如果其他人也遇到这个问题,我必须将以下块添加到我的子域 VirtualHost,phpmyadmin 就会再次出现在子域上:
<FilesMatch ".php$"> SetHandler "proxy:unix:/var/run/php/php7.4- >
fpm.username.sock|fcgi://localhost/"
<FilesMatch>/
我看了一下,没有/var/run/php/
目录。
jking@secondbase:~$ php -v
PHP 8.1.2 (cli) (built: Jul 21 2022 12:10:37) (NTS)
附加问题症状
嗨,我刚刚意识到我所说的唯一可以运行的网站只有 html 文件,没有 php 文件。我添加了 info.php 文件并得到了 503 响应。因此,所有正在提供服务的网站都无法处理 php 文件并响应 503 错误消息。
检查 libapache2-mod-php
我除了升级到 22.04 之外什么都没做。我以为它会更新所有必要的内容,因为它是一个现有的安装(包)。我做这个假设错了吗?在升级之前,一切都正常。从那时起,我也多次运行过 apt-get update。
检查一下:
jking@secondbase:~$ dpkg -s libapache2-mod-php
Package: libapache2-mod-php
Status: install ok installed
Priority: optional
Section: php
Installed-Size: 18
Maintainer: Ubuntu Developers <[email protected]>
Architecture: all
Source: php-defaults (92ubuntu1)
Version: 2:8.1+92ubuntu1
Depends: libapache2-mod-php8.
Description: server-side, HTML-embedded scripting language (Apache 2 module) (default)
This package provides the PHP module for the Apache 2 webserver.
PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used open source general-purpose scripting language that is especially suited for web development and can be embedded into HTML.
This package is a dependency package, which depends on latest stable
PHP version (currently 8.1).
Original-Maintainer: Debian PHP Maintainers <[email protected]>
版本不匹配?
因此,错误消息指的是 php 7.4,/run/php/php7.4-fpm.sock (*) failed
而 dpkg 指的是 php 8.1 Version: 2:8.1+92ubuntu1
。是否需要更新某些内容?或者需要卸载/删除某些内容?
约翰
更新软件包
jking@secondbase:/var/log/apache2$ dpkg-query -l libapache2-mod-php8.1
||/ Name Version Architecture Description
+++-=====================-================-============-=======================>
ii libapache2-mod-php8.1 8.1.2-1ubuntu2.3 amd64 server-side, HTML-embed>
jking@secondbase:/var/log/apache2$ dpkg-query -l libapache2-mod-php
||/ Name Version Architecture Description
+++-==================-===============-============-===========================>
ii libapache2-mod-php 2:8.1+92ubuntu1 all server-side, HTML-embedded >
jking@secondbase:/var/log/apache2$ dpkg-query -l libapache2-mod-php7.4
||/ Name Version Architecture Description
+++-=====================-============-============-===========================>
un libapache2-mod-php7.4 <none> <none> (no description available)
jking@secondbase:/var/log/apache2$ dpkg-query -l libapache2-mod-php8.0
||/ Name Version Architecture Description
+++-=====================-============-============-===========================>
un libapache2-mod-php8.0 <none> <none> (no description available)
不幸的是,没有明显的区别。error.log 文件中仍然抱怨 PHP7.4:
[Sun Aug 28 23:23:44.600963 2022] [proxy:error] [pid 6221] (2)No such file or directory: AH02454: FCGI: attempt to connect to Unix domain socket /run/php/php7.4-fpm.sock (*) failed
[Sun Aug 28 23:23:44.601007 2022] [proxy_fcgi:error] [pid 6221] [client 192.168.1.29:56866] AH01079: failed to make connection to backend: httpd-UDS
但我仍然没有/run/php
目录。
包裹状态
jking@secondbase:~$ sudo apt list --installed | grep php
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
libapache2-mod-php8.1/jammy-updates,now 8.1.2-1ubuntu2.3 amd64 [installed]
libapache2-mod-php/jammy,jammy,now 2:8.1+92ubuntu1 all [installed]
php-common/jammy,jammy,now 2:92ubuntu1 all [installed]
php8.1-cli/jammy-updates,now 8.1.2-1ubuntu2.3 amd64 [installed,automatic]
php8.1-common/jammy-updates,now 8.1.2-1ubuntu2.3 amd64 [installed,automatic]
php8.1-opcache/jammy-updates,now 8.1.2-1ubuntu2.3 amd64 [installed,automatic]
php8.1-readline/jammy-updates,now 8.1.2-1ubuntu2.3 amd64 [installed,automatic]
jking@secondbase:~$ sudo apt upgrade
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
jking@secondbase:~$ sudo apt update
Hit:1 http://us.archive.ubuntu.com/ubuntu jammy InRelease
Get:2 http://us.archive.ubuntu.com/ubuntu jammy-updates InRelease [114 kB]
Hit:3 https://dl.google.com/linux/chrome/deb stable InRelease
Get:4 http://security.ubuntu.com/ubuntu jammy-security InRelease [110 kB]
Get:5 http://us.archive.ubuntu.com/ubuntu jammy-backports InRelease [99.8 kB]
Fetched 324 kB in 1s (337 kB/s)
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
All packages are up to date.
jking@secondbase:~$ sudo apt update --fix-missing
Hit:1 http://us.archive.ubuntu.com/ubuntu jammy InRelease
Hit:2 https://dl.google.com/linux/chrome/deb stable InRelease
Get:3 http://us.archive.ubuntu.com/ubuntu jammy-updates InRelease [114 kB]
Get:4 http://security.ubuntu.com/ubuntu jammy-security InRelease [110 kB]
Get:5 http://us.archive.ubuntu.com/ubuntu jammy-backports InRelease [99.8 kB]
Fetched 324 kB in 1s (319 kB/s)
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
All packages are up to date.
jking@secondbase:~$ sudo apt install -f
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
不知道接下来该怎么做。我可能会卸载 Apache 然后重新安装。
感谢您的努力。谢谢。
约翰
答案1
尝试这个
sudo a2enmod php8.1
sudo systemctl restart apache2