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.

When I read tutorial on how to create /add virtual hosts, the last sentence is always something like:

... now restart apache and you are done!

Now, many (most|all) web hosts have a panel that allow you to create new virtual hosts which are activated almost instantly... and I am sure they didn't restart apache (inconveniencing hundreds of other users) just for my pleasure!

So how to change apache settings / adding virtual hosts, etc. and reloading the new settings without actually restarting the apache server?

share|improve this question
add comment

2 Answers

up vote 9 down vote accepted
$ /etc/init.d/httpd reload

This will run a config syntax check and then will make apache reload its config files without interrupting traffic.

share|improve this answer
    
Oh, cool! I new about the start|stop|restart options, but not about the reload one. Thanks. –  augustin Aug 28 '10 at 15:43
1  
Some change also requires force-reload rather than reload. –  ℝaphink Aug 28 '10 at 16:11
2  
and make sure you do a: service httpd configtest before your reload - it won't get all config errors, but it catches some. –  Jason Tan Aug 28 '10 at 19:01
1  
@Jason, at least on Debian/Ubuntu, the above command runs a config test (and ensures that it exits cleanly) before issuing the apache2ctl graceful. –  EEAA Aug 29 '10 at 0:06
add comment

Most linux distros have a small utility called apachectl or apache2ctl, which you can use to just reload the configuration. This will also activate any new virtual hosts. The command you are looking for is apache2ctl graceful

share|improve this answer
    
Thanks. I'll certainly check them out. How does this compare to the other solution: <code>$ /etc/init.d/httpd reload </code> –  augustin Aug 28 '10 at 15:44
3  
@augustin: the init script is a wrapper around apache2ctl. I would rather use the init script because it might also launch apache2 as a specific user, which you'd have to know in order to use apache2ctl. Trust in the tools that come with your distribution :-) –  ℝaphink Aug 28 '10 at 16:17
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.