$ cat master/src/index-debug.php
<?php
error_log("error message 123");
var_dump(
-a-a-a ini_get('error_log'),
-a-a-a ini_get('log_errors'),
-a-a-a file_get_contents('/var/log/error.log'),
);
$ curl http://localhost:8014/master/src/index-debug.php
string(18) "/var/log/error.log"
string(1) "1"
<b>Warning</b>:-a file_get_contents(/var/log/error.log): Failed to open stream: No such file or directory in <b>/var/www/html/master/src/index-debug.php</b> on line <b>4</b><br /> bool(false)
Why?
On 26/11/2022 12.18, SupaPlex wrote:
$ cat master/src/index-debug.php
<?php
error_log("error message 123");
var_dump(
-a-a-a-a ini_get('error_log'),
-a-a-a-a ini_get('log_errors'),
-a-a-a-a file_get_contents('/var/log/error.log'),
);
$ curl http://localhost:8014/master/src/index-debug.php
string(18) "/var/log/error.log"
string(1) "1"
<b>Warning</b>:-a file_get_contents(/var/log/error.log): Failed to open
stream: No such file or directory in
<b>/var/www/html/master/src/index-debug.php</b> on line <b>4</b><br />
bool(false)
Why?
Does the /var/log directory exist?
Does the user which runs the process have the right to write into the directory?
$ docker run xxx ls -ld /var/log
drwxr-xr-x 1 root root 4096 Aug 23 13:04 /var/log
Il 26/11/22 15:45, SupaPlex ha scritto:
$ docker run xxx ls -ld /var/log drwxr-xr-x 1 root root 4096 Aug 23
13:04 /var/log
Furthermore
file_put_contents('/var/log/error.log', 123);
Output
file_put_contents(/var/log/error.log): Failed to open stream: Permission denied
...
Il 26/11/22 17:52, Lew Pitcher ha scritto:
...
# chown www-data:www-data /var/log/error.log
Problem solved!!!
Since we're here, you can reply to the thread
[docker] error_log() not write inside web page
| Sysop: | Amessyroom |
|---|---|
| Location: | Fayetteville, NC |
| Users: | 65 |
| Nodes: | 6 (0 / 6) |
| Uptime: | 02:40:34 |
| Calls: | 862 |
| Files: | 1,311 |
| D/L today: |
10 files (20,373K bytes) |
| Messages: | 264,324 |