Apache 虛擬主機 VirtualHost 配置


轉自:http://www.neoease.com/apache-virtual-host/

Windows 是市場占有率最高的 PC 操作系統, 也是很多人的開發環境. 其 VirtualHost 配置方法與 Linux 上有些差異, 以下方式適合原生 Apache, XAMPP 和 WAMP 套件.

1. 打開目錄 {Apache2 安裝目錄}\conf\extra\, 找到 httpd-vhosts.conf 文件.

2. 仿照例子, 添加一段代碼來指定某一域名的網站.

#
# DocumentRoot 是網站文件存放的根目錄
# ServerName 是網站域名, 需要跟 DNS 指向的域名一致
#
<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot "D:/workspace/php/demo_neoease_com"
    ServerName demo.neoease.com
    ErrorLog "logs/demo.neoease.com-error.log"
    CustomLog "logs/demo.neoease.com-access.log" common
</VirtualHost>

3. 打開 httpd.conf 文件, 添加如下語句.

# Virtual hosts
Include conf/extra/httpd-vhosts.conf

4. 重啟 Apache 服務.

 

注:默認情況下新添加的虛擬主機的的路徑是沒有訪問權限的,添加路徑的訪問的權限

例如:

<Directory "E:/Apache2.2/www.ee.com">
    Options Indexes FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM