apache虛擬主機設定問題...



贊助商連結


edwang
2002-01-13, 12:32 AM
現在使用 adsldns 的 dns...沒有固定 ip .. 是過 aaa.domain.com, bbb.domain.com 都會連到我的主機...

問題來了...

apache 的 virtualhost 都要 based on ip ... 即 <VirtualHost xxx.xxx.xxx.xx> ... 可是我沒有固定 ip, 那要怎麼設??

我試過用 <virtualhost aa.my.com>...結果還是會連到主要的 document root ... 並不會區分開....

誰有事過成功的呢??教教我...謝謝

贊助商連結


repsol
2002-01-13, 01:35 AM
Using Name-based Virtual Hosts


To use name-based virtual hosting, you must designate the IP address (and possibly port) on the server that will be accepting requests for the hosts. This is configured using the NameVirtualHost directive. In the normal case where any and all IP addresses on the server should be used, you can use * as the argument to NameVirtualHost. (NameVirtualHost * will work only in version 1.3.13 and later.) Note that mentioning an IP address in a NameVirtualHost directive does not automatically make the server listen to that IP address. See Setting which addresses and ports Apache uses for more details. In addition, any IP address specified here must be associated with a network interface on the server.

The next step is to create a <VirtualHost> block for each different host that you would like to serve. The argument to the <VirtualHost> directive should be the same as the argument to the NameVirtualHost directive (ie, an IP address, or * for all addresses). Inside each <VirtualHost> block, you will need at minimum a ServerName directive to designate which host is served and a DocumentRoot directive to show where in the filesystem the content for that host lives.

For example, suppose that both www.domain.tld and www.otherdomain.tld point at an IP address that the server is listening to. Then you simply add the following to httpd.conf:


NameVirtualHost *

<VirtualHost *>
ServerName www.domain.tld
DocumentRoot /www/domain
</VirtualHost>

<VirtualHost *>
ServerName www.otherdomain.tld
DocumentRoot /www/otherdomain
</VirtualHost>


以上資料來源 :
http://httpd.apache.org

edwang
2002-01-13, 02:42 AM
ok了 ..... 謝謝...:)

蓋瑞
2003-08-07, 06:20 PM
對不起喔!上面的看不太懂...敘述一下我的狀況, 請大家幫我看看是哪邊不對
系統:win-xp
線路:512/512 adsl 固8
軟體:AppServ 210

問題是...
1.若想利用同一個IP使用不同的網域名稱..如
abcd.com.tw
1234.com.tw
是不是只要修改 http.conf 這個檔案就好了ㄋ

2.搜尋以前的文章都沒有較完整的說明, 但照著改過如下, 請問如此設定對嗎?
因為照這樣設定後會出現"找不到網頁" 所以請教各位有經驗的朋友, 謝謝各位



NameVirtualHost 203.204.203.204

<VirtualHost 203.204.203.204>
ServerAdmin [email protected]
DocumentRoot /www
ServerName abcd.com.tw
ErrorLog logs/abcd-error.log
CustomLog logs/abcd-access.log common
</VirtualHost>

<VirtualHost 203.204.203.204>
ServerAdmin [email protected]
DocumentRoot /www/xoops
ServerName 1234.com.tw
ErrorLog logs/1234-error.log
CustomLog logs/1234-access.log common
</VirtualHost>

edwang
2003-08-07, 10:17 PM
同一IP使用多Domain除了 httpd.conf 要設定之外,還要設定 DNS 才行...只改 httpd.conf 是沒有用的~~~



最初由 蓋瑞 發表
對不起喔!上面的看不太懂...敘述一下我的狀況, 請大家幫我看看是哪邊不對
系統:win-xp
線路:512/512 adsl 固8
軟體:AppServ 210

問題是...
1.若想利用同一個IP使用不同的網域名稱..如
abcd.com.tw
1234.com.tw
是不是只要修改 http.conf 這個檔案就好了ㄋ

2.搜尋以前的文章都沒有較完整的說明, 但照著改過如下, 請問如此設定對嗎?
因為照這樣設定後會出現"找不到網頁" 所以請教各位有經驗的朋友, 謝謝各位



NameVirtualHost 203.204.203.204

<VirtualHost 203.204.203.204>
ServerAdmin [email protected]
DocumentRoot /www
ServerName abcd.com.tw
ErrorLog logs/abcd-error.log
CustomLog logs/abcd-access.log common
</VirtualHost>

<VirtualHost 203.204.203.204>
ServerAdmin [email protected]
DocumentRoot /www/xoops
ServerName 1234.com.tw
ErrorLog logs/1234-error.log
CustomLog logs/1234-access.log common
</VirtualHost>

蓋瑞
2003-08-08, 03:37 AM
那...請問要如何設定ㄋ
可否教教我或是有相關的書籍可以參考
那麼 httpd.conf 是不是醬子設定便OKㄋ
謝謝您:D

edwang
2003-08-09, 01:52 AM
httpd.conf 的部分這樣設定是可以的...DNS 的部分主要是讓所有的網域可以指向同一個 IP....設定方式請自行參考 bind 文件~~~~



最初由 蓋瑞 發表
那...請問要如何設定ㄋ
可否教教我或是有相關的書籍可以參考
那麼 httpd.conf 是不是醬子設定便OKㄋ
謝謝您:D