我的服务器信息是
Server version: Apache/2.4.6 (CentOS)
Server built: Nov 19 2015 21:43:13我试图为两个不同的站点配置虚拟主机: biz.example.com和pin.example.com,它们都托管在同一台服务器上。有两个不同的文件夹位于'var/www/html/‘命名'biz’和'pin‘与他们尊重的项目文件,为上述2个网站。我正试图按以下方式配置它。
在下面配置的/etc/主机中
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
xxx.xxx.xxx.xxx biz.example.com
xxx.xxx.xxx.xxx pin.example.comXxx.xxx被服务器IP地址所取代。
在/etc/httpd/conf/httpd.conf内
IncludeOptional sites-enabled/*.conf现在,在/etc/httpd/site下面有biz.conf和pin.conf文件。我还在/etc/httpd下启用了文件夹站点,其中有两个指向站点的biz.conf和pin.conf的文件,可用文件夹使用下面的命令
ln -s /etc/httpd/sites-available/biz.conf /etc/httpd/sites-enabled/biz.conf
ln -s /etc/httpd/sites-available/pin.conf /etc/httpd/sites-enabled/pin.confbiz.conf有以下几个方面
<VirtualHost *:80>
ServerName http://biz.example.com/
ServerAlias http://biz.example.com/
DocumentRoot "/var/www/html/biz"
<directory "/var/www/html/biz">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Allow from 127.0.0.1
</directory>
</VirtualHost>pin.conf文件中的配置被提到为
<VirtualHost *:80>
ServerName http://pin.example.com/
ServerAlias http://pin.example.com/
DocumentRoot "/var/www/html/pin"
<directory "/var/www/html/pin">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Allow from 127.0.0.1
</directory>
</VirtualHost>在这个设置中,如果我尝试访问http://biz.example.com/,正确的网站(biz网站)正在加载。但是如果我试图访问http://pin.example.com/,那么biz网站也是加载而不是pin网站。多个配置不能协同工作。
我还试图将biz.conf和pin.conf的虚拟配置合并到一个文件biz.conf中,但它也不起作用。
发布于 2016-12-16 12:13:18
ServerName指令的语法是:
ServerName [scheme://]domain-name|ip-address[:port]没有尾随的斜线。作为一种副作用,由于ServerName不被识别,所以总是提供第一个VirtualHost。
https://stackoverflow.com/questions/41183714
复制相似问题