Score:0

How to load new Apache site without effecting existing sites?

in flag

If I add a new Apache site at /etc/apache2/sites-enabled/newsite.conf, how to I load that new configuration without bringing down any other sites currently being hosted by Apache?

As far as I know, sudo apachectl graceful and sudo service apache2 restart and sudo service apache2 reload all cause a brief outage to all sites, with the outage being shorter for reload.

djdomi avatar
za flag
apache2ctl has a config test
in flag
@djdomi But that doesn't load the new config, right? I want to make the new site hosted and available on the network.
jp flag
`apachectl graceful` isn't supposed to cause any downtime. `service apache2 reload` internally calls `apachectl graceful` also.
Score:1
hm flag

As per best practice do the following when you add a new website:

  1. Place the config file under /etc/apache2/sites-available in your example newsite.conf.
  2. "Enable" the websitee, run the command: a2ensite newsite
  3. Test your config, run the command apache2ctl configtest
  4. at last reload the config: service apache2 reload

This won't cause an outage for other running websites. You did everything you can to avoid taking down the webserver. apache2ctl configtest will let you know if you did syntax error or a module you want to use in the config is not loaded yet, or the path you defined to an ssl certificate is not valid. Any open session from the clients will stay open. Although you do all necessary steps to avoid taking down the webserver, it can very well happen in case for instance an ssl certificate is not in a correct format, unfortunately apache2ctl configtest can't protect you from that.

I hope my answer helps!

djdomi avatar
za flag
reload will crash if configtest was failing
jp flag
@djdomi reload internally calls `apachectl graceful` which, in turn, does `apache configtest` before doing a graceful restart. if `configtest` fails then reload isn't performed, an error message is printed and apache continues running with the old config without a reload.
djdomi avatar
za flag
in my experience of years with apache, reload will crash apache could ve that the behavior has changed but for years it crashed on config test failure
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.