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

    Linux下Apache虚拟主机的三种配置。这样可以实现一台主机架构多个独立域名网站。其中基于域名的最为常见。性价比也最高。下面PHP程序员雷雪松详细的讲解下Linux下Apache虚拟主机配置的具体步骤。

    1、基于多ip地址的虚拟主机
    Listen 80
    <VirtualHost 12.34.56.78>
    DocumentRoot /home/httpd/html1
    ServerName www.ok1.com
    ErrorLog /usr/local/apache/logs/error1_log
    CustomLog /usr/local/apache/logs/access1_log combined
    </VirtualHost>
    <VirtualHost 87.65.43.21>
    DocumentRoot /home/httpd/html2
    ServerName www.ok2.com
    ErrorLog /usr/local/apache/logs/error2_log
    CustomLog /usr/local/apache/logs/access2_log combined
    </VirtualHost>

    2、基于多IP 和多端口的虚拟主机配置
    Listen 12.34.56.78:80
    Listen 12.34.56.78:8080
    Listen 87.65.43.21:80
    Listen 87.65.43.21:8080

    <VirtualHost 12.34.56.78:80>
    DocumentRoot /www/example1-80
    ServerName www.example1.com
    </VirtualHost>
    <VirtualHost 12.34.56.78:8080>

    DocumentRoot /www/example1-8080
    ServerName www.example1.com
    </VirtualHost>
    <VirtualHost 87.65.43.21:80>
    DocumentRoot /www/example2-80
    ServerName www.example1.org
    </VirtualHost>
    <VirtualHost 87.65.43.21:8080>
    DocumentRoot /www/example2-8080
    ServerName www.example2.org
    </VirtualHost>

    3、单个IP 地址的服务器上基于域名的虚拟主机配置
    # Ensure that Apache listens on port 80
    Listen 80
    # Listen for virtual host requests on all IP addresses
    NameVirtualHost *:80
    <VirtualHost *:80>
    DocumentRoot /www/example1
    ServerName www.example1.com
    ServerAlias example1.com. *.example1.com
    # Other directives here
    </VirtualHost>
    <VirtualHost *:80>
    DocumentRoot /www/example2
    ServerName www.example2.org
    # Other directives here
    </VirtualHost>

    来源:Linux下Apache虚拟主机配置

  • 相关阅读:
    2019.10.11CSS
    2019.10.11 THML
    虚拟机FAQ
    thinkpad安装虚拟机 开启虚拟功能要在bios的security里面设置
    JDK在windows系统下环境变量的设置
    有关operamasks-ui的一些信息汇总
    从用List给ArrayList赋值看容器的传值,最好用.addAll
    给eclipse安装svn插件
    Java接口 枚举型Enumeration
    linux下的grep命令
  • 原文地址:https://www.cnblogs.com/leixuesong/p/11339018.html
Copyright © 2011-2022 走看看