[英]Using apache virtual hosts
我正在尝试使用2个虚拟主机设置我的Apache:
Listen 11.22.33.44:8080
<VirtualHost *>
ServerName servername.com/stable
DocumentRoot /home/deploy/producao/servername.com/current/public
<Directory /home/deploy/producao/servername.com/current/public>
# This relaxes Apache security settings.
AllowOverride all
# MultiViews must be turned off.
Options -MultiViews
</Directory>
</VirtualHost>
<VirtualHost *>
ServerName servername.com/stable
DocumentRoot /home/deploy/teste/servername.com/current/public
<Directory /home/deploy/teste/servername.com/current/public>
# This relaxes Apache security settings.
AllowOverride all
# MultiViews must be turned off.
Options -MultiViews
</Directory>
</VirtualHost>
但是,一切都错了。 我想要的是,当我键入servername.com/stable时,我得到一个文档根目录,而当我使用servername.com/testing时,我得到另一个文档根目录。
我尝试了几件事,但没有任何效果,例如
<VirtualHost servername.com/stable>
<VirtualHost servername.com/testing>
和使用
ServerName servername.com
ServerPath /stable
...
ServerName servername.com
ServerPath /testing
但是这些都不起作用。
您的ServerName
指令不正确。 您只能使用该指令指定DNS主机名,而不能指定服务器路径。 例如
ServerName example.com
ServerName example.net
是正确的。 您只是试图在SAME服务器名称的子目录中托管两个不同的站点。 为此,您不需要两个virtualhost指令。 单个虚拟主机中的一个<Directory>
或<Location>
<VirtualHost *>
ServerName example.com
<Location /site1>
... site1 settings here
</Location>
<Location /site2>
... site2 settings here
</Location>
</VirtualHost>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.