IIS、apache、tomcat服務器虛擬主機配置

首先咱們有一個域名  xxx.com;(注,兩個一級域名不相同也能夠)
有兩個二級域名   priject.xxx.com 和 movie.xxx.com
有一臺主機 ,如今假設訪問主機電腦

IIS服務器虛擬主機配置方法
一、在IIS中添加網站
其中  綁定一欄中的主機名爲 priject.xxx.com,在分配好網站的文件路徑

二、添加isapi篩選器
其中可執行文件位置爲php的安裝位置
三、處理程序映射->添加腳本映射
四、最後重啓IIS服務器,就能夠用域名訪問了
再添加站點,一樣的步驟。


tomcat服務器虛擬主機配置方法
在Engine節點下增長host節點

<Host name="priject.xxx.com"  appBase="webapps/priject"
            unpackWARs="true" autoDeploy="true">

        <!-- SingleSignOn valve, share authentication between web applications
             Documentation at: /docs/config/valve.html -->
        <!--
        <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
        -->

        <!-- Access log processes all example.
             Documentation at: /docs/config/valve.html
             Note: The pattern used is equivalent to using pattern="common" -->
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="localhost_access_log." suffix=".txt"
               pattern="%h %l %u %t &quot;%r&quot; %s %b" />

</Host>
<Host name= "movie.xxx.com"  appBase="webapps/movie"
            unpackWARs="true" autoDeploy="true">

        <!-- SingleSignOn valve, share authentication between web applications
             Documentation at: /docs/config/valve.html -->
        <!--
        <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
        -->

        <!-- Access log processes all example.
             Documentation at: /docs/config/valve.html
             Note: The pattern used is equivalent to using pattern="common" -->
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="localhost_access_log." suffix=".txt"
               pattern="%h %l %u %t &quot;%r&quot; %s %b" />

</Host>
注在webapps目錄下的movie要建立ROOT目錄才能夠,並且ROOT必須大寫。在ROOT目錄先放置jsp代碼。

tomcat會根據主機名稱自動尋找相應的目錄去訪問


apache服務器虛擬主機配置方法


打開httpd.conf文件
去掉LoadModule vhost_alias_module modules/mod_vhost_alias.so
這句前面的#號

Include conf/extra/httpd-vhosts.conf這句前面的#號

Include conf/extra/httpd-vhosts.conf這句在httpd.conf文件底部

而後打開Apache2.2\conf\extra下的httpd-vhosts.conf文件,加入以下代碼

#配置本身的虛擬主機
<VirtualHost *:80>
    #網站目錄,若是在www目錄下的php目錄,下面    #就填寫F:/www/php
    DocumentRoot "D:/www/網站目錄"
    #域名
    ServerName  priject.xxx.com
    #這裏配置歡迎首頁面
    DirectoryIndex index.html index.htm index.php
    <Directory />
    Options FollowSymLinks
    #不容許別人修改咱們的頁面
    AllowOverride None
    #設置訪問權限
    order allow,deny
    Allow from all
    </Directory>   
</VirtualHost>
<VirtualHost *:80>
    #網站目錄,若是在www目錄下的php目錄,下面    #就填寫F:/www/php
    DocumentRoot "D:/www/網站目錄"
    #域名
    ServerName  movie.xxx.com
    #這裏配置歡迎首頁面
    DirectoryIndex index.html index.htm index.php
    <Directory />
    Options FollowSymLinks
    #不容許別人修改咱們的頁面
    AllowOverride None
    #設置訪問權限
    order allow,deny
    Allow from all
    </Directory>   
</VirtualHost>

php

相關文章
相關標籤/搜索