1. 程式人生 > >本地網站域名配置

本地網站域名配置

1.開啟 windows system32 drivers etc host


127.0.0.1  www.a.com 繫結域名

2.開啟 apache conf httpd.conf

把include ..../http_vhosts.conf的“#”去掉

3.開啟include ..../http_vhosts.conf這個檔案再檔案裡面寫上繫結域名的專案路徑

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot "E:/yangyunyun/htnm_branch"
    ServerName www.b.com
    ErrorLog "logs/www.b.com-error.log"
    CustomLog "logs/www.b.com-access.log" common
</VirtualHost>

本地繫結域名成功


補充:本地域名繫結中出現的以下的問題,已經附上解決方案了

Apache提示You don't have permission to access / on this server問題解決


 
今天為了方便測試,將一本地目錄設定為一apache的虛擬主機,在httpd-vhosts.conf檔案中進行簡單設定,

然後在hosts檔案中將訪問地址指向本地,啟動apache,進行訪問,卻出現了You don't have permission to access / on this server的提示,

baidu了一下,原來是因為我的虛擬主機目錄為非apache安裝目錄下的htdocs,所以違反了apache對預設對網站根訪問許可權。

apache的預設虛擬主機根目錄地址為../Apache Software Foundation/Apache2.2/htdocs 目錄下,需要對httpd.conf檔案進行修改才能指向其他目錄。

在httpd.conf檔案下找到這段:

Conf程式碼  收藏程式碼
<span style="font-size: x-small;">#  
# Each directory to which Apache has access can be configured with respect  
# to which services and features are allowed and/or disabled in that  
# directory (and its subdirectories).   
#  
# First, we configure the "default" to be a very restrictive set of   
# features.    
#  
<Directory />  
    Options FollowSymLinks  
    AllowOverride None  
    Order deny,allow  
    Deny from all  
</Directory></span>  
 將之修改為
Conf程式碼  收藏程式碼
<span style="font-size: x-small;"># 允許指向外部的目錄進行訪問  
<Directory />  
    Options Indexes FollowSymLinks  
    AllowOverride None  
</Directory></span>  
 然後重啟apache,就ok了。