O reinício do Apache2 falhou no Ubuntu 16.04

6

Estou tentando usar domain para meu localhost em vez de localhost ou 127.0.0.1

Eu adicionei um arquivo de configuração myconfig.conf in sites-availbale Eu também o habilitei usando sudo a2ensite myconfig.conf

Quando eu reinicio o apache2 server usando sudo sudo systemctl restart apache2 , Eu recebo erro como

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

Eu reinstalei o apache2 desinstalando-o, mas ele gera um erro

Job for apache2.service failed because the control process exited with error code. See "systemctl status apache2.service" and "journalctl -xe" for details.
invoke-rc.d: initscript apache2, action "start" failed.

Saída do sudo journalctl -xe

May 26 12:42:51 vostro-tbe gnome-session[2123]: GET /chrome HTTP/1.1
May 26 12:42:52 vostro-tbe gnome-session[2123]: GET /chrome HTTP/1.1
May 26 12:42:53 vostro-tbe gnome-session[2123]: GET /chrome HTTP/1.1
May 26 12:42:54 vostro-tbe gnome-session[2123]: GET /chrome HTTP/1.1
May 26 12:42:55 vostro-tbe gnome-session[2123]: GET /chrome HTTP/1.1
May 26 12:42:56 vostro-tbe gnome-session[2123]: GET /chrome HTTP/1.1
May 26 12:42:57 vostro-tbe gnome-session[2123]: GET /chrome HTTP/1.1
May 26 12:42:58 vostro-tbe gnome-session[2123]: GET /chrome HTTP/1.1
May 26 12:42:59 vostro-tbe gnome-session[2123]: GET /chrome HTTP/1.1
May 26 12:43:00 vostro-tbe gnome-session[2123]: GET /chrome HTTP/1.1
May 26 12:43:01 vostro-tbe gnome-session[2123]: GET /chrome HTTP/1.1
May 26 12:43:02 vostro-tbe gnome-session[2123]: GET /chrome HTTP/1.1
May 26 12:43:03 vostro-tbe gnome-session[2123]: GET /chrome HTTP/1.1
May 26 12:43:04 vostro-tbe gnome-session[2123]: GET /chrome HTTP/1.1
May 26 12:43:05 vostro-tbe gnome-session[2123]: GET /chrome HTTP/1.1
May 26 12:43:06 vostro-tbe gnome-session[2123]: GET /chrome HTTP/1.1
May 26 12:43:07 vostro-tbe gnome-session[2123]: GET /chrome HTTP/1.1
May 26 12:43:08 vostro-tbe gnome-session[2123]: GET /chrome HTTP/1.1
May 26 12:43:09 vostro-tbe gnome-session[2123]: GET /chrome HTTP/1.1
May 26 12:43:10 vostro-tbe gnome-session[2123]: GET /chrome HTTP/1.1
May 26 12:43:11 vostro-tbe gnome-session[2123]: GET /chrome HTTP/1.1
May 26 12:43:12 vostro-tbe gnome-session[2123]: GET /chrome HTTP/1.1
May 26 12:43:13 vostro-tbe gnome-session[2123]: GET /chrome HTTP/1.1
May 26 12:43:14 vostro-tbe gnome-session[2123]: GET /chrome HTTP/1.1
May 26 12:43:15 vostro-tbe gnome-session[2123]: GET /chrome HTTP/1.1
May 26 12:43:16 vostro-tbe gnome-session[2123]: GET /chrome HTTP/1.1
May 26 12:43:17 vostro-tbe gnome-session[2123]: GET /chrome HTTP/1.1
May 26 12:43:18 vostro-tbe gnome-session[2123]: GET /chrome HTTP/1.1
May 26 12:43:19 vostro-tbe gnome-session[2123]: GET /chrome HTTP/1.1
May 26 12:43:20 vostro-tbe gnome-session[2123]: GET /chrome HTTP/1.1
May 26 12:43:21 vostro-tbe gnome-session[2123]: GET /chrome HTTP/1.1
May 26 12:43:22 vostro-tbe gnome-session[2123]: GET /chrome HTTP/1.1
May 26 12:43:22 vostro-tbe sudo[16839]:     anuj : TTY=pts/1 ; PWD=/etc/apache2/sites-available ; USER=root ; COMMAND=/bin/journalctl -xe
May 26 12:43:22 vostro-tbe sudo[16839]: pam_unix(sudo:session): session opened for user root by anuj(uid=0)

Saída de systemctl status 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 2016-05-26 12:42:43 IST; 53s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 16781 ExecStart=/etc/init.d/apache2 start (code=exited, status=1/FAILURE)

May 26 12:42:43 vostro-tbe apache2[16781]:  *
May 26 12:42:43 vostro-tbe apache2[16781]:  * The apache2 configtest failed.
May 26 12:42:43 vostro-tbe apache2[16781]: Output of config test was:
May 26 12:42:43 vostro-tbe apache2[16781]: apache2: Syntax error on line 140 of /etc/apache2/apache2.conf: Syntax error on line 2 of /etc/apache2/mods-enabled/php7.0.load: Cannot load /usr/lib/apache2/modules/libphp7.0.so
May 26 12:42:43 vostro-tbe apache2[16781]: Action 'configtest' failed.
May 26 12:42:43 vostro-tbe apache2[16781]: The Apache error log may have more information.
May 26 12:42:43 vostro-tbe systemd[1]: apache2.service: Control process exited, code=exited status=1
May 26 12:42:43 vostro-tbe systemd[1]: Failed to start LSB: Apache2 web server.
May 26 12:42:43 vostro-tbe systemd[1]: apache2.service: Unit entered failed state.
May 26 12:42:43 vostro-tbe systemd[1]: apache2.service: Failed with result 'exit-code'.

Saída de sudo apache2ctl configtest

apache2: Syntax error on line 140 of /etc/apache2/apache2.conf: Syntax error on line 2 of /etc/apache2/mods-enabled/php7.0.load: Cannot load /usr/lib/apache2/modules/libphp7.0.so into server: /usr/lib/apache2/modules/libphp7.0.so: cannot open shared object file: No such file or directory
Action 'configtest' failed.
The Apache error log may have more information.

conteúdo de myconfig.conf

<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName website.com
    ServerAlias www.website.com
    DocumentRoot /var/www/html/website
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
    
por Anuj TBE 26.05.2016 / 09:28

4 respostas

15

Instale o pacote libapache2-mod-php7.0 ou desative o módulo PHP7 executando

sudo a2dismod php7.0
    
por Florian Diesch 26.05.2016 / 11:28
5

Eu também tenho o mesmo problema e a razão que causou foi algo assim,

Eu criei um host virtual example.com.conf em etc/apache2/sites-available , então ele criou um link em etc/apache2/sites-enabled quando u habilitar o host virtual para aquele host em particular.

Mais tarde eu apaguei o arquivo example.com.conf de etc/apache2/sites-available , mas esqueci de desativar o host para que o link desse host ainda esteja disponível em etc/apache2/sites-enabled , então isso causa o erro no meu caso, então eu simplesmente excluiu esse arquivo vinculado de etc/apache2/sites-enabled e meu apache começou a funcionar.

    
por OSTech Updates 23.12.2016 / 11:13
1

Se você usa php7, desabilite o módulo php5:

sudo a2dismod php5

isso funcionou para mim

    
por Claudio Zilio 06.09.2016 / 13:58
1

Seu problema é com suas duas linhas no seu arquivo de configuração. Os 2 caminhos de log causam um erro no Apache.

Eu tive esse mesmo problema e quando removi as duas linhas do arquivo de log exatamente como você as tinha, consegui reiniciar o apache.

    
por Mike Mazur 20.10.2016 / 19:30