PHP Apache 配置虛擬機器主機

來源:互聯網
上載者:User
1.找到Apache的\conf目錄下的httpd.conf檔案,開啟它,找到下面這兩行:

# Virtual hosts

#Include conf/extra/httpd-vhosts.conf

把他前邊的#號去掉,修改後如下如下:

# Virtual hosts

Include conf/extra/httpd-vhosts.conf

意思是啟用虛擬機器主機的設定檔案httpd-vhosts.conf,虛擬機器主機的設定都在這個檔案下設定,不用去改httpd.conf,這樣比較清晰。



2.找到Apache的\conf\extra目錄下的httpd-vhost.conf這個檔案。

開啟它的時候裡面已經含有像下面這樣的內容:

?虛擬機器主機配置開始

ServerAdmin webmaster@dummy-host.localhost

DocumentRoot "E:/wamp/www/ecshop"//網站的根路徑-虛擬機器主機的目錄,即網域名稱對應的根目錄

ServerName "www.baidu.com"//虛擬機器主機網域名稱-你想要的網域名稱

ServerAlias www.dummy-host.localhost

ErrorLog "logs/dummy-host.localhost-error.log"

CustomLog "logs/dummy-host.localhost-access.log" common


還要在每個虛擬機器主機配置開始前加入以下內容:

//這是你的虛擬機器主機的被授權的目錄一般與DocumentRoot “”?虛擬機器主機的目錄,即網域名稱對應的根目錄相同。

Options Indexes FollowSymLinks Includes ExecCGI

AllowOverride All

Order allow,deny

Allow from all

Allow from all - 只要allow別人才行訪問上面定義的目錄,否則在IE或firefox訪問時會顯示503錯誤,即禁止訪問。這是Apache預設的設定,最後一行是這樣的

Deny from all意思是拒絕所有訪問對根目錄的訪問,別人是訪問不了你的網站的,

所以要想其他使用者可以訪問到你的項目就得改成

Allow from all

3.找到C:\WINDOWS\system32\drivers\etc目錄下的hosts檔案

加上一句下面的話

127.0.0.1 www.baidu.com?這個是你的網域名稱,你要設定多少個虛擬機器主機,就要加多少行這樣的記錄。

=========================================================================================================
例子
Options Indexes FollowSymLinks Includes ExecCGIAllowOverride AllOrder allow,denyAllow from allServerAdmin webmaster@dummy-host2.localhostDocumentRoot E:\wamp\www\ecshopServerName www.test.comErrorLog logs/dummy-host2.localhost-error_logCustomLog logs/dummy-host2.localhost-access_log common
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.