zoukankan      html  css  js  c++  java
  • Apache的虚拟主机配置

    使用虚拟主机要先取消中心主机,注释掉DocumentRoot

    #DocumentRoot "/www/htdoc"

    虚拟主机的单独配置:

    • 用户认证
    • 访问日志
    • 错误日志
    • 别名
    • 脚本别名

    一、基于IP的虚拟主机

    一台服务器多个IP地址搭建多个网站

    例如:

    <VirtualHost 10.10.10.201:80>

        DocumentRoot /www/vhost1

        ServerName www.a.com

        ErrorLog logs/vhost1-err.log

        CustomLog logs/vhost1-acc.log combined

    </VirtualHost>

    <VirtualHost 10.10.10.202:80>

        DocumentRoot /www/vhost2

        ServerName www.b.com

        ErrorLog logs/vhost1-err.log

        CustomLog logs/vhost1-acc.log combined

    </VirtualHost>

    二、基于端口号的虚拟主机

    一台服务器一个IP搭建多个网站,每个网站使用不同的端口号访问

    Listen 8081

    Listen 8082

    <VirtualHost 10.10.10.201:8081>

        DocumentRoot /www/vhost1

        ServerName www.a.com

        ErrorLog logs/vhost1-err.log

        CustomLog logs/vhost1-acc.log combined

    </VirtualHost>

    <VirtualHost 10.10.10.201:8082>

        DocumentRoot /www/vhost2

        ServerName www.b.com

        ErrorLog logs/vhost1-err.log

        CustomLog logs/vhost1-acc.log combined

    </VirtualHost>

    三、基于域名(FQDN)的虚拟主机

    一台服务器一个IP搭建多个网站每个网站使用不同的域名访问

    在2.2中如果使用基于FQDN的方式要将NameVirtualHost *:80的注释去掉,并且NameVirtualHost的格式要和VirtualHost中的格式相同:

    <VirtualHost *:80>

        DocumentRoot /www/vhost1

        ServerName www.a.com

        ErrorLog logs/vhost1-err.log

        CustomLog logs/vhost1-acc.log combined

    </VirtualHost>

    <VirtualHost *:80>

        DocumentRoot /www/vhost2

        ServerName www.b.com

        ErrorLog logs/vhost1-err.log

        CustomLog logs/vhost1-acc.log combined

    </VirtualHost>

  • 相关阅读:
    vue 分页 pagination
    查看android 签名文件keystore的有效期限
    cordova + vue 项目实现极光推送功能
    vue window
    input
    vue install 组件
    cordova 的安桌动画
    深度图
    css3 Transition动画执行时有可能会出现闪烁的bug
    windows zip命令
  • 原文地址:https://www.cnblogs.com/fansik/p/5633548.html
Copyright © 2011-2022 走看看