Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Is it possible to make apache not dependant on log existance?

If there is a log file that cannot be opened, apache quits after restart or even reload. Quite an unplesant behaviour because one needs to be super careful when manipulating vhosts on production server. Does it need to be this way? Interesting is that if there is just a syntax error in a vhost reloading apache does not quit it.

Example:

$ sudo /etc/init.d/httpd reload

From logs:

[Thu Jan 10 19:25:02 2013] [notice] SIGHUP received.  Attempting to restart
(2)No such file or directory: httpd: could not open error log file /var/www/patron/logs/error_log.
Unable to open logs

And apache is not running anymore :(.

share|improve this question
    
Test the changes in a staging environment as you should anyway. Would you rather have Apache not tell you that it can't open its logs, then silently dump everything? –  gparent Jan 10 '13 at 18:51
    
we are pretty small company and the only staging environment is production server itself (i.e. separate directory for production websites and websites being tested). Regrettably, this feature of apache makes this approach uneasy. –  clime Jan 11 '13 at 14:54
    
One thing you can try (and it won't solve every problem, but it will help) is to use Apache to test the config beforehand for its validity. You should be able to do this without restarting (or even starting) Apache. –  gparent Jan 11 '13 at 15:09
add comment

1 Answer

You are barking up the wrong tree here. You've instructed apache to keep logs, it's not able to do that, so it bails out, as it should.

The real problem here is lack of control/testing. Before touching your production configs, test those changes in a staging environment. Doing so will catch this type of issue in addition to countless others.

If you absolutely must modify your configs directly on the production server, make sure you perform a configuration test before reloading the configuration. Use of apachectl configtest and apachectl graceful will eliminate most (but not all) accidents of this type.

share|improve this answer
    
Well if there is a syntax error in a vhost, apache does not stop running and just fails to reload configs. I would expect the same behaviour for the log case with an appropriate error message. Emergency brakes are pretty useful things. –  clime Jan 10 '13 at 18:51
1  
The case of logging is different than most vhost syntax errors. Access logging, for many use cases is not only critical to monitoring infrastructure, but also legally mandated. You really don't want your server to drop logs, even with an error message which you may or may not catch. –  EEAA Jan 10 '13 at 18:53
    
I don't want my server to drop logs, I want it to continue processing after "reload" command (even with old configs). Anyway, I guess it is not possible then. –  clime Jan 10 '13 at 18:56
1  
What you're asking for is impossible though. It can't open the log, it needs to either drop them or not accept any connections (and then not have anything to drop). Reload reloads the config, so the old one is irrelevant once you execute the command. –  gparent Jan 10 '13 at 18:57
1  
That said, I'd appreciate a try-reload command, but without a separate command I don't think it's possible to have sensible behavior the way you describe. –  gparent Jan 11 '13 at 15:10
show 3 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.