zoukankan      html  css  js  c++  java
  • apache基于域名的虚拟主机配置

    在apache基于域名的虚拟主机配置中,多种方式可以达到相同的目的,在配置过程中将其中一个个人认为比较简单、明了的配置记录下来,以免忘记。

    1、当在一台linux主机里搭建多个站点的,需要有一个默认的站点,在httpd.conf文件中修改添加:

    <VirtualHost _default_:80>
    DocumentRoot /var/www/html
    < /VirtualHost>
    对此页面可以做些处理,尽量不要开启默认站点。

    2、把#NameVirtualHost *:80前面的#去掉,即可开启虚拟主机的功能

    3、接下来可以正式添加虚拟主机了,配置如下,根据自己的要求来配置:

    <VirtualHost *:80>
    ServerAdmin webmaster@.example.com
    DocumentRoot /var/www/ns/
    ServerName ns.example.com
    ErrorLog logs/ns.example.com-error_log
    CustomLog logs/ns.example.com-access_log common
    < /VirtualHost>
    < VirtualHost *:80>
    ServerAdmin webmaster@abc.com
    DocumentRoot /var/www/phpmyadmin
    ServerName www.abc.com
    ErrorLog logs/www.abc.com-error_log
    CustomLog logs/www.abc.com-access_log common
    < /VirtualHost>

    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------

    同时在C:\WINDOWS\system32\drivers\etc\hosts表中设置
    127.0.0.1 localhost
    127.0.0.1 fading.cn
    127.0.0.1 dz6.fading.cn
    127.0.0.1 x.fading.cn
    或者修改DNS,多个域名指向同一个IP地址
    访问路径:
    http://fading.cn或localhost
    http://dz6.fading.cn
    http://x.fading.cn

    别名alias:

    Alias /dz6/ "d:/http/wwwroot/Discuz!_6.0.0_SC_GBK/upload/"
    <Directory "d:/http/wwwroot/Discuz!_6.0.0_SC_GBK/upload">
    Options Indexes MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all
    </Directory>

    Alias /x/ "d:/http/wwwroot/xspace/upload/"
    <Directory "d:/http/wwwroot/xspace/upload">
    Options Indexes MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all
    </Directory>
    访问的时候一定用
    http://localhost/x/ 加上/
    http://localhost/dz6/ 加上/

  • 相关阅读:
    LeetCode: Next Permutation 解题报告
    LeetCode: Subsets 解题报告
    LeetCode: Recover Binary Search Tree 解题报告
    LeetCode: Find Peak Element 解题报告
    LeetCode: Valid Parentheses 解题报告
    LeetCode: First Missing Positive 解题报告
    LeetCode: Best Time to Buy and Sell Stock III 解题报告
    Nginx系列(二)——流量分发管控
    Nginx系列(一)——HTTP/TCP/UDP负载均衡
    运维电子书PDF汇总
  • 原文地址:https://www.cnblogs.com/google4y/p/2149131.html
Copyright © 2011-2022 走看看