Apache, problema Falha ao iniciar o LSB: servidor web Apache2

6

Eu uso o Ubuntu 16.02. Quando tento sudo service apache2 restart , diz:

Job for apache2.service failed because the control process exited with error code. See "systemctl status apache2.service" and "journalctl -xe" for details.

Em seguida, digito: journalctl -xe e solicito:

-- 
-- Unit apache2.service has begun starting up.
Jan 11 02:30:46 aleksandr-VirtualBox apache2[8177]: /etc/init.d/apache2: 1: /etc/apache2/envvars: envvars: not found
Jan 11 02:30:46 aleksandr-VirtualBox apache2[8177]: /etc/init.d/apache2: 49: /etc/apache2/envvars: envvars: not found
Jan 11 02:30:46 aleksandr-VirtualBox apache2[8177]: /etc/init.d/apache2: 1: /etc/apache2/envvars: envvars: not found
Jan 11 02:30:46 aleksandr-VirtualBox apache2[8177]: /etc/init.d/apache2: 49: /etc/apache2/envvars: envvars: not found
Jan 11 02:30:46 aleksandr-VirtualBox apache2[8177]:  * Starting Apache httpd web server apache2
Jan 11 02:30:46 aleksandr-VirtualBox apache2[8177]:  *
Jan 11 02:30:46 aleksandr-VirtualBox apache2[8177]:  * The apache2 configtest failed.
Jan 11 02:30:46 aleksandr-VirtualBox apache2[8177]: Output of config test was:
Jan 11 02:30:46 aleksandr-VirtualBox apache2[8177]: /usr/sbin/apache2ctl: 1: /etc/apache2/envvars: envvars: not found
Jan 11 02:30:46 aleksandr-VirtualBox apache2[8177]: /usr/sbin/apache2ctl: 49: /etc/apache2/envvars: envvars: not found
Jan 11 02:30:46 aleksandr-VirtualBox apache2[8177]: (2)No such file or directory: AH02291: Cannot access directory '/etc/apache2/logs/' for main error log
Jan 11 02:30:46 aleksandr-VirtualBox apache2[8177]: AH00014: Configuration check failed
Jan 11 02:30:46 aleksandr-VirtualBox apache2[8177]: Action 'configtest' failed.
Jan 11 02:30:46 aleksandr-VirtualBox apache2[8177]: The Apache error log may have more information.
Jan 11 02:30:46 aleksandr-VirtualBox systemd[1]: apache2.service: Control process exited, code=exited status=1
Jan 11 02:30:46 aleksandr-VirtualBox sudo[8171]: pam_unix(sudo:session): session closed for user root
Jan 11 02:30:46 aleksandr-VirtualBox 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.
Jan 11 02:30:46 aleksandr-VirtualBox systemd[1]: apache2.service: Unit entered failed state.
Jan 11 02:30:46 aleksandr-VirtualBox systemd[1]: apache2.service: Failed with result 'exit-code'.
Jan 11 02:33:09 aleksandr-VirtualBox dhclient[792]: DHCPREQUEST of 192.168.56.101 on enp0s8 to 192.168.56.100 port 67 (xid=0x204f076f)
Jan 11 02:33:09 aleksandr-VirtualBox dhclient[792]: DHCPACK of 192.168.56.101 from 192.168.56.100
Jan 11 02:33:09 aleksandr-VirtualBox NetworkManager[619]:   [1484073189.4253]   address 192.168.56.101
Jan 11 02:33:09 aleksandr-VirtualBox NetworkManager[619]:   [1484073189.4260]   plen 24 (255.255.255.0)
Jan 11 02:33:09 aleksandr-VirtualBox NetworkManager[619]:   [1484073189.4266]   server identifier 192.168.56.100
Jan 11 02:33:09 aleksandr-VirtualBox NetworkManager[619]:   [1484073189.4273]   lease time 1200
Jan 11 02:33:09 aleksandr-VirtualBox NetworkManager[619]:   [1484073189.4279] dhcp4 (enp0s8): state changed bound -> bound
Jan 11 02:33:09 aleksandr-VirtualBox dbus[590]: [system] Activating via systemd: service name='org.freedesktop.nm_dispatcher' unit='dbus-org.freedesktop.nm-dispatcher.service'
Jan 11 02:33:09 aleksandr-VirtualBox systemd[1]: Starting Network Manager Script Dispatcher Service...
-- Subject: Unit NetworkManager-dispatcher.service has begun start-up
-- Defined-By: systemd
-- Support: 
-- 
-- Unit NetworkManager-dispatcher.service has begun starting up.
Jan 11 02:33:09 aleksandr-VirtualBox dhclient[792]: bound to 192.168.56.101 -- renewal in 559 seconds.
Jan 11 02:33:09 aleksandr-VirtualBox dbus[590]: [system] Successfully activated service 'org.freedesktop.nm_dispatcher'
Jan 11 02:33:09 aleksandr-VirtualBox systemd[1]: Started Network Manager Script Dispatcher Service.
-- Subject: Unit NetworkManager-dispatcher.service has finished start-up
-- Defined-By: systemd
-- Support: 
-- 
-- Unit NetworkManager-dispatcher.service has finished starting up.
-- 
-- The start-up result is done.
Jan 11 02:33:09 aleksandr-VirtualBox nm-dispatcher[8205]: req:1 'dhcp4-change' [enp0s8]: new request (1 scripts)
Jan 11 02:33:09 aleksandr-VirtualBox nm-dispatcher[8205]: req:1 'dhcp4-change' [enp0s8]: start running ordered scripts...

E quando systemctl status apache2.service é mais importante:

* 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 Wed 2017-01-11 02:30:46 +08; 33min ago
     Docs: man:systemd-sysv-generator(8)
  Process: 8023 ExecStop=/etc/init.d/apache2 stop (code=exited, status=0/SUCCESS)
  Process: 2236 ExecReload=/etc/init.d/apache2 reload (code=exited, status=0/SUCCESS)
  Process: 8177 ExecStart=/etc/init.d/apache2 start (code=exited, status=1/FAILURE)

Jan 11 02:30:46 aleksandr-VirtualBox apache2[8177]: /usr/sbin/apache2ctl: 1: /etc/apache2/envvars: envvars: not found
Jan 11 02:30:46 aleksandr-VirtualBox apache2[8177]: /usr/sbin/apache2ctl: 49: /etc/apache2/envvars: envvars: not found
Jan 11 02:30:46 aleksandr-VirtualBox apache2[8177]: (2)No such file or directory: AH02291: Cannot access directory '/etc/apache2/logs/' for main error log
Jan 11 02:30:46 aleksandr-VirtualBox apache2[8177]: AH00014: Configuration check failed
Jan 11 02:30:46 aleksandr-VirtualBox apache2[8177]: Action 'configtest' failed.
Jan 11 02:30:46 aleksandr-VirtualBox apache2[8177]: The Apache error log may have more information.
Jan 11 02:30:46 aleksandr-VirtualBox systemd[1]: apache2.service: Control process exited, code=exited status=1
Jan 11 02:30:46 aleksandr-VirtualBox systemd[1]: Failed to start LSB: Apache2 web server.
Jan 11 02:30:46 aleksandr-VirtualBox systemd[1]: apache2.service: Unit entered failed state.
Jan 11 02:30:46 aleksandr-VirtualBox systemd[1]: apache2.service: Failed with result 'exit-code'.

O que está errado? Onde está uma interrupção? Por favor ajude!

    
por A.Verber 10.01.2017 / 20:11

4 respostas

4

Existem dois erros:

1. Por algum motivo, seu /etc/apache2/envvars está ausente:

  • de journalctl -xe :

    Jan 11 02:30:46 aleksandr-VirtualBox apache2[8177]: /etc/init.d/apache2: 1: /etc/apache2/envvars: envvars: not found
    Jan 11 02:30:46 aleksandr-VirtualBox apache2[8177]: /etc/init.d/apache2: 49: /etc/apache2/envvars: envvars: not found
    Jan 11 02:30:46 aleksandr-VirtualBox apache2[8177]: /etc/init.d/apache2: 1: /etc/apache2/envvars: envvars: not found
    Jan 11 02:30:46 aleksandr-VirtualBox apache2[8177]: /etc/init.d/apache2: 49: /etc/apache2/envvars: envvars: not found
    ...        
    Jan 11 02:30:46 aleksandr-VirtualBox apache2[8177]: /usr/sbin/apache2ctl: 1: /etc/apache2/envvars: envvars: not found
    Jan 11 02:30:46 aleksandr-VirtualBox apache2[8177]: /usr/sbin/apache2ctl: 49: /etc/apache2/envvars: envvars: not found
    
  • de systemctl status apache2.service :

    Jan 11 02:30:46 aleksandr-VirtualBox apache2[8177]: /usr/sbin/apache2ctl: 1: /etc/apache2/envvars: envvars: not found
    Jan 11 02:30:46 aleksandr-VirtualBox apache2[8177]: /usr/sbin/apache2ctl: 49: /etc/apache2/envvars: envvars: not found
    

No meu sistema, este arquivo tem as próximas permissões:

$ ls -l /etc/apache2/envvars

-rw-r--r--   1 root root  1782 мар 19  2016 envvars

E seu conteúdo ( $ cat /etc/apache2/envvars ) é:

# envvars - default environment variables for apache2ctl

# this won't be correct after changing uid
unset HOME

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

# Since there is no sane way to get the parsed apache2 config in scripts, some
# settings are defined via environment variables and then used in apache2ctl,
# /etc/init.d/apache2, /etc/logrotate.d/apache2, etc.
export APACHE_RUN_USER=www-data
export APACHE_RUN_GROUP=www-data
# temporary state file location. This might be changed to /run in Wheezy+1
export APACHE_PID_FILE=/var/run/apache2/apache2$SUFFIX.pid
export APACHE_RUN_DIR=/var/run/apache2$SUFFIX
export APACHE_LOCK_DIR=/var/lock/apache2$SUFFIX
# Only /var/log/apache2 is handled by /etc/logrotate.d/apache2.
export APACHE_LOG_DIR=/var/log/apache2$SUFFIX

## The locale used by some modules like mod_dav
export LANG=C
## Uncomment the following line to use the system default locale instead:
#. /etc/default/locale

export LANG

## The command to get the status for 'apache2ctl status'.
## Some packages providing 'www-browser' need '--dump' instead of '-dump'.
#export APACHE_LYNX='www-browser -dump'

## If you need a higher file descriptor limit, uncomment and adjust the
## following line (default is 8192):
#APACHE_ULIMIT_MAX_FILES='ulimit -n 65536'

## If you would like to pass arguments to the web server, add them below
## to the APACHE_ARGUMENTS environment.
#export APACHE_ARGUMENTS=''

## Enable the debug mode for maintainer scripts.
## This will produce a verbose output on package installations of web server mod                                               ules and web application
## installations which interact with Apache
#export APACHE2_MAINTSCRIPT_DEBUG=1

Você pode criá-lo manualmente: sudo nano /etc/apache2/envvars , colar acima do conteúdo, salvar ctrl + o e sair ctrl + x .

2. No seu sistema, a pasta /etc/apache2/logs também está ausente:

  • de journalctl -xe :

    Jan 11 02:30:46 aleksandr-VirtualBox apache2[8177]: (2)No such file or directory: AH02291: Cannot access directory '/etc/apache2/logs/' for main error log
    
  • de systemctl status apache2.service :

    Jan 11 02:30:46 aleksandr-VirtualBox apache2[8177]: (2)No such file or directory: AH02291: Cannot access directory '/etc/apache2/logs/' for main error log
    

Esta não é a pasta de log padrão, é definida em sua configuração personalizada e deve ser criada:

$ sudo mkdir /etc/apache2/logs
    
por pa4080 10.01.2017 / 20:29
3

Experimente estes comandos:

sudo a2dismod mpm_event
sudo a2enmod mpm_prefork

Em seguida, reinicie o serviço apache2.

    
por arnauld 07.04.2017 / 16:45
3

Eu excluí os arquivos .conf nos sites disponíveis e não excluí os arquivos de link nos sites habilitados.

Agora eu deletei todos esses arquivos em sites habilitados

reiniciou o servidor apache2 (sudo service apache2 restart)

funcionou para mim

espero que isso ajude alguém:)

    
por Soundarya 17.08.2017 / 06:23
0

Eu tive o mesmo problema. Recebi o mesmo erro com sudo service apache2 restart e executei sudo systemctl status apache2.service e a linha vermelha foi Failed to start LSB: Apache2 web server.

Solução

execute o comando abaixo:

sudo apache2ctl configtest

Ele irá verificar se há erros (erros de sintaxe, eu acho) e, em seguida, você pode depurar o erro.

    
por vmoh_ir 05.04.2018 / 19:06

Tags