每个虚拟主机的错误日志记录



我正在使用Apache运行Ubuntu 14.04。我想为每个虚拟主机提供单独的php错误日志。我已经阅读了一些堆栈溢出主题并设置了 host.com 文件,但它仍然不起作用。PHP错误被记录到错误中.log而不是php-error.log(我没有忘记重新启动apache(。

我的php版本:PHP 5.6.30-12~ubuntu14.04.1+deb.sury.org+1(cli(。

我的主机文件:

<IfModule mod_ssl.c>
<VirtualHost dev.domain.com:443>
ServerName dev.domain.com
ServerAdmin email@domain.com
DocumentRoot /var/www/html/domain.com/dev.domain.com/public_html
ErrorLog /var/log/logs/domain.com/dev.domain.com/dev.domain.com.error.log
CustomLog /var/log/logs/domain.com/dev.domain.com/dev.domain.com.access.log combined
php_flag log_errors on
php_flag display_errors on
php_value error_reporting 2147483647
php_value error_log /var/log/logs/domain.com/dev.domain.com/dev.domain.com.php-error.log
<Directory /var/www/html/domain.com/dev.domain.com/public_html>
Options +Indexes +FollowSymLinks -MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
SSLCertificateFile /etc/letsencrypt/live/dev.domain.com/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/dev.domain.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateChainFile /etc/letsencrypt/live/dev.domain.com/chain.pem
</VirtualHost>
</IfModule>

有什么想法吗?

------编辑------

我也尝试过这样:

<IfModule mod_ssl.c>
<VirtualHost dev.domain.com:443>
ServerName dev.domain.com
ServerAdmin linas@hardrokas.net
DocumentRoot /var/www/html/domain.com/dev.domain.com/public_html
ErrorLog /var/log/logs/domain.com/dev.domain.com/dev.domain.com.error.log
CustomLog /var/log/logs/domain.com/dev.domain.com/dev.domain.com.access.log combined

<Directory /var/www/html/domain.com/dev.domain.com/public_html>
Options +Indexes +FollowSymLinks -MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
<IfModule mod_php5.c>
php_flag log_errors on
php_flag display_errors on
php_value error_reporting 2147483647
php_value error_log /var/log/logs/domain.com/dev.domain.com/dev.domain.com.php-error.log
</IfModule>

SSLCertificateFile /etc/letsencrypt/live/dev.domain.com/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/dev.domain.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateChainFile /etc/letsencrypt/live/dev.domain.com/chain.pem
</VirtualHost>
</IfModule>

而这个:

    <IfModule mod_ssl.c>
<VirtualHost dev.domain.com:443>
ServerName dev.domain.com
ServerAdmin linas@hardrokas.net
DocumentRoot /var/www/html/domain.com/dev.domain.com/public_html
ErrorLog /var/log/logs/domain.com/dev.domain.com/dev.domain.com.error.log
CustomLog /var/log/logs/domain.com/dev.domain.com/dev.domain.com.access.log combined

<Directory /var/www/html/domain.com/dev.domain.com/public_html>
Options +Indexes +FollowSymLinks -MultiViews
AllowOverride All
Order allow,deny
allow from all
<IfModule mod_php5.c>
php_flag log_errors on
php_flag display_errors on
php_value error_reporting 2147483647
php_value error_log /var/log/logs/domain.com/dev.domain.com/dev.domain.com.php-error.log
</IfModule>
</Directory>
SSLCertificateFile /etc/letsencrypt/live/dev.domain.com/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/dev.domain.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateChainFile /etc/letsencrypt/live/dev.domain.com/chain.pem
</VirtualHost>
</IfModule>

但同样的问题,所有 php 错误都被记录为错误.log

尝试将php_flag值放在目录标签中:

<IfModule mod_ssl.c>
<VirtualHost dev.domain.com:443>
ServerName dev.domain.com
ServerAdmin email@domain.com
DocumentRoot /var/www/html/domain.com/dev.domain.com/public_html
ErrorLog /var/log/logs/domain.com/dev.domain.com/dev.domain.com.error.log
CustomLog /var/log/logs/domain.com/dev.domain.com/dev.domain.com.access.log combined

<Directory /var/www/html/domain.com/dev.domain.com/public_html>
    Options +Indexes +FollowSymLinks -MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
    php_flag log_errors on
    php_flag display_errors on
    php_value error_reporting 2147483647
    php_value error_log /var/log/logs/domain.com/dev.domain.com/dev.domain.com.php-error.log    
</Directory>
SSLCertificateFile /etc/letsencrypt/live/dev.domain.com/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/dev.domain.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateChainFile /etc/letsencrypt/live/dev.domain.com/chain.pem
</VirtualHost>
</IfModule>

尝试将这些标志放入其中:

<IfModule mod_php5.c>
    php_flag log_errors on
    php_flag display_errors on
    php_value error_reporting 2147483647
    php_value error_log /var/log/logs/domain.com/dev.domain.com/dev.domain.com.php-error.log
  </IfModule>

或者另一个模组名称(取决于您使用的 php 版本(

最新更新