2012-03-22 148 views
3

我正在使用Wamp 2.2編輯conf/extra/httpd-vhosts.conf編輯此文件來添加VirtualHosts,但是當我在httpd.conf的未註釋行中包含httpd-vhosts.conf文件後,重新啓動Wamp後無法啓動。如果我恢復更改是正常工作。虛擬主機與WAMP

任何想法爲什麼會發生這種情況?

這是我使用的代碼httpd-vhost.conf

<VirtualHost *> 
    ServerAdmin [email protected] 
    DocumentRoot "C:/wamp/www" # change this line with your htdocs folder 
    ServerName localhost 
    ServerAlias localhost 
    <Directory "C:/wamp/www"> 
     Options Indexes FollowSymLinks Includes ExecCGI 
     Order allow,deny 
     Allow from all 
    </Directory> 
</VirtualHost> 

# WooCommerce Multisite 
<VirtualHost dev.lo> 
    ServerAdmin [email protected] 
    DocumentRoot "C:/wamp/www/dev" 
    ServerName dev.lo 
    ServerAlias dev.lo 
    <Directory "C:/wamp/www/dev"> 
     Order allow,deny 
     Allow from all 
    </Directory> 
</VirtualHost> 

感謝

喬治

編輯

由於安德烈亞斯·哈根的建議,我通過httpd的運行Apache 。可執行程序。

第一個錯誤是DocumentRoot的錯誤參數,因爲出現的註釋類似於作爲第二個參數,當DocumentRoot只接受一個時。

然後我得到警告:[warn] NameVirtualHost *:80 has no VirtualHosts。有一個快速搜索,發現非常有幫助的問題 - https://serverfault.com/questions/1405/apache-2-startup-warning-namevirtualhost-80-has-no-virtualhosts

回答

5

可能在vhosts文件中有一些不好的配置。嘗試從命令行啓動apache,以便獲取錯誤輸出。這將幫助您識別您的問題。

+0

什麼是從cmd開始它的命令? – Mamaduka 2012-03-22 10:03:34

+0

只需運行該exe文件。認爲它被命名爲httpd.exe – 2012-03-22 10:05:50

+0

試過,但httpd.exe只要我打開它就關閉,所以不能得到錯誤通知。 – Mamaduka 2012-03-22 15:55:13

3

打開您的主機文件(\WINDOWS\system32\drivers\etc\hosts)。 此行添加到底層:

127.0.0.1  test 

這會告訴您的計算機中包含測試任何URL將被路由到127.0.0.1(本地主機)。

現在打開httpd.conf這添加到文件的最底部:

NameVirtualHost *:80 
<VirtualHost *:80> 
    DocumentRoot "c:/wamp/www/myfirstsite/" 
    ServerName testsite 
</VirtualHost> 

現在重啓apache,並導航到:http://test/(您可能需要重新啓動瀏覽器,以使更改生效)

希望這能奏效。

+0

我已經編輯了dev.lo的主機文件 - 「127.0.0.1 dev.lo」。 – Mamaduka 2012-03-22 10:03:46

0

轉到C:/驅動器,然後選擇文件夾WAMP

,並轉到C:\ WAMP \ BIN \ apache的\ Apache2.4.4 \ conf以選擇httpd.conf文件。

編輯用記事本和去58行號

變化收聽80和替換聽8181保存文件並重新啓動Apache服務器

現在檢查URL,例如像這樣的本地主機:8181

我有使用這一跳你將會成功。