在不重新启动 Apache 的情况下添加或删除或重新加载特定的 VirtualHost(并中断其他 VirtualHosts 的请求)
Add or remove or reload a specific VirtualHost without restarting Apache (and having other VirtualHosts' requests interrupted)
上下文:假设我有这个 /etc/apache2/sites-available/000-default.conf
文件(Debian 9、Apache 2.4):
<VirtualHost *:80>
ServerName example.com
DocumentRoot /var/www/html/site1
</VirtualHost>
并且一些客户当前正在浏览该网站,甚至其中一些正在忙于在该网站上下载一个 1 GB 的文件(假设他们正在下载 www.example.com/bigfile.zip
)。
现在我想添加一个新的 VirtualHost
并将 000-default.conf
文件编辑为(并保存):
<VirtualHost *:80>
ServerName example.com
DocumentRoot /var/www/html/site1
</VirtualHost>
<VirtualHost *:80>
ServerName example2.com
DocumentRoot /var/www/html/site2
</VirtualHost>
现在如果我这样做
service apache2 restart
它将成功启用新网站 example2.com
,但也会停止客户端对 example.com 的所有持续请求,并且会中断例如正在进行的下载。
问题:有没有办法添加一个新的 VirtualHost
并且不中断其他 VirtualHost
正在进行的请求(长时间下载等)?
注:
我已经读过 How to reload apache configuration for a site without restarting apache but the question and answer are not precise about what is the consequences "of not restarting" Apache. The same about Can I “reload” Apache2 configuration file without issues?,我不确定如果从客户端持续下载 20 分钟会发生什么情况。是等还是不等?这里的这个问题特别关注在不破坏其他人的请求的情况下添加新的 VirtualHost。
我也准备了许多类似的问题,但这个问题解决了一个精确的特定要求:安装一个新的 VirtualHost
同时不中断正在进行的请求,例如长时间下载。
重新启动==停止,然后再启动。
改为使用apachectl graceful
。 Graceful 让现有的连接完成,然后在它们被释放时一个接一个地重新启动每个子进程。新连接将获得新配置。
上下文:假设我有这个 /etc/apache2/sites-available/000-default.conf
文件(Debian 9、Apache 2.4):
<VirtualHost *:80>
ServerName example.com
DocumentRoot /var/www/html/site1
</VirtualHost>
并且一些客户当前正在浏览该网站,甚至其中一些正在忙于在该网站上下载一个 1 GB 的文件(假设他们正在下载 www.example.com/bigfile.zip
)。
现在我想添加一个新的 VirtualHost
并将 000-default.conf
文件编辑为(并保存):
<VirtualHost *:80>
ServerName example.com
DocumentRoot /var/www/html/site1
</VirtualHost>
<VirtualHost *:80>
ServerName example2.com
DocumentRoot /var/www/html/site2
</VirtualHost>
现在如果我这样做
service apache2 restart
它将成功启用新网站 example2.com
,但也会停止客户端对 example.com 的所有持续请求,并且会中断例如正在进行的下载。
问题:有没有办法添加一个新的 VirtualHost
并且不中断其他 VirtualHost
正在进行的请求(长时间下载等)?
注:
我已经读过 How to reload apache configuration for a site without restarting apache but the question and answer are not precise about what is the consequences "of not restarting" Apache. The same about Can I “reload” Apache2 configuration file without issues?,我不确定如果从客户端持续下载 20 分钟会发生什么情况。是等还是不等?这里的这个问题特别关注在不破坏其他人的请求的情况下添加新的 VirtualHost。
我也准备了许多类似的问题,但这个问题解决了一个精确的特定要求:安装一个新的
VirtualHost
同时不中断正在进行的请求,例如长时间下载。
重新启动==停止,然后再启动。
改为使用apachectl graceful
。 Graceful 让现有的连接完成,然后在它们被释放时一个接一个地重新启动每个子进程。新连接将获得新配置。