zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    eclipse中注释模板的修改
    Oracle 解锁Record is locked by another user
    Oracle 解锁Record is locked by another user
    提高网站速度的最佳实践
    Tomcat中配置SSL
    CentOS QQ
    csshack
    文件contentType
    JavaScript实现Iframe自适应其加载的内容高度
    转timer
  • 原文地址:https://www.cnblogs.com/thewindkee/p/12873258.html
Copyright © 2011-2022 走看看