怎樣配置apache虛擬主機

2021-06-14 23:07:48 字數 2715 閱讀 1674

**:

基於不同情況下配置apache虛擬主機的方法,一共八種情況。首先檢視你虛擬主機屬於哪一種情況,然後對號入座就好了。過程不複雜,關鍵在於對症下藥。

一、基於ip位址的虛擬主機

二、基於ip 和多埠的虛擬主機配置

三、單個ip 位址的伺服器上基於網域名稱的虛擬主機配置

# ensure that apache listens on port 80

listen 80

# listen for virtual host requests on all ip addresses

namevirtualhost *:80

documentroot /www/example1

servername www.example1.com

serveralias example1.com. *.example1.com

# other directives here

documentroot /www/example2

servername www.example2.org

# other directives here

四、在多個ip 位址的伺服器上配置基於網域名稱的虛擬主機

listen 80

# this is the "main" server running on 172.20.30.40

servername server.domain.com

documentroot /www/mainserver

# this is the other address

namevirtualhost 172.20.30.50

documentroot /www/example1

servername www.example1.com

# other directives here ...

documentroot /www/example2

servername www.example2.org

# other directives here ...

五、在不同的埠上執行不同的站點(基於多埠的伺服器上配置基於網域名稱的虛擬主機)

listen 80

listen 8080

namevirtualhost 172.20.30.40:80

namevirtualhost 172.20.30.40:8080

servername www.example1.com

documentroot /www/domain-80

servername www.example1.com

documentroot /www/domain-8080

servername www.example2.org

documentroot /www/otherdomain-80

servername www.example2.org

documentroot /www/otherdomain-8080

六、基於網域名稱和基於ip 的混合虛擬主機的配置

listen 80

namevirtualhost 172.20.30.40

documentroot /www/example1

servername www.example1.com

documentroot /www/example2

servername www.example2.org

documentroot /www/example3

servername www.example3.net

apache虛擬主機配置

之前已經在csdn上上傳過apache的文件在這裡補充說明一下,apache2.2.x與tomcat或iis或三者之間的虛擬主機配置。介紹一下如何整合其他 web伺服器,如 iis tomcat 等。網上有 n多整合方案講的都不是很清楚 特別是 windows 下的 這裡要特別提示一下,apache...

apache虛擬主機配置

多個網域名稱 伺服器 對應乙個 ip 位址,配置方法為 namevirtualhost 111.22.33.44 servername www.sample.com documentroot www sample servername www.sample2.com documentroot www...

apache配置虛擬主機

namevirtualhost 80 directoryindex default.php index.html index.php index.htm servername www.host1.com servername host1 com documentroot d wamp www1 er...