apache多域名配置

要求:2个域名,对应1个ip,也就是一个服务器下2个目录。

跟着网上的教程找到conf.httpd

 

<VirtualHost 101.xxx.xxx.xxx:80>
    DocumentRoot /var/www/html/A
    ServerName www.A.com
   <Directory "/var/www/html/A">
        Options Indexes FollowSymLinks
        AllowOverride None
        Order allow,deny
        Allow from all
   </Directory>
</VirtualHost>


<VirtualHost 101.xxx.xxx.xxx:80>
    DocumentRoot /var/www/html/B
    ServerName www.B.com
   <Directory "/var/www/html/B">
        Options Indexes FollowSymLinks
        AllowOverride None
        Order allow,deny
        Allow from all
   </Directory>
</VirtualHost>

打开 NameVirtualHost 的注释,修改如下:
NameVirtualHost 101.xxx.xxx.xxx:80

 

然后启动httpd的时候  一直警告,
httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain for ServerName
 

解决如下:
 

hostname -f 查看 hostname.
 

然后在httpd.conf最后一行添加
 

ServerName 你的hostname
 

我是这样的:
 

ServerName  localhost:80
 

重启后, 两个域名分别能访问到不同的目录下
 

或者: (未验证)
 

查看 /etc/hosts
 

显示如下:
 

127.0.0.1    localhost.localdomain localhost host.server4-245.com
 

::1          localhost.localdomain localhost host.server4-245.com
 

那么在 httpd.conf 中添加:
 

ServerName host.server4-245.com
 

参考:http://stackoverflow.com/questions/9541460/httpd-could-not-reliably-determine-the-servers-fully-qualified-domain-name-us

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值