• 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

  • 相关阅读:
    【VUE】5.路由导航守卫
    【VUE】4.配置axios发起请求
    【VUE】3.表单操作
    【GIT】命令笔记
    【VUE】2.渲染组件&重定向路由
    【Vue】1.前端项目初始化
    【PYTHON】操作excel笔记
    【Python】python 入门与进阶
    【flask-migrate】:ERROR [root] Error: Target database is not up to date.
    【Flask】学习笔记(一)入门
  • 原文地址:https://www.cnblogs.com/thewindkee/p/12873258.html
Copyright © 2020-2023  润新知