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

linux系统配置Apache虚拟主机实例

时间:2015-08-01 14:15:23      阅读:125      评论:0      收藏:0      [点我收藏+]

标签:

安装apache,php: yum install httpd php 假设VPS的IP是58.130.17.168,有两个域名指向该IP,分别是domain1.com, domain2.com, 修改/etc/httpd/conf/httpd.conf,在文件的最后加入: ServerName 58.130.17.168 NameVirtualHost 58.130.17.168 &

安装apache,php:
yum install httpd php

假设VPS的IP是58.130.17.168,有两个域名指向该IP,分别是domain1.com, domain2.com,

修改/etc/httpd/conf/httpd.conf,在文件的最后加入:

ServerName 58.130.17.168
NameVirtualHost 58.130.17.168

<VirtualHost 58.130.17.168>
        ServerName domain1.com
        DocumentRoot /var/www/domain1.com
        <Directory "/var/www/domain1.com">
            Options Indexes FollowSymLinks
            AllowOverride None
            Order allow,deny
            Allow from all
        </Directory>
</VirtualHost>

<VirtualHost 58.130.17.168>
        ServerName domain2.com
        DocumentRoot /var/www/domain2.com
        <Directory "/var/www/domain2.com">
            Options Indexes FollowSymLinks
            AllowOverride None
            Order allow,deny
            Allow from all
        </Directory>
</VirtualHost>

然后在/var/www/domain1.com和/var/www/domain2.com下创建不同的index.html文件:
echo "domain1">/var/www/domain1.com/index.html
echo "domain2">/var/www/domain2.com/index.html

在浏览器里输入http://domain1.com和http://domain2.com即可看到效果了

linux系统配置Apache虚拟主机实例

标签:

原文地址:http://www.cnblogs.com/tblog/p/4694012.html

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