2016-03-08 45 views
0

我目前有一個Web服務器設置爲開發環境,我的DNS設置基本上任何子域都是有效的,即* .mydomain.com。我已經在我的Apache配置下列虛擬主機部分實現了這一點,用在/ var/www/html等/ 1%作爲子域的文檔根:%1 ErrorLog/CustomLog在Apache conf

<VirtualHost x.x.x.x:80> 
    ... 
    ServerName %1.mydomain.com 
    DocumentRoot /var/www/html 
    VirtualDocumentRoot "/var/www/html/%1" 
    LogFormat "%V %h %l %u %t \"%t\" %s %b" vcommon 
    ErrorLog /var/log/httpd/error.log 
    CustomLog /var/log/httpd/access.log combined 
</VirtualHost> 

不過,我試圖讓錯誤日誌和的CustomLog通過使用以下內容寫入更相關目錄中的文件:

ErrorLog "/var/www/html/%1/error.log" 
    CustomLog "/var/www/html/%1/access.log" combined 

而這會破壞事情。 Apache將無法啓動並報告:

No such file or directory: [client AH02291: Cannot access directory '/var/www/html/%1/' for error log[...] 

在我看來,該錯誤日誌和的CustomLog選項不擴大/以同樣的方式,VirtualDocumentRoot是,所以我的問題是,相當簡潔評估%1,如何我可以做到這一點嗎?

在此先感謝。

回答

0

Apache日誌是每個虛擬主機,所以這是不可能的。

我能想到的最好的辦法是定期對Apache日誌文件進行一些處理以創建人造日誌。

+0

好的,謝謝你的回覆。目前,我只是想通過PHP明確設置日誌文件,希望解決方案會出現,讓我這樣做,我想如何:) – kougami