Apache2无法正常工作

问题描述 投票:0回答:2

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

的下一个错误tex

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

   `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显示下一条消息:

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.
php apache2 lamp
2个回答
0
投票
export APACHE_PID_FILE=/var/run/apache2/apache2$SUFFIX.pid

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

如果没有suffix,则必须添加

#for supporting multiple apache2 instances
 if [ "${APACHE_CONFDIR##/etc/apache2-}" != "${APACHE_CONFDIR}" ] ; then
    SUFFIX="-${APACHE_CONFDIR##/etc/apache2-}"
 else
    SUFFIX=
 fi

UPDATE

no listening sockets available。您正面临此问题,因为另一个应用程序/服务在您的Ubuntu服务器上获得了端口80。

现在您需要终止获取端口80的进程。您可以使用以下命令轻松找到它:-

sudo netstat -ltnp | grep ':80'

这将返回类似:-

tcp 0 0 127.0.0.1:80 0.0.0.0:* LISTEN 1588/aolserver4-nsd

对于上述情况,进程号1588获得了端口80,您需要终止该进程1588。

sudo kill -9 1588

现在您可以开始apache

解决方案2

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


0
投票

在日志中显示端口80(apache2的端口被另一个应用程序使用:-

© www.soinside.com 2019 - 2024. All rights reserved.