欧美一级特黄大片做受成人-亚洲成人一区二区电影-激情熟女一区二区三区-日韩专区欧美专区国产专区

如何配置apache虛擬主機(jī)的實(shí)例小結(jié)

2022-10-10    分類: 虛擬主機(jī)

1、基于ip地址的虛擬主機(jī)

 

復(fù)制代碼 代碼如下:

Listen 80
<VirtualHost 172.20.30.40>
    DocumentRoot /home/httpd/html1
    ServerName www.ok1.com
    ErrorLog /usr/local/apache/logs/error1_log
    CustomLog /usr/local/apache/logs/access1_log combined
</VirtualHost>
<VirtualHost 172.20.30.50>
    DocumentRoot /home/httpd/html2
    ServerName www.ok2.com
    ErrorLog /usr/local/apache/logs/error2_log
    CustomLog /usr/local/apache/logs/access2_log combined
</VirtualHost>

 

 2、基于IP 和多端口的虛擬主機(jī)配置

 

復(fù)制代碼 代碼如下:

Listen 172.20.30.40:80
Listen 172.20.30.40:8080
Listen 172.20.30.50:80
Listen 172.20.30.50:8080

<VirtualHost 172.20.30.40:80>
 DocumentRoot /www/example1-80
 ServerName www.example1.com
</VirtualHost>
<VirtualHost 172.20.30.40:8080>

 DocumentRoot /www/example1-8080
 ServerName www.example1.com
</VirtualHost>
<VirtualHost 172.20.30.50:80>
 DocumentRoot /www/example2-80
 ServerName www.example1.org
</VirtualHost>
<VirtualHost 172.20.30.50:8080>
 DocumentRoot /www/example2-8080
 ServerName www.example2.org
</VirtualHost>

 

3、單個(gè)IP 地址的服務(wù)器上基于域名的虛擬主機(jī)配置
 

復(fù)制代碼 代碼如下:

# Ensure that Apache listens on port 80
Listen 80
# Listen for virtual host requests on all IP addresses
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /www/example1
ServerName www.example1.com
ServerAlias example1.com. *.example1.com
# Other directives here
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /www/example2
ServerName www.example2.org
# Other directives here
</VirtualHost>

如果您感覺(jué)上面的文章還不夠詳細(xì)可以看下下面的文章:

實(shí)驗(yàn)?zāi)繕?biāo):在apache實(shí)現(xiàn)基于域名的虛擬主機(jī)
實(shí)驗(yàn)用的XAMPP版本為1.7.7,內(nèi)含apache版本為2.2.21

實(shí)驗(yàn)前準(zhǔn)備:

 

1. 為了測(cè)試不同的域名,在Windows/System32/drivers/etc/下覓得hosts文件,在其中添加實(shí)驗(yàn)用的域名若干,如 -

 

復(fù)制代碼 代碼如下:

127.0.0.1   test1.net
127.0.0.1   test2.net

 

如此,則在瀏覽器中輸入該倆域名時(shí),Windows將其解析為127.0.0.1本地地址。即,在瀏覽器中訪問(wèn)localhost, test1.net, test2.net均可訪問(wèn)XAMPP的歡迎頁(yè)。

2. 在apache目錄下建立目錄,以放置您不同的網(wǎng)站。為保護(hù)XAMPP原有的htdocs中的歡迎頁(yè)內(nèi)容,實(shí)驗(yàn)另外建立了與htdocs平級(jí)的htdocs1目錄,在其下建立了test1.net, test2.net兩個(gè)子目錄用以放置實(shí)驗(yàn)用的網(wǎng)站。如下 -
apache/htdocs1/test1.net - 放置test1.net網(wǎng)站內(nèi)容
apache/htdocs1/test2.net - 放置test2.net網(wǎng)站內(nèi)容

 在這兩個(gè)目錄中各新建hello world一網(wǎng)頁(yè) index.html,內(nèi)容 -

 

復(fù)制代碼 代碼如下:

<HTML>
<HEAD></HEAD>
<BODY>
<H1>hello~, 這是[對(duì)應(yīng)的網(wǎng)站名,用以區(qū)別].net</H1></BODY>
</HTML> 

 

實(shí)驗(yàn)步驟:

1. 找到apache/conf/httpd.conf, 將其中的

ServerAdmin
ServerName
DocumentRoot
注釋掉。

2. 在httpd.conf中,找到行

 Include "conf/extra/httpd-vhosts.conf"
如被注釋則解注。該文件記載了虛擬主機(jī)的參數(shù)。[以前虛擬主機(jī)參數(shù)是直接填寫在httpd.conf中的,為了更好地組織文件,將其分離出去,類似于某些編程語(yǔ)言一樣。因此httpd.conf中include它,即相當(dāng)于把它的內(nèi)容填在了httpd.conf中。]

3. 這個(gè)httpd-vhosts.conf文件格式基本如下 -

 

復(fù)制代碼 代碼如下:

#blah-blah
NameVirtualHost *:80
#blah-blah
#blah-blah
<VirtualHost *:80>
    ServerAdmin XXXXXXXX
    DocumentRoot "XXXXXXXX"
    ServerName XXXXXXX
    ServerAlias XXXXXX
    ErrorLog "logs/XXXXXX-error.log"
    CustomLog "logs/XXXXXXX-error.log" combined
</VirtualHost>

 

需要修改的,就是<VirtualHost>中的參數(shù)了。這個(gè)可以參見(jiàn)apache官方文檔。根據(jù)實(shí)驗(yàn)域名,可以增加兩個(gè)<VirtualHost>:

 

復(fù)制代碼 代碼如下:

<VirtualHost *:80>
    ServerAdmin adm@test1.net
    DocumentRoot "C:/xampp/htdocs1/test1.net"
    ServerName test1.net
    ServerAlias www.test1.net
    ErrorLog "logs/test1-error.log"
    CustomLog "logs/test1-access.log" combined

    <Directory "C:/xampp/htdocs1/test1.net">
    order allow,deny
    allow from all
    </Directory>
</VirtualHost>
<VirtualHost *:80>
    ServerAdmin adm@test2.net
    DocumentRoot "C:/xampp/htdocs1/test2.net"
    ServerName test2.net
    ServerAlias www.test2.net
    ErrorLog "logs/test1-error.log"
    CustomLog "logs/test1-access.log" combined

    <Directory "C:/xampp/htdocs1/test2.net">
    order allow,deny
    allow from all
    </Directory>
</VirtualHost>

 

注意,如果不在各VirtualHost中定義Directory的可訪問(wèn)性,你將遇到的是Access Forbidden!就連原來(lái)的localhost也是。

4. 由于之前注釋掉了httpd.conf中的ServerName, DocumentRoot等,為了仍然能以localhost訪問(wèn)原XAMPP歡迎頁(yè),就在增加一個(gè)VirtualHost,如下 -

 

復(fù)制代碼 代碼如下:

<VirtualHost *:80>
    ServerAdmin adm@localhost
    DocumentRoot "C:/xampp/htdocs"
    ServerName localhost

    ErrorLog "logs/localhost-error.log"
    CustomLog "logs/localhost-access.log" combined

    <Directory "C:/xampp/htdocs">
    order allow,deny
    allow from all
    </Directory>
</VirtualHost>

 

為了避免出錯(cuò),把它放置在第一個(gè)Virtualhost位置。

至此,apache基于域名的虛擬主機(jī)配置完成??梢酝ㄟ^(guò)http://localhost訪問(wèn)XAMPP歡迎頁(yè),通過(guò)http://test1.net和http://test2.net訪問(wèn)各自的主頁(yè)。

#
# Virtual Hosts
#

# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.2/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.

#
# Use name-based virtual hosting.
#
NameVirtualHost *:80

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#

<VirtualHost *:80>
    ServerAdmin kongdaoxian@gmail.com
    DocumentRoot "E:/skydao/apache2/htdocs"
    ServerName localhost
    ServerAlias www.skydao.com
    ErrorLog "logs/localhost-error.log"
    CustomLog "logs/localhost-access.log" combined

    <Directory "E:/skydao/apache2/htdocs">
    order allow,deny
    allow from all
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin kongdaoxian@gmail.com
    DocumentRoot "E:/skydao/apache2/htdocs/project1"
    ServerName project1.com
    ServerAlias www.project1.com
    ErrorLog "logs/project1-error.log"
    CustomLog "logs/project1-access.log" combined

    <Directory "E:/skydao/apache2/htdocs/project1">
    order allow,deny
    allow from all
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin kongdaoxian@gmail.com
    DocumentRoot "E:/skydao/apache2/htdocs/zendTest/public"
    ServerName zendTest.com
    ServerAlias www.zendTest.com
    DirectoryIndex index.php
    <Directory />
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin kongdaoxian@gmail.com
    DocumentRoot "E:/skydao/apache2/htdocs/testRewrite"
    ServerName testRewrite.com
    ServerAlias www.testRewrite.com
    # DirectoryIndex index.php
    <Directory />
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin kongdaoxian@gmail.com
    DocumentRoot "E:/skydao/apache2/htdocs/test"
    ServerName test.com
    ServerAlias www.test.com
    ErrorLog "logs/zendTest-error.log"
    CustomLog "logs/zendTest-access.log" combined

    <Directory "E:/skydao/apache2/htdocs/test">
    order allow,deny
    allow from all
    </Directory>
</VirtualHost>

標(biāo)題名稱:如何配置apache虛擬主機(jī)的實(shí)例小結(jié)
文章出自:http://aaarwkj.com/news13/204313.html

網(wǎng)站建設(shè)、網(wǎng)絡(luò)推廣公司-創(chuàng)新互聯(lián),是專注品牌與效果的網(wǎng)站制作,網(wǎng)絡(luò)營(yíng)銷seo公司;服務(wù)項(xiàng)目有虛擬主機(jī)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

手機(jī)網(wǎng)站建設(shè)
国产精品三级竹菊影视| 成人在线免费黄色小说| 国产亚洲成人精品久久| 欧美颜射一区二区三区| 在线看黄视频网站永久免费| 久国产精品久久久极品| 亚洲av二区三区成人| 日本精品免费专区在线观看| 国产精品久久中文字幕亚洲| 熟妇一区二区三区av| 国产精品麻豆一区二区三区| 亚洲精品一品区二品区三区| 欧美国产精品中文字幕| 99久久精品费精品国产风间由美| 黄色18禁网站在线看| 一区二区三区亚洲精品在线| 最新日本欧美一区二区| 国产原创av超爽剧情系列| 精品久久中文字幕久久av| 亚洲一区二区三区四区五区六| 日日摸夜夜添添出白浆| 亚洲一区二区三区欧美精品| av免费在线观看网页| 日韩精品国产一区二区在线观看| 亚洲一区二区视频免费看| 欧美一区二区三区免费精品| 哪里可以看日韩免费毛片| 国产亚洲一区二区三区av| 日韩中文字幕在线乱码| av剧情网址在线观看| 欧美口爆吞精在线播放| 99久久精品费精品国产风间由美| 亚洲成人高清在线播放| 国产熟女碰碰人人a久久| 日本一区中文字幕欧美| 欧美日韩中文国产天堂| 欧美日韩国产天堂一区| 91在线观看高清免费| 五月天色婷婷亚洲综合一区| 国产在线乱码一区二区| 国产麻豆成人传媒免费观看|