我想设置以下结构: staging.mydomain.com/client/projectname production.mydomain.com/client/projectname
对于新项目,我在/ home / -folder中创建以下文件夹:
我创建了一个用“a2ensite”启用的文件,包括下面显示的内容。
它与clientA的“生产”和“暂存”一起正常工作,但当然clientB不会工作,因为它被客户端A覆盖了,对吗?
<VirtualHost *:80>
ServerName www.mydomain.com
ServerAlias mydomain.com
DirectoryIndex index.html index.php
DocumentRoot /home/mysite
</VirtualHost>
<VirtualHost *:80>
ServerName production.mydomain.com
ServerAlias production.mydomain.com
DirectoryIndex index.html index.php
DocumentRoot /home/clientA/projectA/production
Alias /clientA/projectA /home/clientA/projectA/production
</VirtualHost>
<VirtualHost *:80>
ServerName staging.mydomain.com
ServerAlias staging.mydomain.com
DirectoryIndex index.html index.php
DocumentRoot /home/clientA/projectA/staging
Alias /clientA/projectA /home/clientA/projectA/staging
</VirtualHost>
<VirtualHost *:80>
ServerName production.mydomain.com
ServerAlias production.mydomain.com
DirectoryIndex index.html index.php
DocumentRoot /home/clientB/projectA/production
Alias /clientB/projectA /home/clientB/projectA/production
</VirtualHost>
<VirtualHost *:80>
ServerName staging.mydomain.com
ServerAlias staging.mydomain.com
DirectoryIndex index.html index.php
DocumentRoot /home/clientB/projectA/staging
Alias /clientB/projectA /home/clientB/projectA/staging
</VirtualHost>
答案 0 :(得分:0)
它与clientA的“生产”和“暂存”一起正常工作,但当然clientB不会工作,因为它被客户端A覆盖了,对吗?
嗯,您为同一服务器名定义了2个vhost:
<VirtualHost *:80>
ServerName staging.mydomain.com
ServerAlias staging.mydomain.com
DirectoryIndex index.html index.php
DocumentRoot /home/clientA/projectA/staging
Alias /clientA/projectA /home/clientA/projectA/staging
</VirtualHost>
和
<VirtualHost *:80>
ServerName staging.mydomain.com
ServerAlias staging.mydomain.com
DirectoryIndex index.html index.php
DocumentRoot /home/clientB/projectA/staging
Alias /clientB/projectA /home/clientB/projectA/staging
</VirtualHost>
第二个将被忽略,因为你已经为服务器“staging.mydomain.com”提供了一个vhost,同样也为“production.mydomain.com”提供了
定义这些vhost时,定义它们以使其所托管的ServerName
称为“staging.mydomain.com”
当您键入http://staging.mydomain.com/
时,您希望它转到哪个vhost?其中有两个声称拥有该主机名。你必须给这些vhost不同的名字。