您好,登錄后才能下訂單哦!
這篇文章將為大家詳細(xì)講解有關(guān)apache基于ip如何配置虛擬主機(jī),小編覺(jué)得挺實(shí)用的,因此分享給大家做個(gè)參考,希望大家閱讀完這篇文章后可以有所收獲。
首先我們用記事本打開(kāi)httpd.conf文件 ,該文件在apache的目錄下,如: D:\AppServ\Apache2.2\conf,修改如下兩處:
(推薦學(xué)習(xí):apache從入門(mén)到精通)
LoadModule vhost_alias_module modules/mod_vhost_alias.so //去掉前面的#,意思是啟用apache的虛擬主機(jī)功能,第203行
Include conf/extra/httpd-vhosts.conf //去掉#的意思是從httpd-vhosts.conf這個(gè)文件導(dǎo)入虛擬主機(jī)配置
配置虛擬主機(jī)后,不能用localhost 訪問(wèn),只需要把httpd.conf文件的ServerName localhost:80 那行注釋掉就可以了。
基于IP
1、假設(shè)服務(wù)器有個(gè)IP地址為192.168.1.10,使用ifconfig在同一個(gè)網(wǎng)絡(luò)接口eth0上綁定3個(gè)IP:
[root@localhost root]# ifconfig eth0:1 192.168.1.11 [root@localhost root]# ifconfig eth0:2 192.168.1.12 [root@localhost root]# ifconfig eth0:3 192.168.1.13
2、修改hosts文件,添加三個(gè)域名與之一一對(duì)應(yīng):
192.168.1.11 www.test1.com 192.168.1.12 www.test2.com 192.168.1.13 www.test3.com
3、建立虛擬主機(jī)存放網(wǎng)頁(yè)的根目錄,如在/www目錄下建立test1、test2、test3文件夾,其中分別存放1.html、2.html、3.html
/www/test1/1.html /www/test2/2.html /www/test3/3.html
4、在httpd.conf中將附加配置文件httpd-vhosts.conf包含進(jìn)來(lái),接著在httpd-vhosts.conf中寫(xiě)入如下配置:
<VirtualHost 192.168.1.11:80> ServerName www.test1.com DocumentRoot /www/test1/ <Directory "/www/test1"> Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow From All </Directory> </VirtualHost> <VirtualHost 192.168.1.12:80> ServerName www.test1.com DocumentRoot /www/test2/ <Directory "/www/test2"> Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow From All </Directory> </VirtualHost> <VirtualHost 192.168.1.13:80> ServerName www.test1.com DocumentRoot /www/test3/ <Directory "/www/test3"> Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow From All </Directory> </VirtualHost>
關(guān)于apache基于ip如何配置虛擬主機(jī)就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,可以學(xué)到更多知識(shí)。如果覺(jué)得文章不錯(cuò),可以把它分享出去讓更多的人看到。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。
億速云公眾號(hào)
手機(jī)網(wǎng)站二維碼
Copyright ? Yisu Cloud Ltd. All Rights Reserved. 2018 版權(quán)所有
廣州億速云計(jì)算有限公司粵ICP備17096448號(hào)-1 粵公網(wǎng)安備 44010402001142號(hào)增值電信業(yè)務(wù)經(jīng)營(yíng)許可證編號(hào):B1-20181529