apache:基于端口創(chuàng )建虛擬主機
以創(chuàng )建虛擬主機(a,b,c)為例子
1)2.1.2禁用默認的主機模式
[root@localhost httpd]# vim /etc/httpd/conf/httpd.conf 在主配置文件里面注釋下面這行內容 #DocumentRoot "/var/www/html"
2)在主配置文件添加監聽(tīng)端口
找到Listen行,在原有行Listen 80行的基礎上, 在添加一行 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 )建虛擬主機內容請搜索腳本之家以前的文章或繼續瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng )、來(lái)自本網(wǎng)站內容采集于網(wǎng)絡(luò )互聯(lián)網(wǎng)轉載等其它媒體和分享為主,內容觀(guān)點(diǎn)不代表本網(wǎng)站立場(chǎng),如侵犯了原作者的版權,請告知一經(jīng)查實(shí),將立刻刪除涉嫌侵權內容,聯(lián)系我們QQ:712375056,同時(shí)歡迎投稿傳遞力量。
Copyright ? 2009-2022 56dr.com. All Rights Reserved. 特網(wǎng)科技 特網(wǎng)云 版權所有 特網(wǎng)科技 粵ICP備16109289號
域名注冊服務(wù)機構:阿里云計算有限公司(萬(wàn)網(wǎng)) 域名服務(wù)機構:煙臺帝思普網(wǎng)絡(luò )科技有限公司(DNSPod) CDN服務(wù):阿里云計算有限公司 百度云 中國互聯(lián)網(wǎng)舉報中心 增值電信業(yè)務(wù)經(jīng)營(yíng)許可證B2
建議您使用Chrome、Firefox、Edge、IE10及以上版本和360等主流瀏覽器瀏覽本網(wǎng)站