首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >Apache2不工作

Apache2不工作
EN

Stack Overflow用户
提问于 2018-05-31 19:35:10
回答 2查看 12.1K关注 0票数 1

我使用Linux Mint。当我尝试重新启动apache时,会显示下一条消息。apache2.service的作业失败,因为控制进程退出并返回错误代码。详细信息请参见"systemctl status apache2.service“和"journalctl -xe”。这里是显示systemctl状态的下一个错误tex `apache2.service

代码语言:javascript
复制
apache2.service - LSB: Apache2 web server
   Loaded: loaded (/etc/init.d/apache2; bad; vendor preset: enabled)
  Drop-In: /lib/systemd/system/apache2.service.d
           └─apache2-systemd.conf
   Active: failed (Result: exit-code) since Thu 2018-05-31 14:15:00 EEST; 7min ago
     Docs: man:systemd-sysv-generator(8)
  Process: 20286 ExecStart=/etc/init.d/apache2 start (code=exited, status=2)

May 31 14:15:00 alpha-To-be-filled-by-O-E-M systemd[1]: Starting LSB: Apache2 web server...
May 31 14:15:00 alpha-To-be-filled-by-O-E-M apache2[20286]: ERROR: APACHE_PID_FILE needs to be defined in /etc/apache2/envvars
May 31 14:15:00 alpha-To-be-filled-by-O-E-M systemd[1]: apache2.service: Control process exited, code=exited status=2
May 31 14:15:00 alpha-To-be-filled-by-O-E-M systemd[1]: Failed to start LSB: Apache2 web server.
May 31 14:15:00 alpha-To-be-filled-by-O-E-M systemd[1]: apache2.service: Unit entered failed state.
May 31 14:15:00 alpha-To-be-filled-by-O-E-M systemd[1]: apache2.service: Failed with result 'exit-code'.

下面是显示journalctl -xe的内容

代码语言:javascript
复制
   `enter code here`-- 
-- Unit flatpak-system-helper.service has begun starting up.
May 31 14:11:23 alpha-To-be-filled-by-O-E-M dbus[923]: [system] Successfully activated service 'org.freedesktop.Flatpak.SystemHelper'
May 31 14:11:23 alpha-To-be-filled-by-O-E-M systemd[1]: Started flatpak system helper.
-- Subject: Unit flatpak-system-helper.service has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit flatpak-system-helper.service has finished starting up.
-- 
-- The start-up result is done.
May 31 14:11:25 alpha-To-be-filled-by-O-E-M ll[18688]: libostree pull from 'flathub' for appstream/x86_64 complete
                                                       security: GPG: summary+commit http: TLS
                                                       non-delta: meta: 1 content: 0
                                                       transfer: secs: 1 size: 569 bytes
May 31 14:11:26 alpha-To-be-filled-by-O-E-M flatpak-system-helper[18716]: libostree pull from 'flathub' for appstream/x86_64 complete
                                                                          security: GPG: summary+commit 
                                                                          non-delta: meta: 1 content: 0
                                                                          transfer: secs: 0 size: 569 bytes
May 31 14:11:34 alpha-To-be-filled-by-O-E-M kernel: [UFW BLOCK] IN=enp2s0 OUT= MAC=01:00:5e:00:00:fb:74:1b:b2:78:93:ac:08:00 SRC=192.168.88.25 DST=224.0.0.251 LEN=32 TOS=0x00 PREC=0x00 TTL=1 ID=62651 PROTO=2 
May 31 14:13:40 alpha-To-be-filled-by-O-E-M sudo[18962]:    alpha : TTY=pts/0 ; PWD=/home/alpha ; USER=root ; COMMAND=/usr/bin/apt-get install lamp-server^ -y
May 31 14:13:40 alpha-To-be-filled-by-O-E-M sudo[18962]: pam_unix(sudo:session): session opened for user root by (uid=0)
May 31 14:13:42 alpha-To-be-filled-by-O-E-M sudo[18962]: pam_unix(sudo:session): session closed for user root
May 31 14:14:35 alpha-To-be-filled-by-O-E-M sudo[20275]:    alpha : TTY=pts/0 ; PWD=/home/alpha ; USER=root ; COMMAND=/bin/nano /var/www/testing.php
May 31 14:14:35 alpha-To-be-filled-by-O-E-M sudo[20275]: pam_unix(sudo:session): session opened for user root by (uid=0)
May 31 14:14:39 alpha-To-be-filled-by-O-E-M kernel: [UFW BLOCK] IN=enp2s0 OUT= MAC=01:00:5e:00:00:fb:74:1b:b2:78:93:ac:08:00 SRC=192.168.88.25 DST=224.0.0.251 LEN=32 TOS=0x00 PREC=0x00 TTL=1 ID=36473 PROTO=2 
May 31 14:14:44 alpha-To-be-filled-by-O-E-M kernel: [UFW BLOCK] IN=enp2s0 OUT= MAC=01:00:5e:00:00:fb:48:43:7c:bd:86:85:08:00 SRC=192.168.88.21 DST=224.0.0.251 LEN=32 TOS=0x00 PREC=0x00 TTL=1 ID=54328 PROTO=2 
May 31 14:14:49 alpha-To-be-filled-by-O-E-M sudo[20275]: pam_unix(sudo:session): session closed for user root
May 31 14:15:00 alpha-To-be-filled-by-O-E-M sudo[20280]:    alpha : TTY=pts/0 ; PWD=/home/alpha ; USER=root ; COMMAND=/usr/sbin/service apache2 restart
May 31 14:15:00 alpha-To-be-filled-by-O-E-M sudo[20280]: pam_unix(sudo:session): session opened for user root by (uid=0)
May 31 14:15:00 alpha-To-be-filled-by-O-E-M systemd[1]: Stopped LSB: Apache2 web server.
-- Subject: Unit apache2.service has finished shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit apache2.service has finished shutting down.
May 31 14:15:00 alpha-To-be-filled-by-O-E-M systemd[1]: Starting LSB: Apache2 web server...
-- Subject: Unit apache2.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit apache2.service has begun starting up.
May 31 14:15:00 alpha-To-be-filled-by-O-E-M apache2[20286]: ERROR: APACHE_PID_FILE needs to be defined in /etc/apache2/envvars
May 31 14:15:00 alpha-To-be-filled-by-O-E-M systemd[1]: apache2.service: Control process exited, code=exited status=2
May 31 14:15:00 alpha-To-be-filled-by-O-E-M systemd[1]: Failed to start LSB: Apache2 web server.
-- Subject: Unit apache2.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit apache2.service has failed.
-- 
-- The result is failed.
May 31 14:15:00 alpha-To-be-filled-by-O-E-M systemd[1]: apache2.service: Unit entered failed state.
May 31 14:15:00 alpha-To-be-filled-by-O-E-M systemd[1]: apache2.service: Failed with result 'exit-code'.
May 31 14:15:00 alpha-To-be-filled-by-O-E-M sudo[20280]: pam_unix(sudo:session): session closed for user root
May 31 14:15:29 alpha-To-be-filled-by-O-E-M kernel: [UFW BLOCK] IN=enp2s0 OUT= MAC=01:00:5e:00:00:fb:74:1b:b2:78:93:ac:08:00 SRC=192.168.88.25 DST=224.0.0.251 LEN=32 TOS=0x00 PREC=0x00 TTL=1 ID=8118 PROTO=2 
May 31 14:15:37 alpha-To-be-filled-by-O-E-M kernel: [UFW BLOCK] IN=enp2s0 OUT= MAC=01:00:5e:00:00:fb:74:1b:b2:78:93:ac:08:00 SRC=192.168.88.25 DST=224.0.0.251 LEN=32 TOS=0x00 PREC=0x00 TTL=1 ID=10819 PROTO=2 
May 31 14:17:01 alpha-To-be-filled-by-O-E-M CRON[20404]: pam_unix(cron:session): session opened for user root by (uid=0)
May 31 14:17:01 alpha-To-be-filled-by-O-E-M CRON[20405]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
May 31 14:17:01 alpha-To-be-filled-by-O-E-M CRON[20404]: pam_unix(cron:session): session closed for user root
May 31 14:17:18 alpha-To-be-filled-by-O-E-M kernel: [UFW BLOCK] IN=enp2s0 OUT= MAC=01:00:5e:00:00:fb:48:43:7c:bd:86:85:08:00 SRC=192.168.88.21 DST=224.0.0.251 LEN=32 TOS=0x00 PREC=0x00 TTL=1 ID=37441 PROTO=2 
May 31 14:17:33 alpha-To-be-filled-by-O-E-M AptDaemon[18313]: INFO: Quitting due to inactivity
May 31 14:17:33 alpha-To-be-filled-by-O-E-M AptDaemon[18313]: INFO: Quitting was requested
May 31 14:17:33 alpha-To-be-filled-by-O-E-M org.debian.apt[923]: 14:17:33 AptDaemon [INFO]: Quitting due to inactivity
May 31 14:17:33 alpha-To-be-filled-by-O-E-M org.debian.apt[923]: 14:17:33 AptDaemon [INFO]: Quitting was requested

删除并重新安装apache2后,将显示下一条消息:

代码语言:javascript
复制
apache2.service - LSB: Apache2 web server
   Loaded: loaded (/etc/init.d/apache2; bad; vendor preset: enabled)
  Drop-In: /lib/systemd/system/apache2.service.d
           └─apache2-systemd.conf
   Active: inactive (dead) since Thu 2018-05-31 14:40:49 EEST; 1min 35s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 24002 ExecStop=/etc/init.d/apache2 stop (code=exited, status=0/SUCCESS)
  Process: 23986 ExecStart=/etc/init.d/apache2 start (code=exited, status=0/SUCCESS)

May 31 14:40:49 alpha-To-be-filled-by-O-E-M apache2[23986]: (98)Address already in use: AH00072: make_sock: could not bind to address [::]:80
May 31 14:40:49 alpha-To-be-filled-by-O-E-M apache2[23986]: (98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80
May 31 14:40:49 alpha-To-be-filled-by-O-E-M apache2[23986]: no listening sockets available, shutting down
May 31 14:40:49 alpha-To-be-filled-by-O-E-M apache2[23986]: AH00015: Unable to open logs
May 31 14:40:49 alpha-To-be-filled-by-O-E-M apache2[23986]: Action 'start' failed.
May 31 14:40:49 alpha-To-be-filled-by-O-E-M apache2[23986]: The Apache error log may have more information.
May 31 14:40:49 alpha-To-be-filled-by-O-E-M apache2[23986]:  *
May 31 14:40:49 alpha-To-be-filled-by-O-E-M apache2[24002]:  * Stopping Apache httpd web server apache2
May 31 14:40:49 alpha-To-be-filled-by-O-E-M apache2[24002]:  *
May 31 14:40:49 alpha-To-be-filled-by-O-E-M systemd[1]: Started LSB: Apache2 web server.
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2018-05-31 19:42:57

代码语言:javascript
复制
export APACHE_PID_FILE=/var/run/apache2/apache2$SUFFIX.pid

将此行添加到/etc/apache2/envvars文件中

如果没有suffix,则必须添加

代码语言:javascript
复制
#for supporting multiple apache2 instances
 if [ "${APACHE_CONFDIR##/etc/apache2-}" != "${APACHE_CONFDIR}" ] ; then
    SUFFIX="-${APACHE_CONFDIR##/etc/apache2-}"
 else
    SUFFIX=
 fi

更新

no listening sockets available。您面临这个问题是因为另一个应用程序/服务获取了您的Ubuntu服务器上的80端口。

现在,您需要终止获取端口80的进程。你可以用下面的命令很容易的找到它:

代码语言:javascript
复制
sudo netstat -ltnp | grep ':80'

这将返回如下内容:-

代码语言:javascript
复制
tcp 0 0 127.0.0.1:80 0.0.0.0:* LISTEN 1588/aolserver4-nsd

对于上面的情况,进程号1588获取端口80,您需要杀死该进程1588。

代码语言:javascript
复制
sudo kill -9 1588

现在,您可以启动apache了

解决方案2

转到/etc/apache2/ports.conf并取消对Listen 80的注释

票数 0
EN

Stack Overflow用户

发布于 2021-02-12 14:22:03

**如果您的Apache2不工作,返回结果如下**

代码语言:javascript
复制
    ● apache2.service - The Apache HTTP Server
   Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
  Drop-In: /lib/systemd/system/apache2.service.d
           └─apache2-systemd.conf
   Active: failed (Result: exit-code) since Fri 2021-02-12 11:23:47 PST; 2min 57s ago

Feb 12 11:23:47 bitcot-Latitude-7480 apachectl[9660]: AH00558: apache2: Could not reliably determine the server's fully qu
Feb 12 11:23:47 bitcot-Latitude-7480 apachectl[9660]: (98)Address already in use: AH00072: make_sock: could not bind to ad
Feb 12 11:23:47 bitcot-Latitude-7480 apachectl[9660]: (98)Address already in use: AH00072: make_sock: could not bind to ad
Feb 12 11:23:47 bitcot-Latitude-7480 apachectl[9660]: no listening sockets available, shutting down
Feb 12 11:23:47 bitcot-Latitude-7480 apachectl[9660]: AH00015: Unable to open logs
Feb 12 11:23:47 bitcot-Latitude-7480 apachectl[9660]: Action 'start' failed.
Feb 12 11:23:47 bitcot-Latitude-7480 apachectl[9660]: The Apache error log may have more information.
Feb 12 11:23:47 bitcot-Latitude-7480 systemd[1]: apache2.service: Control process exited, code=exited status=1
Feb 12 11:23:47 bitcot-Latitude-7480 systemd[1]: apache2.service: Failed with result 'exit-code'.
Feb 12 11:23:47 bitcot-Latitude-7480 systemd[1]: Failed to start The Apache HTTP Server.

别担心,我有一个解决方案

首先,检查您的计算机是否有Nginx服务正在您的系统中运行

代码语言:javascript
复制
sudo systemctl status nginx.service

如果它正在运行,请使用以下命令停止该服务

代码语言:javascript
复制
sudo systemctl stop nginx.service

然后检查端口80是否有任何进程正在该端口上运行

代码语言:javascript
复制
sudo lsof -i tcp:80

输出:

代码语言:javascript
复制
    COMMAND PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
anydesk 950 root   22u  IPv4  39398      0t0  TCP bitcot-Latitude-7480:35993->hosted.by.datacamp.co.uk:http (ESTABLISHED)

使用以下命令终止进程

代码语言:javascript
复制
sudo kill 950

现在您的apache2已经准备好了,要启动服务,请打开一个新的终端Ctrl + Ail + T,然后使用

代码语言:javascript
复制
sudo systemctl  start apache2

这就是你要的

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50623348

复制
相关文章

相似问题

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