简体   繁体   English

使用apache虚拟主机

[英]Using apache virtual hosts

i am trying to set up my apache with 2 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>

But all is wrong. 但是,一切都错了。 What i want is, when i type servername.com/stable i get one document root and when i use servername.com/testing i get onother one. 我想要的是,当我键入servername.com/stable时,我得到一个文档根目录,而当我使用servername.com/testing时,我得到另一个文档根目录。

I tryed several things but none work, like 我尝试了几件事,但没有任何效果,例如

<VirtualHost servername.com/stable>
<VirtualHost servername.com/testing>

and using 和使用

ServerName servername.com
ServerPath /stable
...
ServerName servername.com
ServerPath /testing

But none of this works. 但是这些都不起作用。

Your ServerName directives are incorrect. 您的ServerName指令不正确。 You can only specify a DNS hostname with that directive, NOT a server path. 您只能使用该指令指定DNS主机名,而不能指定服务器路径。 eg 例如

ServerName example.com
ServerName example.net

would be correct. 是正确的。 You're just trying to host two different sites in subdirectories of the SAME server name. 您只是试图在SAME服务器名称的子目录中托管两个不同的站点。 For that, you don't need two virtualhost directives. 为此,您不需要两个virtualhost指令。 Just a <Directory> or <Location> within a single vhost, eg 单个虚拟主机中的一个<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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM