PDA

View Full Version : Apache just stops


namit
22nd January 2006, 11:37
Every so often say 1 time a week apache crashes on me i can not seam to restart it or get any responce of viewing websites.

When i try to restart it i get is

Reloading web server config...httpd not running, trying to start
(98)Address already in use: make_sock: could not bind to address [::]:80
no listening sockets available, shutting down
Unable to open logs

This just means i have to reboot the server and it works again but bit of pain when i have no access to computer and it goes down.

Can anyone help me?
Debian

till
22nd January 2006, 12:22
I have the same problem on a debian wood. It seems that the apache main process dies, but some child processes and the SSL apache process where still alive.

I've written a small php script that checks the apache logfile for the error, kills all remaining httpd processes and restarts apache. Its not a nice solution, but it works for me until i find the resaon why apache fails.

<?php

exec('grep "returned a Fatal error..." /var/log/apache/error.log > /tmp/apache_error_test.log');
clearstatcache();
if(filesize("/tmp/apache_error_test.log") > 0) {

// killing apache processes
exec("killall apache");

// make a backup of the error logfile
exec("cp /var/log/apache/error.log /var/log/apache/fatal_error.log");

// empty the error log
exec("cat /dev/null > /var/log/apache/error.log");

sleep(5);

// starting apache websrver
exec("/etc/init.d/apache start");
}

?>


I run this script as cronjob.