Apache2 не работает - PullRequest
0 голосов
/ 31 мая 2018

Я использую Linux Mint.Когда я пытаюсь перезапустить, apache отображает следующее сообщение. Задание для apache2.service не выполнено, поскольку процесс управления завершен с кодом ошибки.Смотрите "systemctl status apache2.service" и "journalctl -xe" для подробностей.Вот следующий текст ошибки, который отображает состояние systemctl `apache2.service

:

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.

1 Ответ

0 голосов
/ 31 мая 2018
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

ОБНОВЛЕНИЕ

no listening sockets available.Вы столкнулись с этой проблемой, потому что другое приложение / служба приобрело порт 80 на вашем сервере Ubuntu.

Теперь вам нужно завершить процесс, который приобрел порт 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

Solution 2

перейти к /etc/apache2/ports.conf и раскомментировать Listen 80

...