首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >服务器暂时不可用(503错误)。找不到httpd,需要安装httpd的方法。

服务器暂时不可用(503错误)。找不到httpd,需要安装httpd的方法。
EN

Ask Ubuntu用户
提问于 2022-08-28 09:56:44
回答 1查看 950关注 0票数 0

我正在运行一个使用共享ip的多个网站的本地web服务器。最近我升级到Ubuntu22.04.1LTS,我刚刚发现我的网站只有一个正常工作。我不能肯定这个问题在升级的时候不存在,但是不久之前它还在工作。

etc/hosts

代码语言:javascript
复制
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没有运行。

代码语言:javascript
复制
jking@secondbase:/sbin$ systemctl status httpd
Unit httpd.service could not be found.

因此,我试图安装httpd,但失败了。

代码语言:javascript
复制
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包。

代码语言:javascript
复制
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,然后再安装它?

任何帮助都是非常感谢的。

谢谢你的回应。

日志文件msgs示例(合并):

代码语言:javascript
复制
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服务不可用”:Unbuntu20.04,MySQL8.0

弄明白了。如果其他人有此问题,我必须将以下块添加到我的子域VirtualHost中,phpmyadmin将再次显示在子域中: SetHandler / <D9FilesMatch>

我看过了,而且没有/var/run/php/目录。

代码语言:javascript
复制
jking@secondbase:~$ php -v  
PHP 8.1.2 (cli) (built: Jul 21 2022 12:10:37) (NTS)

附加问题症状

嗨,我刚刚意识到,我说的是唯一的工作网站只有html文件,没有php文件。我添加了info.php文件并得到了503个响应。因此,所服务的所有站点都无法处理php文件并使用503错误消息进行响应。

检查libasache2-mod-php

除了升级到22.04之外,我什么也没做。我以为它会被更新,因为它是一个现有的安装(包)。我做这个假设是错的吗?这一切都是在升级之前开始的。从那以后,我还运行了很多次apt-获取更新。

检查它:

代码语言:javascript
复制
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   
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 

版本错配?

因此,错误消息是指php7.4 /run/php/php7.4-fpm.sock (*) failed,而dpkg是指php8.1 Version: 2:8.1+92ubuntu1。有什么需要更新的吗?还是需要卸载/删除的东西?

约翰

提供最新的包

代码语言:javascript
复制
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               (no description available)


jking@secondbase:/var/log/apache2$ dpkg-query -l libapache2-mod-php8.0
||/ Name                  Version      Architecture Description
+++-=====================-============-============-===========================>
un  libapache2-mod-php8.0               (no description available)

不幸的是,并没有明显的不同。仍然在抱怨error.log文件中的PHP7.4:

代码语言:javascript
复制
[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目录。

包状态

代码语言:javascript
复制
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并重新安装。

感谢你的努力。谢谢。

约翰

EN

回答 1

Ask Ubuntu用户

发布于 2022-10-21 08:53:56

尝尝这个

代码语言:javascript
复制
sudo a2enmod php8.1
sudo systemctl restart apache2
票数 0
EN
页面原文内容由Ask Ubuntu提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://askubuntu.com/questions/1426124

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档