0

Firstly, apologies for the vague title. Not sure how best to word it. I'll start off with a copy of my php logs.

[25-Jun-2019 12:21:44] WARNING: [pool corrigansni.ivech.co.uk] child 58505 said into stderr: "NOTICE: PHP message: PHP Warning:  Unknown: open_basedir restriction in effect. File(C:\Inetpub\vhosts\ivech.co.uk\logs\php_errors\choicerentals.ivech.co.uk\php_error.log) is not within the allowed path(s): (/var/www/vhosts/ivech.co.uk/:/tmp/) in Unknown on line 0"
[25-Jun-2019 12:21:44] WARNING: [pool corrigansni.ivech.co.uk] child 58504 said into stderr: "NOTICE: PHP message: PHP Warning:  Unknown: open_basedir restriction in effect. File(C:\Inetpub\vhosts\ivech.co.uk\logs\php_errors\choicerentals.ivech.co.uk\php_error.log) is not within the allowed path(s): (/var/www/vhosts/ivech.co.uk/:/tmp/) in Unknown on line 0"
[25-Jun-2019 12:21:45] WARNING: [pool corrigansni.ivech.co.uk] child 58499 said into stderr: "NOTICE: PHP message: PHP Warning:  Unknown: open_basedir restriction in effect. File(C:\Inetpub\vhosts\ivech.co.uk\logs\php_errors\choicerentals.ivech.co.uk\php_error.log) is not within the allowed path(s): (/var/www/vhosts/ivech.co.uk/:/tmp/) in Unknown on line 0"
[25-Jun-2019 12:21:45] WARNING: [pool corrigansni.ivech.co.uk] child 58456 said into stderr: "NOTICE: PHP message: PHP Warning:  Unknown: open_basedir restriction in effect. File(C:\Inetpub\vhosts\ivech.co.uk\logs\php_errors\choicerentals.ivech.co.uk\php_error.log) is not within the allowed path(s): (/var/www/vhosts/ivech.co.uk/:/tmp/) in Unknown on line 0" 

That's just a small section of my logs. I'm assuming I have programming errors which are trying to write to the logs but this is happening on every page load of roughly 60 subdomains. I've only become aware of it due to some major speed issues recently. The server load is fine however the speed of running multiple ajax scripts has decreased dramatically recently. I'm hoping this is all related and by fixing this problem the speed issues will fix.

My main issue is that irrelevant of the php errors, they're not able to write because of the openbase_dir problem. However, as you can see from the logs it's not even trying to write to a related folder.

subdomain: corrigansni is trying to write to the log folder for choicerentals even though they aren't related and choicerentals subdomain no longer exists. I'm also not being told which script is trying to write the logs.

Can anyone answer the following:

  1. where the setting may be to change where it is writing the logs?
  2. why i'm getting unknown on line 0 instead of a script location
  3. why every single page load and ajax call may be causing this to happen.

Just as a side note, I've tried changing the PHP version I'm using, still get the same issues.

Thanks in advance

EDIT: A few people have suggested a similar question elsewhere. It's not really the same. That questions asks how to relax openbase_dir, I don't want to do that.

My question has a few parts:

Firstly; it's trying to access a folder within the directory which is not relevant. How do I change that location.

Secondly; my openbase_dir settings appear to be correct so why would it not be able to access it.

Thirdly. What would cause it to attempt to write to an error_log file but from an unknown location.

user1530205
  • 302
  • 6
  • 19
  • Possible duplicate of [How can I relax PHP's open\_basedir restriction?](https://stackoverflow.com/questions/223800/how-can-i-relax-phps-open-basedir-restriction) – aynber Jun 25 '19 at 12:44
  • "Unknown on line 0" generally means that the function is being called from some part of PHP that can't easily be attributed to a line in your program (although sometimes it's just a bug in the runtime). I've mostly seen it when errors are happening during process shutdown because some user-defined resource needs cleaning up, e.g. object destructors, session close handlers, stream wrapper close hooks. – IMSoP Jun 25 '19 at 13:38
  • Any suggestion on how to track that down? I'm pulling what little hair I have left out. All the errors are errors telling me there is an open_basedir restriction in effect. It's so frustrating! – user1530205 Jun 25 '19 at 13:46
  • Something to do with Windows vs. Linux? Or links? Allowed paths are `/var/www/vhosts/ivech.co.uk/:/tmp/`, but you're apparently accessing a directory ` C:\Inetpub\vhosts\ivech.co.uk\logs\php_errors\choicerentals.ivech.co.uk` ? Obviously C:\Inetpub\vhosts\ivech.co.uk\ is not the same as /var/www/vhosts/ivech.co.uk – Jonnix Jun 25 '19 at 14:02
  • 100% agree with you and I'm assuming thats part of the problem sooo........ where is php getting the information from that is telling it to write the errors to C:\Inetpub\vhosts\ivech.co.uk\logs\php_errors\choicerentals.ivech.co.uk and how can I change that? thanks – user1530205 Jun 25 '19 at 14:08

2 Answers2

0

Your PHP settings have an incorrect value for the error_log setting, which points to a directory you've told PHP it shouldn't write to. This is causing a Warning during the startup of every request, as PHP processes your settings files, before it's reached the first line of your PHP code. Since it can't write to the log file specified, it falls back to the default, which is to echo to "standard error", which is eventually picked up and put in the generic log file you're seeing.

There are several places a configuration variable can be set, discussed in the Runtime Configuration chapter of the PHP manual; for instance, there may be one or more php.ini files, and settings passed in from Apache configuration files. Either the setting has been copied incorrectly from one site to another, or it is being set in a global configuration file which is used by both sites.

The peculiar path logged (C:\Inetpub\vhosts\ivech.co.uk\logs\php_errors\choicerentals.ivech.co.uk\php_error.log) suggests that the setting is incorrect anyway, apart from mentioning the wrong site; possibly it is specifying a relative path rather than an absolute one (starting with C:\).

As pointed out in comments, it looks like the open_basedir setting is wrong as well, as it appears to be in Linux format, whereas the log message suggests you're running on Windows.

IMSoP
  • 89,526
  • 13
  • 117
  • 169
  • So based on what you're saying, the only reason I'm getting so many errors is because every time a php script runs or an ajax call to a PHP script, it's gathering relevant information such as where to write an error to if there is one. Failing to connect to the relevant location and therefore giving an error directly in the PHP logs instead? – user1530205 Jun 25 '19 at 14:36
  • Yes, that's right, except the last part should say "...directly in the *web server* logs" (or possibly even "system logs"). The PHP logs are the location it *should* be going to, but can't open. That's why you end up with the rather awkward prefix "WARNING: ... NOTICE: PHP message: PHP Warning:" If PHP was able to log it, it would just begin "PHP Warning", but it's been passed around between various processes before anything was able to write it to a file. – IMSoP Jun 25 '19 at 14:42
  • Ok thanks. So one final thing. It's a plesk server running on centOS7 (which really makes the whole windows path thing baffling) but I've managed to override the PHP error_log directive with error_log = "{WEBSPACEROOT}/logs/corrigansni.ivech.co.uk" (double checked this with phpinfo()) and the errors appear to have disappeared. Should that be a path to a folder or a path to a specific file. secondly. Apart from the overall PHP.ini file where else could it have been getting that directive from? it's the same on roughly 50% of my subdomains then different on others. – user1530205 Jun 25 '19 at 14:50
0

For anyone that ever finds this I found my problem. I had a silly little file called .user.ini in my folder structure which was setting the windows path. Must have been there from an old windows server we used to use.

user1530205
  • 302
  • 6
  • 19