我正在使用共用 IP 運行具有多個網站的本機 Web 伺服器。最近我升級到 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 資料庫取得資料。
據我所知,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