mkdir /data/site{1,2,3}
echo ‘www.a.com‘ > /data/site1/index.HTML
echo ‘www.b.com‘ > /data/site2/index.HTML
echo ‘www.c.com‘ > /data/site3/index.HTML
vim /etc/httpd/conf.d/vhosts.conf
Listen 8001 Listen 8002 Listen 8003 <virtualhost *:8001> documentroot /data/site1 <directory /data/site1> require all granted </directory> </virtualhost> <virtualhost *:8002> <directory /data/site2> require all granted</directory> documentroot /data/site2 </virtualhost> <virtualhost *:8003> <directory /data/site3> require all granted </directory> documentroot /data/site3 </virtualhost>实验:基于ip的多虚拟主机 1.给单个网卡绑定多个ip地址
ip a a 192.168.36.8/24 dev eth0
ip a a 192.168.36.9/24 dev eth0
vim /etc/httpd/conf.d/vhosts.conf
<virtualhost 192.168.36.7:80> documentroot /data/site1 <directory /data/site1> require all granted </directory> </virtualhost> <virtualhost 192.168.36.8:80> <directory /data/site2> require all granted </directory> documentroot /data/site2 </virtualhost> <virtualhost 192.168.36.9:80> <directory /data/site3> require all granted </directory> documentroot /data/site3 </virtualhost>实验:基于主机头的多虚拟主机 1.修改配置文件
vim /etc/httpd/conf.d/vhosts.conf <virtualhost *:80>documentroot /data/site1servername www.a.com<directory /data/site1>require all granted</directory>CustomLog "logs/a_access_log" combined</virtualhost><virtualhost *:80><directory /data/site2> require all granted</directory>documentroot /data/site2servername www.b.comCustomLog "logs/b_access_log" combined</virtualhost><virtualhost *:80>servername www.c.com<directory /data/site3> require all granted</directory>documentroot /data/site3CustomLog "logs/c_access_log" combined</virtualhost>2.在测试机hosts文件中添加名词解析
vim /etc/hosts
192.168.36.7 www.a.com www.b.com www.c.com
以上是内存溢出为你收集整理的基于PORT、ip和主机头的多虚拟主机全部内容,希望文章能够帮你解决基于PORT、ip和主机头的多虚拟主机所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)