美文网首页
apache-虚拟主机

apache-虚拟主机

作者: 16325 | 来源:发表于2020-03-12 01:11 被阅读0次

    apche支持3种类型虚拟主机:
    基于IP的虚拟主机
    基于端口的虚拟主机
    基于主机名的虚拟主机

    一、基于IP虚拟主机

    [root@localhost conf.d]# vi virtualhost.conf
    <Directory "/data">
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
    </Directory>
    
    <VirtualHost 192.168.95.10:80>
    DocumentRoot /data/web1
    ServerName 192.168.95.10
    ErrorLog /data/web1/logs/error_log
    CustomLog /data/web1/logs/access_log combined
    </VirtualHost>
    
    <VirtualHost 192.168.95.11:80>
    DocumentRoot /data/web2
    ServerName 192.168.95.11
    ErrorLog /data/web2/logs/error_log
    CustomLog /data/web2/logs/access_log combined
    </VirtualHost>
    
    

    二、基于端口

    1、修改主配置文件
    #Listen 80
    Listen 192.168.95.11:80
    Listen 192.168.95.11:81

    2、修改虚拟主机文件

    <Directory "/data">
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
    </Directory>
    <VirtualHost 192.168.95.11:80>
    DocumentRoot /data/web1
    ServerName 192.168.95.11
    ErrorLog /data/web1/logs/error_log
    CustomLog /data/web1/logs/access_log combined
    </VirtualHost>
    
    <VirtualHost 192.168.95.11:81>
    DocumentRoot /data/web2
    ServerName 192.168.95.11
    ErrorLog /data/web2/logs/error_log
    CustomLog /data/web2/logs/access_log combined
    </VirtualHost>
    

    三、基于名称的虚拟主机

    <Directory "/data">
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
    </Directory>
    <VirtualHost 192.168.95.11:80>
    DocumentRoot /data/web1
    ServerName [www.uplook.com](http://www.uplook.com/)
    ErrorLog /data/web1/logs/error_log
    CustomLog /data/web1/logs/access_log combined
    </VirtualHost>
    
    <VirtualHost 192.168.95.11:80>
    DocumentRoot /data/web2
    ServerName [www.uplooking.com](http://www.uplooking.com/)
    ErrorLog /data/web2/logs/error_log
    CustomLog /data/web2/logs/access_log combined
    </VirtualHost>
    
    

    相关文章

      网友评论

          本文标题:apache-虚拟主机

          本文链接:https://www.haomeiwen.com/subject/euvljhtx.html