apache基于IP的虚拟主机配置方法

五月 10th, 2010 Posted in Apache | 阅读次数: 216 次

Author:gaojinbo

Time:2010-5-10

我们很多时候需要配置apache虚拟主机,以下文档可以很方便地配置出自己想要的虚拟主机,以下方法仅供大家参考!apache虚拟主机配置

基于IP的虚拟主机

1)不同IP地址的配置:
cd /etc/sysconfig/network-scripts
cp ifcfg-eth0 ifcfg-eth0:1
vi ifcfg-eth0:1
更改为:
DEVICE=eth0:1
ONBOOT=YES
BOOTPROTO=static
IPADDR=192.168.0.2
NETMASK=255.255.255.0

 

2)service network restart

 

3)vi /etc/httpd/conf/httpd.conf

 

4)更改虚拟主机部分为:
<VirtualHost 192.168.0.1:80>
DocumentRoot /var/www/html/website1
</VirtualHost>
<VirtualHost 192.168.0.2:80>
DocumentRoot /var/www/html/website2
</VirtualHost>

 

5)创建目录以及页面文件:
mkdir –p /var/www/html/website1
mkdir –p /var/www/html/website2
cd /var/www/html/website1
echo “website1” >index.html

cd /var/www/html/website2
echo “website2” >index.html

 

6.完成以上设置后,可以通过以下方式访问:
1)打开浏览器
2)输入http://192.168.0.1以及http://192.168.0.2

 

完成!

相关日志:

Tags:

4 Responses to “apache基于IP的虚拟主机配置方法”

  1. Exclusive Eat Says:

    These are very nice tips that I will try out, I am glad I ran into it. Thanks.


  2. Flirting Tips For Girls Says:

    Eat, drink and be merry, for tomorrow we die


  3. Related Resources Says:

    Interesting Posts…

    [...]some other related resources on the web that are worth viewing on this subject include[...]…


  4. Resources Says:

    My Recommended Websites…

    [...]some new websites on the web we love, even if they are not related to ours. Check them out[...]…


留下您的脚印