[Solved] Apache2 MySQL broken after logs deletion

This article is part of the series where I have started documenting my experiences while working.

So moving on I broke my setup of Apache2 and MySQL after cleaning logs from Stacer (Linux System Optimizer & Monitoring)

I’m running Apache v2.4.41, PHP 5.6 and MySQL 8.0 and Ubuntu 20.0.4

Stacer as mentioned in the app cleaned my application logs but it also broke Apache2 and MySQL. This can also happen when doing logs cleanup manually.

Fixing Apache2

Checking logs

sudo tail /var/log/apache2/error.log

In my case I got a file not found error. Which suggested that Stacer actually deleted the log files the reason apache2 is unable to start.

Trying to start/ restart the service

sudo systemctl restart apache2

it doesn’t work.

Restoring log files for apache2

sudo mkdir /var/log/apache2

try to start apache2 with

sudo systemctl start apache2

if it doesn’t start then create the missing log file using the command below,

sudo nano /var/log/apache2/error.log

Start Apache2

sudo systemctl start apache2

it should start with any issues now.

Restoring log files for MySQL

Create the missing MySQL log file

sudo nano /var/log/mysql/error.log

Setting permissions for the log file to be able to be writable

sudo chmod 777 /var/log/mysql/error.log

Start MySQL server

sudo systemctl mysql start

This should now start MySQL without any issues.

Comment below if you tried this and are still can’t get these to run.

Leave a Reply