error_log per Virtual Host?

后端 未结 11 1782
独厮守ぢ
独厮守ぢ 2020-12-02 07:58

On one Linux Server running Apache and PHP 5, we have multiple Virtual Hosts with separate log files. We cannot seem to separate the php error_log between virtu

相关标签:
11条回答
  • 2020-12-02 08:12

    If somebody comes looking it should look like this:

    <VirtualHost *:80>
        ServerName example.com
        DocumentRoot /var/www/domains/example.com/html
        ErrorLog /var/www/domains/example.com/apache.error.log
        CustomLog /var/www/domains/example.com/apache.access.log common
        php_flag log_errors on
        php_flag display_errors on
        php_value error_reporting 2147483647
        php_value error_log /var/www/domains/example.com/php.error.log
    </VirtualHost>
    

    This is for development only since display_error is turned on. You will notice that the Apache error log is separate from the PHP error log. The good stuff is in php.error.log.

    Take a look here for the error_reporting key http://www.php.net/manual/en/errorfunc.configuration.php#ini.error-reporting

    0 讨论(0)
  • 2020-12-02 08:12

    The default behaviour for error_log() is to output to the Apache error log. If this isn't happening check your php.ini settings for the error_log directive. Leave it unset to use the Apache log file for the current vhost.

    0 讨论(0)
  • 2020-12-02 08:12
    php_value error_log "/var/log/httpd/vhost_php_error_log"
    

    It works for me, but I have to change the permission of the log file.

    or Apache will write the log to the its error_log.

    0 讨论(0)
  • 2020-12-02 08:13

    Have you tried adding the php_value error_log '/path/to/php_error_log to your VirtualHost configuration?

    0 讨论(0)
  • 2020-12-02 08:16

    My Apache had something like this in httpd.conf. Just change the ErrorLog and CustomLog settings

    <VirtualHost myvhost:80>
        ServerAdmin webmaster@dummy-host.example.com
        DocumentRoot /opt/web
        ServerName myvhost
        ErrorLog logs/myvhost-error_log
        CustomLog logs/myvhost-access_log common
    </VirtualHost>
    
    0 讨论(0)
  • 2020-12-02 08:21

    To set the Apache (not the PHP) log, the easiest way to do this would be to do:

    <VirtualHost IP:Port>
       # Stuff,
       # More Stuff,
       ErrorLog /path/where/you/want/the/error.log
    </VirtualHost>
    

    If there is no leading "/" it is assumed to be relative.

    Apache Error Log Page

    0 讨论(0)
提交回复
热议问题