2016-03-06 42 views
0

我在使用ElCapitan下的內置apache網絡服務器時出現問題。OSX Apache虛擬主機只返回默認頁面

我想在我的用戶目錄中設置我的Sites-Directory。這可以通過添加用戶配置等來正常工作。所以我的localhost /〜Fabian給了我/User/Fabian/Sites/index.php的內容。

現在我試圖在此目錄中設置虛擬主機,例如/User/Fabian/Sites/Projekte/testsite.me/public。

所以我激活了虛擬主機模塊並將其包含在我的httpd.conf中。在此之後,我成立了在httpd-vhost.conf一個虛擬主機:

</VirtualHost *:80> 
    ServerAdmin [email protected] 
    DocumentRoot "/Users/Fabian/Sites/Projekte/testsite.me/public" 
    ServerName testsite.me 
    ErrorLog "/Users/Fabian/Sites/Logs/testsite-error_log" 
    CustomLog "/Users/Fabian/Sites/Logs/testsite-custom_log" common 
</VirtualHost> 

我還添加了ServerAlias到我的hosts文件

127.0.0.1 testsite.me 

試圖打開http://testsite.me顯示我的默認「它的工作原理「-頁。

運行apachectl configtest給我一個語法錯誤:

httpd: Syntax error on line 499 of /private/etc/apache2/httpd.conf: Syntax error on line 74 of /private/etc/apache2/extra/httpd-vhosts.conf: </VirtualHost without matching <VirtualHost section 

499線在httpd.conf看起來是這樣的:

Include /private/etc/apache2/extra/httpd-vhosts.conf 
的httpd-vhosts.conf的

行74ff包含我上面定義的虛擬主機。

任何想法如何解決這個問題?什麼是VirtualHost部分?

謝謝!

+0

Stack Overflow中的[topic](http://stackoverflow.com/help/on-topic)是編程,這個問題似乎與此無關。我想你會在更適合的Stack Exchange站點(如[Unix和Linux](http://unix.stackexchange.com),[Ask Different](http://apple.stackexchange))中得到更好的響應。 com /)或[超級用戶](http://superuser.com)。 –

回答

0

你開始你的虛擬主機定義</VirtualHost *:80> 這應該是<VirtualHost *:80>沒有斜槓。 儘管apache配置文件不是xml,但開始和結束部分的語法是相同的;所以你從<tag>開始並以</tag>結束。