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.

To avoid Apache restart, Dynamically Configured Mass Virtual Hosting is used. But, --in this case-- Apache takes vhost configurations from directory pattern. So, I am not free to choose DocumentRoot directory which doesn't match with selected pattern. For example, if I have set pattern like ...user/www/domain/subdomain, I will have to create directories like the pattern to add a domain/subdomain as vhost.

But, cPanel allows its users to freely choose DocumentRoot for add-on domains & subdomains they add. And, it doesn't restart Apache each time a change is made. Changes are instantaneous too.

What does cPanel exactly do to Apache configurations?
I've guessed that it has to do with the same Dynamically Configured Mass Virtual Hosting, but I've given up after few days of brainstorming. Can you please help?

share|improve this question
1  
If I had to guess I'd say it's sending Apache a USR1 signal, to gracefully restart with no loss of service. I don't have an install with which to verify, but you should be able to confirm by checking the Apache logs. –  Shane Madden Feb 11 '12 at 20:39
    
@ShaneMadden You are saying to add vhosts in httpd.conf or httpd-vhosts.conf and then restart Apache with USR1 signal. Do you really think it would work? I think, service will have to lose its state to read configuration file.. think if it has thousands of vhosts (making file big). –  Sachin Shekhar Feb 11 '12 at 21:16
    
A graceful restart can take as long as it needs to without disrupting service at all. Again, I'm not certain that this is how it's doing it, but you can easily confirm by checking the log. –  Shane Madden Feb 11 '12 at 22:24
add comment

1 Answer

up vote 0 down vote accepted

Finally, I have found solution. To avoid restart, I don't need Dynamically Configured Mass Virtual Hosting (its always better to think in simple way, first). Apache provides apachectl for this task. On Debian 6, its binary was /usr/sbin/apachectl with default apt-get based installation. It may vary from system-to-system. If you compile & install Apache from its source, it should be in your control.
Assuming location of apachectl binary is in your PATH variable, this command does what I need:

apachectl graceful

It restarts web server without terminating current connections to server. Means, its just like reloading configuration files without restart. I don't know how cPanel exactly does it, but it works.

share|improve this answer
add comment

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.