apache基于端口創(chuàng)建虛擬主機的示例
發(fā)布日期:2021-12-21 17:22 | 文章來源:站長之家
apache:基于端口創(chuàng)建虛擬主機
以創(chuàng)建虛擬主機(a,b,c)為例子
1)2.1.2禁用默認的主機模式
[root@localhost httpd]# vim /etc/httpd/conf/httpd.conf 在主配置文件里面注釋下面這行內(nèi)容 #DocumentRoot "/var/www/html"
2)在主配置文件添加監(jiān)聽端口
找到Listen行,在原有行Listen 80行的基礎(chǔ)上, 在添加一行 Listen 8080 Listen 81
3)添加端口配置虛擬
[root@localhost httpd]#vim /etc/httpd/conf.d/virtualhost.conf <VirtualHost 192.168.87.131:80> DocumentRoot "/var/www/a" ServerName www.a.com </VirtualHost> <VirtualHost 192.168.87.131:8080> DocumentRoot "/var/www/b" ServerName www.b.com </VirtualHost> <VirtualHost 192.168.87.131:81 DocumentRoot "/var/www/c" ServerName www.c.com </VirtualHost>
4)創(chuàng)建新目錄
[root@localhost conf.d]# cd/var/www [root@localhost www]# mkdir a b c [root@localhost www]# echo welcome to www.a.com >> ./a/index.html [root@localhost www]# echo welcome to www.b.com >> ./b/index.html [root@localhost www]# echo welcome to www.c.com >> ./c/index.html
5)重啟httpd
[root@localhost ~]#systemctl restart httpd
注意:一定要重啟httpd!!!
最后效果:
到此這篇關(guān)于apache基于端口創(chuàng)建虛擬主機的示例的文章就介紹到這了,更多相關(guān)apache端口創(chuàng)建虛擬主機內(nèi)容請搜索本站以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持本站!
版權(quán)聲明:本站文章來源標注為YINGSOO的內(nèi)容版權(quán)均為本站所有,歡迎引用、轉(zhuǎn)載,請保持原文完整并注明來源及原文鏈接。禁止復(fù)制或仿造本網(wǎng)站,禁止在非www.sddonglingsh.com所屬的服務(wù)器上建立鏡像,否則將依法追究法律責任。本站部分內(nèi)容來源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來,僅供學習參考,不代表本站立場,如有內(nèi)容涉嫌侵權(quán),請聯(lián)系alex-e#qq.com處理。
相關(guān)文章