apache基于端口創(chuàng)建虛擬主機(jī)的示例
apache:基于端口創(chuàng)建虛擬主機(jī)
以創(chuàng)建虛擬主機(jī)(a,b,c)為例子
1)2.1.2禁用默認(rèn)的主機(jī)模式
[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)建虛擬主機(jī)的示例的文章就介紹到這了,更多相關(guān)apache端口創(chuàng)建虛擬主機(jī)內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Linux下實(shí)現(xiàn)定時(shí)器Timer的幾種方法總結(jié)
下面小編就為大家?guī)?lái)一篇Linux下實(shí)現(xiàn)定時(shí)器Timer的幾種方法總結(jié)。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2016-10-10Linux配置防火墻,開啟80、3306端口的實(shí)例方法
在本篇文章里小編給大家整理的是關(guān)于Linux配置防火墻,開啟80端口、3306端口的相關(guān)內(nèi)容,需要的朋友們參考下。2020-02-02詳解如何在 CentOS 7 中安裝或升級(jí)最新的內(nèi)核
這篇文章主要介紹了詳解如何在 CentOS 7 中安裝或升級(jí)最新的內(nèi)核,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下。2017-03-03linux中g(shù)rep命令使用實(shí)戰(zhàn)詳解
這篇文章主要介紹了linux中g(shù)rep命令使用實(shí)戰(zhàn)詳解的相關(guān)資料,需要的朋友可以參考下2023-02-02使用CDN之后APACHE日志記錄中IP地址不正確的解決方案
這篇文章主要介紹了使用CDN之后APACHE日志記錄中IP地址不正確的解決方案,需要的朋友可以參考下2014-12-12