error_log per Virtual Host?

2019-01-16 07:06发布

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 virtual hosts.

Overriding this setting in the <Location> of the httpd.conf does not seem to do anything.

Is there a way to have separate php error_logs for each Virtual Host?

11条回答
Anthone
2楼-- · 2019-01-16 07:21

I usually just specify this in an .htaccess file or the vhost.conf on the domain I'm working on. Add this to one of these files:

php_admin_value error_log "/var/www/vhosts/example.com/error_log"
查看更多
我欲成王,谁敢阻挡
3楼-- · 2019-01-16 07:23

Create Simple VirtualHost:

example hostname:- thecontrolist.localhost

  1. C:\Windows\System32\drivers\etc

    127.0.0.1 thecontrolist.localhost in hosts file

  2. C:\xampp\apache\conf\extra\httpd-vhosts.conf

    <VirtualHost *> ServerName thecontrolist.localhost ServerAlias thecontrolist.localhost DocumentRoot "/xampp/htdocs/thecontrolist" <Directory "/xampp/htdocs/thecontrolist"> Options +Indexes +Includes +FollowSymLinks +MultiViews AllowOverride All Require local </Directory> </VirtualHost>

  3. Don't Forget to restart Your apache. for more check this link

查看更多
兄弟一词,经得起流年.
4楼-- · 2019-01-16 07:24

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

查看更多
我想做一个坏孩纸
5楼-- · 2019-01-16 07:27

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

查看更多
三岁会撩人
6楼-- · 2019-01-16 07:30

The default behaviour is for error_log() 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.

查看更多
我欲成王,谁敢阻挡
7楼-- · 2019-01-16 07:32

Yes, you can try,

php_value error_log "/var/log/php_log" 

in .htaccess or you can have users use ini_set() in the beginning of their scripts if they want to have logging.

Another option would be to enable scripts to default to the php.ini in the folder with the script, then go to the user/host's root folder, then to the server's root, or something similar. This would allow hosts to add their own php.ini values and their own error_log locations.

查看更多
登录 后发表回答