0

How can I auto-start a site when the config file for it is created?

Ubuntu Server 13.10 Apache

Kevin
  • 133
  • 1
  • 2
  • 14

1 Answers1

2

The best option would be to do a graceful restart (service apache2 reload) in order to have the config become active without downtime (the new process takes over the listener while the old process completes any active requests).

To automate this you'd need something watching the files then restarting the service.. probably not worth the effort if you're creating the site files manually.

Instead, consider using some kind of configuration management like Puppet or Chef to manage the site config files, which can then be configured to run that graceful restart every time it changes one of those files.

Shane Madden
  • 114,520
  • 13
  • 181
  • 251
  • The sites files will end up being created automatically, through a PHP script. – Kevin Feb 12 '14 at 20:30
  • 1
    @o7thWebDesign Then either have PHP run the service reload (use `sudoers` to let it mess with the service, but do not let it run any other commands as root), or have something running (could just be a cron job) that will watch for changes in that directory and run the graceful restart if changes are detected? – Shane Madden Feb 12 '14 at 20:33
  • 1
    Don't forget inotify. – user9517 Feb 12 '14 at 20:51