Accidentally deleted /var/log/apache2 and now can’t restart Apache

when I restart apache2

pike01@pike01:~$ sudo service apache2 restart
 * Restarting web server apache2                                         [fail]
 * The apache2 configtest failed.
Output of config test was:
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
(2)No such file or directory: AH02291: Cannot access directory '/var/log/apache2/' for main error 
(2)No such file or directory: AH02291: Cannot access directory '/var/log/apache2/' for error log of vhost defined at /etc/apache2/sites-enabled/000-default.conf:83
(2)No such file or directory: AH02291: Cannot access directory '/var/log/apache2/' for error log of vhost defined at /etc/apache2/sites-enabled/000-default.conf :67

Answer:
To get fixed

sudo mkdir /var/log/apache2/
sudo touch /var/log/apache2/{access,error,other_vhosts_access,suexec}.log
sudo chown -R root:adm /var/log/apache2/
sudo chmod -R 750 /var/log/apache2

now again restart the apache webserver by using, sudo service apache2 restart

Leave a Reply

Your email address will not be published. Required fields are marked *