在Apache上添加新的虚拟主机而不重新启动服务器?
我已经让Apache正常工作,虚拟主机按预期工作。 我的操作系统是Windows7 然而,我有一个问题,我正试图找到答案,谷歌并没有做出多大让步——不管怎么说,对于Windows,只有Linux(在这种情况下并不适用) 如何添加新的VirtualHost而不经常重新启动服务器 (我目前正在运行的是Apache 2.2版) 我将新主机添加到主机文件和vhost中的文件,如下所示:在Apache上添加新的虚拟主机而不重新启动服务器?,apache,dns,config,virtualhost,vhosts,Apache,Dns,Config,Virtualhost,Vhosts,我已经让Apache正常工作,虚拟主机按预期工作。 我的操作系统是Windows7 然而,我有一个问题,我正试图找到答案,谷歌并没有做出多大让步——不管怎么说,对于Windows,只有Linux(在这种情况下并不适用) 如何添加新的VirtualHost而不经常重新启动服务器 (我目前正在运行的是Apache 2.2版) 我将新主机添加到主机文件和vhost中的文件,如下所示: <VirtualHost *:80> ServerName host1.tld ServerAlias
<VirtualHost *:80>
ServerName host1.tld
ServerAlias www.host1.tld
DocumentRoot /www/vhosts/host1.tld
ErrorLog /www/Apache22/logs/error.log
<Directory "/www/vhosts/host1.tld">
Options All
AllowOverride All
order allow,deny
allow from all
</Directory>
ServerName host1.tld
ServerAlias www.host1.tld
DocumentRoot/www/vhosts/host1.tld
ErrorLog/www/Apache22/logs/error.log
选项全部
允许超越所有
命令允许,拒绝
通融
服务器名mywebsite.com
ServerAlias www.mywebsite.com
DocumentRoot/www/vhosts/mywebsite.com
ErrorLog/www/Apache22/logs/error.log
选项全部
允许超越所有
命令允许,拒绝
通融
是否有人使用过类似的解决方案,如果有,您有什么建议?您可以在不重新启动服务器的情况下重新启动apache。我的mac电脑上有一个苹果脚本,可以为我重新启动apache,这样只需单击一下,四分之一秒,就可以加载新的apache配置。以下是可以轻松移植到Python(供Windows使用)的apple脚本:
您可以使用一个块配置所有vhost
UseCononicalName关闭
VirtualDocumentRoot/www/vhosts/%0
ErrorLog/www/Apache22/logs/error.log
选项全部
允许超越所有
命令允许,拒绝
通融
重新启动Web服务器有什么问题?对于承载许多站点的大型系统,不能因为我们想更改一个站点而在其他站点上停机。我认为“重新启动服务器”实际上是指“重新启动Web服务器”(即Apache)。我找到了我的解决方案,httpd-k restart。谢谢大家!
<VirtualHost *:80>
ServerName mywebsite.com
ServerAlias www.mywebsite.com
DocumentRoot /www/vhosts/mywebsite.com
ErrorLog /www/Apache22/logs/error.log
<Directory "/www/vhosts/mywebsite.com">
Options All
AllowOverride All
order allow,deny
allow from all
</Directory>
set stopString to do shell script "sudo /usr/local/apache2/bin/apachectl stop" with administrator privileges and password
set startString to do shell script "sudo /usr/local/apache2/bin/apachectl start" with administrator privileges and password
if startString as string = "" then
"Apache started correctly"
else
stopString & " , " & startString
end if
<VirtualHost *:80>
UseCanonicalName Off
VirtualDocumentRoot /www/vhosts/%0
ErrorLog /www/Apache22/logs/error.log
<Directory "/www/vhosts">
Options All
AllowOverride All
order allow,deny
allow from all
</Directory>