码迷,mamicode.com
首页 > Web开发 > 详细

Apache虚拟主机配置

时间:2015-01-15 11:09:44      阅读:152      评论:0      收藏:0      [点我收藏+]

标签:linux

为了方面管理我这里用httpd-vhosts.conf配置文件来配置

  1. 打开[root@apache ~]# vi /usr/local/apache/conf/httpd.conf

  2. 找到Include conf/extra/httpd-vhosts.conf把#去掉使用文件生效

    # Fancy directory listings
    #Include conf/extra/httpd-autoindex.conf

    # Language settings
    #Include conf/extra/httpd-languages.conf

    # User home directories
    #Include conf/extra/httpd-userdir.conf

    # Real-time info on requests and configuration
    #Include conf/extra/httpd-info.conf

    # Virtual hosts
    Include conf/extra/httpd-vhosts.conf

  3. 打开[root@apache ~]# vi /usr/local/apache/conf/extra/httpd-vhosts.conf添加以下内容


    <VirtualHost 172.16.4.59:80>
        ServerAdmin webmaster@dummy-host.example.com
        DocumentRoot "/usr/local/apache/htdocs/www.wys.com"
        ServerName www.wys.com
        ErrorLog "/usr/local/apache/htdocs/www.wys.com/error_log"
        CustomLog "/usr/local/apache/htdocs/www.wys.com/access_log" common
    </VirtualHost>

    <VirtualHost 172.16.4.59:80>
        ServerAdmin webmaster@dummy-host2.example.com
        DocumentRoot "/usr/local/apache/htdocs/www.wys123.com"
        ServerName www.wys123.com
        ErrorLog "/usr/local/apache/htdocs/www.wys123.com/error_log"
        CustomLog "/usr/local/apache/htdocs/www.wys123.com/access_log" common

  4. 重启Apache

  5. 修改hosts文件


    [root@apache ~]# vi /etc/hosts

    127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
    ::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
    127.0.0.1  www.wys123.com
    127.0.0.1  www.wys.com

  6. 浏览器打开www.wys.com是否成功。

  7. 至此结束



Apache虚拟主机配置

标签:linux

原文地址:http://vqiao.blog.51cto.com/9368913/1604151

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!