Apache-2.2

帶有 PHP 和自定義日誌的 Apache Virtualhosts - 如何隔離 PHP 錯誤?

  • December 7, 2012

我正在嘗試在 Ubuntu 伺服器上為我的應用程序設置一個簡單的託管環境。

我創建了一個這樣的虛擬主機:

<VirtualHost *:80>
       ServerAdmin info@example.org
       ServerName www.example.com
       ServerAlias example.com

       DocumentRoot /home/owner/example.com/docs
       <Directory />
               Options FollowSymLinks
               AllowOverride None
       </Directory>
       <Directory /home/owner/example.com/docs/>
               Options -Indexes FollowSymLinks MultiViews
               AllowOverride None
               Order allow,deny
               allow from all
       </Directory>

       ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
       <Directory "/usr/lib/cgi-bin">
               AllowOverride None
               Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
               Order allow,deny
               Allow from all
       </Directory>

       ErrorLog /home/owner/example.com/logs/error.log

       # Possible values include: debug, info, notice, warn, error, crit,
       # alert, emerg.
       LogLevel warn

       CustomLog /home/owner/example.com/logs/access.log combined

       php_flag log_errors on
       php_value error_log /home/owner/example.com/logs/php-error.log

</VirtualHost>

現在,我的問題是 PHP 錯誤和警告被拋出error.log- 不是php-error.log我希望的那樣。

怎樣才能做到這一點?

確保 apache 使用者除了能夠寫入之外,還具有創建 /home/owner/example.com/logs/php-error.log 文件的權限。

/home/owner/example.com/logs/ 目錄很可能有 755 權限,這將阻止 Apache 創建 php-error.log 文件。

引用自:https://serverfault.com/questions/455992