apache基于IP的虚拟主机配置方法
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
完成!
六月 20th, 2010 at 06:40
These are very nice tips that I will try out, I am glad I ran into it. Thanks.
七月 9th, 2010 at 00:58
Eat, drink and be merry, for tomorrow we die
五月 26th, 2011 at 00:23
Interesting Posts…
[...]some other related resources on the web that are worth viewing on this subject include[...]…
六月 3rd, 2011 at 02:47
My Recommended Websites…
[...]some new websites on the web we love, even if they are not related to ours. Check them out[...]…