0

我想设置以下结构: staging.mydomain.com/client/projectname production.mydomain.com/client/projectname

对于新项目,我在 /home/-文件夹中创建以下文件夹:

  • “客户名称”-文件夹
    • “项目名称”-文件夹
      • 暂存文件夹
      • 生产文件夹

我制作了一个使用“a2ensite”启用的文件,包括下面显示的内容。

它与 clientA 一起用于“生产”和“登台”工作正常,但当然 clientB 不会工作,因为它类似于被 clientA 覆盖,对吧?

<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>
4

1 回答 1

0

它与 clientA 一起用于“生产”和“登台”工作正常,但当然 clientB 不会工作,因为它类似于被 clientA 覆盖,对吧?

好吧,您为相同的服务器名称定义了 2 个虚拟主机:

<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”的虚拟主机,同样适用于“production.mydomain.com”

当您定义这些虚拟主机并定义它们时,ServerName它托管的主机称为“staging.mydomain.com”

当您键入http://staging.mydomain.com/时,您希望它转到哪个虚拟主机?其中有 2 个声称托管该主机名。你必须给这些虚拟主机不同的名字。

于 2012-08-23T07:54:04.493 回答