Let's assume I have multiple domains pointing to one server. I know that I can have multiple virtual hosts in Apache for example, but every time I want to add a new website I have to change the configuration and restart the server.
I am looking for hosting multiple domain names without having to create a config file each time. Why ? because after creating a config file, I have then to restart the HTTP server which means that each domain I add will block all the other domains for a period of time.
Basically I want a config or program that points dynamically each domain to a sub-folder of my main source code without having to create a config file or restarting the HTTP server.
Please let me know if this is doable with the current HTTP servers or if not point me to some resources that will help me do this programatically.
With most standard web servers you simply cannot do this without a restart or at least reload of the service (so it picks up the new configs).
Of course you could build your own solution, based on your requirements.
You can reload the server without restart it, a reload keep the active connections up, so you can load the changes in your configuration without restarting the server.
Command for nginx:
nginx -s reload
I suggest to use
nginx -t && nginx -s reload in order to check the configuration before reloading
Command for Apache:
apachectl -k graceful,
systemctl reload httpd.service,
service apache2 reload,
service httpd reload (it depends on your environment)