最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

 更新時(shí)間:2014年01月12日 23:05:02   作者:  
如果你是第一次配置apache虛擬主機(jī),那么通過閱讀這篇文章你將會(huì)了解到如何實(shí)現(xiàn)apache虛擬主機(jī)配置。其實(shí)要配置好一臺(tái)虛擬主機(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>


如果您感覺上面的文章還不夠詳細(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. 為了測試不同的域名,在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本地地址。即,在瀏覽器中訪問localhost, test1.net, test2.net均可訪問XAMPP的歡迎頁。

2. 在apache目錄下建立目錄,以放置您不同的網(wǎng)站。為保護(hù)XAMPP原有的htdocs中的歡迎頁內(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)頁 index.html,內(nèi)容 -

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

<HTML>
<HEAD></HEAD>
<BODY>
<H1>hello~, 這是[對應(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中的,為了更好地組織文件,將其分離出去,類似于某些編程語言一樣。因此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è)可以參見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的可訪問性,你將遇到的是Access Forbidden!就連原來的localhost也是。

4. 由于之前注釋掉了httpd.conf中的ServerName, DocumentRoot等,為了仍然能以localhost訪問原XAMPP歡迎頁,就在增加一個(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ī)配置完成??梢酝ㄟ^http://localhost訪問XAMPP歡迎頁,通過http://test1.net和http://test2.net訪問各自的主頁。

#
# 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>

相關(guān)文章

  • Linux環(huán)境變量&&進(jìn)程地址空間詳解

    Linux環(huán)境變量&&進(jìn)程地址空間詳解

    本文介紹了Linux環(huán)境變量、命令行參數(shù)、進(jìn)程地址空間以及Linux內(nèi)核進(jìn)程調(diào)度隊(duì)列的相關(guān)知識(shí),環(huán)境變量是系統(tǒng)運(yùn)行環(huán)境的參數(shù),命令行參數(shù)用于傳遞給程序的參數(shù),進(jìn)程地址空間是進(jìn)程的虛擬內(nèi)存區(qū)域,而Linux內(nèi)核進(jìn)程調(diào)度隊(duì)列是進(jìn)程調(diào)度的核心數(shù)據(jù)結(jié)構(gòu)
    2025-02-02
  • linux主機(jī)AMH管理面板安裝教程及建站使用方法(圖文)

    linux主機(jī)AMH管理面板安裝教程及建站使用方法(圖文)

    這篇文章主要介紹了linux主機(jī)AMH管理面板安裝教程及建站使用,需要的朋友可以參考下
    2015-10-10
  • yum安裝本地rpm軟件方案詳解

    yum安裝本地rpm軟件方案詳解

    這篇文章主要介紹了yum安裝本地rpm軟件方案詳解,具有一定借鑒價(jià)值,需要的朋友可以參考下
    2018-01-01
  • 詳解linux tail命令顯示最后n行

    詳解linux tail命令顯示最后n行

    這篇文章給大家分享了linux tail命令顯示最后n行的具體代碼方法,有需要的朋友可以參考學(xué)習(xí)下。
    2018-07-07
  • linux下如何實(shí)現(xiàn)快速拷貝大文件

    linux下如何實(shí)現(xiàn)快速拷貝大文件

    這篇文章主要介紹了linux下如何實(shí)現(xiàn)快速拷貝大文件,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2020-05-05
  • 在 RHEL8 /CentOS8 上建立多節(jié)點(diǎn) Elastic stack 集群的方法

    在 RHEL8 /CentOS8 上建立多節(jié)點(diǎn) Elastic stack 集群的方法

    Elastic stack 俗稱 ELK stack,是一組包括 Elasticsearch、Logstash 和 Kibana 在內(nèi)的開源產(chǎn)品。Elastic Stack 由 Elastic 公司開發(fā)和維護(hù)。這篇文章主要介紹了如何在 RHEL8 /CentOS8 上建立多節(jié)點(diǎn) Elastic stack 集群,需要的朋友可以參考下
    2019-09-09
  • Linux gcc命令的具體使用

    Linux gcc命令的具體使用

    這篇文章主要介紹了Linux gcc命令的具體使用,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-02-02
  • linux grub的啟動(dòng)加密及刪除恢復(fù)方法

    linux grub的啟動(dòng)加密及刪除恢復(fù)方法

    這篇文章主要介紹了linux grub的啟動(dòng)加密及刪除恢復(fù)方法,需要的朋友可以參考下
    2016-10-10
  • Linux 自動(dòng)分區(qū)、格式化、掛載腳本詳解

    Linux 自動(dòng)分區(qū)、格式化、掛載腳本詳解

    這篇文章主要介紹了Linux 自動(dòng)分區(qū)、格式化、掛載腳本詳解的相關(guān)資料,自動(dòng)檢測是否有尚未分區(qū)的數(shù)據(jù)盤,格式化新的數(shù)據(jù)盤并自動(dòng)掛載,需要的朋友可以參考下
    2016-12-12
  • linux 安裝pypy , virtualenv及使用方法

    linux 安裝pypy , virtualenv及使用方法

    下面小編就為大家?guī)硪黄猯inux 安裝pypy , virtualenv及使用方法。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2016-12-12

最新評(píng)論

庄浪县| 晴隆县| 关岭| 浮山县| 额济纳旗| 德庆县| 辽中县| 沐川县| 区。| 鄢陵县| 句容市| 通海县| 大田县| 桃源县| 石嘴山市| 衡南县| 天门市| 芷江| 济南市| 宣城市| 卢湾区| 桐城市| 涡阳县| 紫云| 榆中县| 康乐县| 汉源县| 西林县| 武夷山市| 乌拉特前旗| 林西县| 台北市| 华池县| 阳东县| 宣汉县| 闻喜县| 江达县| 泰州市| 丹巴县| 衡水市| 彭州市|