Ubuntu – Error while starting apache2 “Cannot access directory ‘/var/log/apache2/’ for main error log”

Apache2

When I run sudo service apache2 start I get this error:

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

And when I run systemctl status apache2.service I get this:

● apache2.service - The Apache HTTP Server
   Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Tue 2019-01-15 16:20:26 -03; 7min ago
  Process: 8101 ExecStart=/usr/sbin/apachectl start (code=exited, status=1/FAILURE)

ene 15 16:20:26 pc systemd[1]: Starting The Apache HTTP Server...
ene 15 16:20:26 pc apachectl[8101]: AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. 
ene 15 16:20:26 pc apachectl[8101]: (2)No such file or directory: AH02291: Cannot access directory '/var/log/apache2/' for main error log
ene 15 16:20:26 pc apachectl[8101]: (2)No such file or directory: AH02291: Cannot access directory '/var/log/apache2/' for error log of vhost 
ene 15 16:20:26 pc apachectl[8101]: AH00014: Configuration check failed
ene 15 16:20:26 pc apachectl[8101]: Action 'start' failed.
ene 15 16:20:26 pc apachectl[8101]: The Apache error log may have more information.
ene 15 16:20:26 pc systemd[1]: apache2.service: Control process exited, code=exited status=1
ene 15 16:20:26 pc systemd[1]: apache2.service: Failed with result 'exit-code'.
ene 15 16:20:26 pc systemd[1]: Failed to start The Apache HTTP Server.

What can I do about this?

Best Answer

  • Fixed

    I just created the directory and gave it write permissions:

    sudo mkdir -p /var/log/apache2/
    sudo chmod -R 744 /var/log/apache2/
    
  • Related Question