Apache服務(wù)器一個(gè)IP多個(gè)站點(diǎn)的配置方法示例
在日常的網(wǎng)站發(fā)布中很多情況下都無(wú)法做到一個(gè)IP對(duì)應(yīng)一個(gè)站點(diǎn),在IP4的情況下IP的資源是相對(duì)有限的。然而作為最流行的Apache自然也考慮到這種情況,那么接下來(lái)看看apache服務(wù)器怎么配置一個(gè)IP多個(gè)站點(diǎn)。
在httpd.conf中找到 "# Virtual hosts",并添加如下行
ServerName 你的域名
HostNameLookups off
例子
NameVirtualHost 192.168.1.104 <VirtualHost 192.168.1.104> ServerName www.php.com ServerAdmin test@gmail.com DocumentRoot /data/www1/ DirectoryIndex index.php index.html index.htm index.shtml Errorlog /usr/local/apache2/logs/wwwError_log Loglevel warn HostNameLookups off <Directory /data/www1/> AllowOverride None Order allow,deny Allow from all </Directory> </VirtualHost> <VirtualHost 192.168.1.104> ServerName bbs.php.com ServerAdmin test@gmail.com DocumentRoot /data/www2/ DirectoryIndex index.php index.html index.htm index.shtml Errorlog /usr/local/apache2/logs/bbsError_log Loglevel warn HostNameLookups off <Directory /data/www2/> AllowOverride None Order allow,deny Allow from all </Directory> </VirtualHost>
上述的例子IP都是192.168.1.104,域名分別是www.php.com和bbs.php.com。因而可知apahce是通過(guò)ServerName來(lái)識(shí)別同一個(gè)IP下的不同站點(diǎn)的。
在實(shí)際應(yīng)用中你只需要將IP192.168.1.104、域名www.php.com和bbs.php.com分別改成你的IP和域名即可。
相關(guān)文章
Ubuntu安裝telent服務(wù)器時(shí)出現(xiàn):apt-get:Package has no installation的原因及
這篇文章主要介紹了Ubuntu安裝telent服務(wù)器時(shí)出現(xiàn):apt-get:Package has no installation的原因及解決方法的相關(guān)資料,需要的朋友可以參考下2016-11-11centos安裝jdk1.8時(shí)出現(xiàn)沒(méi)有/lib/ld-linux.so.2:這個(gè)文件的原因分析
這篇文章主要介紹了centos安裝jdk1.8時(shí)出現(xiàn)沒(méi)有/lib/ld-linux.so.2:這個(gè)文件的原因分析,通過(guò)使用一個(gè)簡(jiǎn)單的命令可以幫助我們解決,需要的朋友跟隨腳本之家小編一起看看吧2018-08-08linux服務(wù)器下添加用戶(hù)和刪除用戶(hù)的命令
linux服務(wù)器下添加用戶(hù)和刪除用戶(hù)的命令,需要的朋友可以參考下。2011-11-11Linux kde中11個(gè)你不知道的應(yīng)用程序
今天小編就為大家分享一篇關(guān)于Linux kde中11個(gè)你不知道的應(yīng)用程序,小編覺(jué)得內(nèi)容挺不錯(cuò)的,現(xiàn)在分享給大家,具有很好的參考價(jià)值,需要的朋友一起跟隨小編來(lái)看看吧2018-10-10Linux下查看端口占用進(jìn)程號(hào),程序名的方法
Linux下查看端口占用進(jìn)程號(hào),程序名的方法,方便我們查找什么進(jìn)程導(dǎo)致系統(tǒng)變慢等需要。2011-05-05