Ubuntu – The apache2 configtest failed

Apache2server

Apache2 is not working when I try to reload the Apache2 error msg is coming. I am very new to server and Apache2 could you please help to run the apache2. Below is the error code.

:/etc/apache2/sites-available# sudo service apache2 reload
 * Reloading web server apache2                                                                                                   *
 * The apache2 configtest failed. Not doing anything.
Output of config test was:
(20)Not a directory: AH02291: Cannot access directory '/var/log/apache2/' for main error log
(20)Not a directory: AH02291: Cannot access directory '/var/log/apache2/' for error log of vhost define                          d at /etc/apache2/sites-enabled/test.conf:1
(20)Not a directory: AH02291: Cannot access directory '/var/log/apache2/' for error log of vhost define                          d at /etc/apache2/sites-enabled/000-default.conf:1
AH00014: Configuration check failed
Action 'configtest' failed.
The Apache error log may have more information.

Best Answer

If there is no folder /var/log/apache2/ Apache will not be able to write logs there.

So create it first mkdir /var/log/apache2 , or change log folder in apache.conf to something different.

Be sure that permissions are correct as well. chmod 750 /var/log/apache2