我使用Apache的動態分析虛擬主機VirtualDocumentRoot指令, 現在我virtualhosts運作良好 但文我檢查的$ _ SERVER [值」 DOCUMENT_ROOT「] 它仍然具有第一個DocumentRoot定義 的值而不是VirtualDocumentRoot值!
我 「的http.conf」 文件的簡要部分是:
UseCanonicalName Off
DocumentRoot "/var/www/html"
<VirtualHost *:80>
ServerAdmin [email protected]
VirtualDocumentRoot "/var/vhosts/%0"
ErrorLog "logs/dynamic-vhosts-error.log"
CustomLog "logs/dynamic-vhosts-access.log" combined
</VirtualHost>
當我運行這個PHP代碼波紋管
<?php
echo $_SERVER["DOCUMENT_ROOT"];
?>
我得到的/ var/www/html等作爲結果。 如果我評論這一行
#DocumentRoot "/var/www/html"
PHP的結果將是
/etc/httpd/htdocs
但我要的$ _SERVER值[ 「DOCUMENT_ROOT」]是這樣的:
/var/vhosts/exampleDomain.com
是有沒有解決方案?
哪個版本的Apache? [這個問題應該從2.4.1開始解決](https://issues.apache.org/bugzilla/show_bug.cgi?id=26052)。 – julp 2014-10-27 12:42:08
謝謝。 是的,這個bug在Apache v2.4.1,0.中修復了我不能在CentOS 6.5上用PHP 5.6.x安裝Apache 2.4.x! 這就是爲什麼我不得不使用Apache2.2 :( 現在我正在尋求一個解決方案,一起有httpd 2.4和php 5.6 ... – 2014-11-04 06:28:32