zoukankan      html  css  js  c++  java
  • Apache服务器中配置虚拟机的方法

    [root@master conf]# cp httpd.conf httpd.conf.bak      #备份主配置文件。

    基于ip地址的虚拟主机,首先添加一个ens33:0

    [root@master html]# ip addr add 192.168.1.220/24 dev ens33 label ens33:0
    [root@master html]# ip addr show ens33
    2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
        link/ether 00:0c:29:21:e3:49 brd ff:ff:ff:ff:ff:ff
        inet 192.168.1.222/24 brd 192.168.1.255 scope global ens33
           valid_lft forever preferred_lft forever
        inet 192.168.1.220/24 scope global secondary ens33:0
           valid_lft forever preferred_lft forever
        inet6 2409:8a0c:4d:59d0:ade0:f328:b2f5:9e47/64 scope global noprefixroute dynamic 
           valid_lft 86366sec preferred_lft 14366sec
        inet6 fe80::1592:73e7:370e:7e72/64 scope link 
           valid_lft forever preferred_lft forever
    [root@node2 ~]# ping 192.168.1.220
    PING 192.168.1.220 (192.168.1.220) 56(84) bytes of data.
    64 bytes from 192.168.1.220: icmp_seq=1 ttl=64 time=1.28 ms
    64 bytes from 192.168.1.220: icmp_seq=2 ttl=64 time=0.673 ms
    64 bytes from 192.168.1.220: icmp_seq=3 ttl=64 time=0.687 ms
    64 bytes from 192.168.1.220: icmp_seq=4 ttl=64 time=1.06 ms
    ^C
    --- 192.168.1.220 ping statistics ---
    4 packets transmitted, 4 received, 0% packet loss, time 3005ms
    rtt min/avg/max/mdev = 0.673/0.925/1.283/0.260 ms
    [root@master www]# pwd
    /var/www
    [root@master www]# mkdir xdl baidu   在这两个目录下分别创建两个首页文件为index.html
    [root@master www]# cd xdl/
    [root@master xdl]# echo "192.168.1.220" > index.html
    [root@master xdl]# cd ../baidu
    [root@master baidu]# echo "192.168.1.222" > index.html

    修改主配置文件                     

    #DocumentRoot "/var/www/html"        停止中心主机。
    <VirtualHost 192.168.1.220:80>
        DocumentRoot "/var/www/xdl"
    #    ServerName dummy-host2.example.com
    </VirtualHost>
    <Directory "/var/www/xdl">
            Options Indexes FollowSymLinks
            AllowOverride None
            Require all granted
    </Directory>
    IncludeOptional conf.d/*.conf
    <VirtualHost 192.168.1.222:80>
        DocumentRoot "/var/www/baidu"
    #    ServerName dummy-host2.example.com
    </VirtualHost>
    <Directory "/var/www/baidu">
            Options Indexes FollowSymLinks
            AllowOverride None
            Require all granted
    </Directory>

    基于端口的虚拟主机                      

    Listen 8080
    <VirtualHost 192.168.1.222:80>
        DocumentRoot "/var/www/xdl"
    #    ServerName dummy-host2.example.com
    </VirtualHost>
    <Directory "/var/www/xdl">
            Options Indexes FollowSymLinks
            AllowOverride None
            Require all granted
    </Directory>
    IncludeOptional conf.d/*.conf
    <VirtualHost 192.168.1.222:8080>
        DocumentRoot "/var/www/baidu"
    #    ServerName dummy-host2.example.com
    </VirtualHost>
    <Directory "/var/www/baidu">
            Options Indexes FollowSymLinks
            AllowOverride None
            Require all granted
    </Directory>

    基于域名的虚拟化                      

    Listen 8080
    <VirtualHost 192.168.1.222:80>
        DocumentRoot "/var/www/xdl"
        ServerName www.xdl.com
    </VirtualHost>
    <Directory "/var/www/xdl">
            Options Indexes FollowSymLinks
            AllowOverride None
            Require all granted
    </Directory>
    IncludeOptional conf.d/*.conf
    <VirtualHost 192.168.1.222:80>
        DocumentRoot "/var/www/baidu"
        ServerName www.baidu.com
    </VirtualHost>
    <Directory "/var/www/baidu">
            Options Indexes FollowSymLinks
            AllowOverride None
            Require all granted
    </Directory>
  • 相关阅读:
    微软一站式技术框架(AllInOne Code Framework(AIO)) 登陆 MSDN中国首页
    The stepbystep guide of making a C# (or VB.NET) Windows 7 Trigger Start Service
    AllInOne Code Framework: 微软一站式开发技术框架 示例命名规则和目录结构说明
    Windows 7 新特性 Shell Library 编程接口介绍
    一步一步教你如何编写VC#,VB.NET或VC++代码玩转Windows Shell Known Folders
    微软一站式开发技术框架解决方案 年内展望
    AllInOne Code Framework: 微软一站式开发技术框架解决方案 2009730 新增sample code简介
    AllInOne Code Framework: 微软一站式开发技术框架 2009917 新增代码示例简介
    AllInOne Code Framework: 微软一站式开发技术框架解决方案 2009826 新增sample code简介
    微软 AllInOne Code Framework (AIO) 客户端应用程序 期待您的见解
  • 原文地址:https://www.cnblogs.com/liujunjun/p/12012092.html
Copyright © 2011-2022 走看看