Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache2 reload config from inside the CGI

Tags:

apache

cgi

perl

I am working on a simple Perl app that copies another Perl app and builds all the required Apache config files.

The thing I can't seem to figure out is how to reload the apache config on the fly. I know I could do a system call and reload apache there, but that would mean I would have to get root access to this app, and that is a little scary.

Is there a way to ask apache to reload its config files from within the CGI container?

-------------------------Additional info------------------------------

I have done some more research and the problem is that Apache must be run with elevated privileges to bind to port 80. So one solution would be to set Apache to run on another port and forward that port to 80 via iptables. (This may be a last resort but a very messy solution).

Here is what gets me, Apache should be able to maintain its current port bindings and recheck its config files, all I am doing is adding another script alias.

Is there any way to add a new script alias with out a reload?

like image 965
Dan Walmsley Avatar asked Jul 19 '26 04:07

Dan Walmsley


1 Answers

you also have the options to reload the config:

/etc/init.d/httpd reload

or

 apachectl -k graceful

But unfortunately, those need root also. This differs from a normal restart in that currently open connections are not aborted. A side effect is that old log files will not be closed immediately. This means that if used in a log rotation script, a substantial delay may be necessary to ensure that the old log files are closed before processing them.

Also, if running Apache with daemontools you can do this by:

svc -h /service/apache
like image 98
Tudor Constantin Avatar answered Jul 21 '26 00:07

Tudor Constantin