相关疑难解决方法(0)

当通过nginx访问时,Php在/ tmp/systemd-private-nABCDE/tmp中有自己的/ tmp

我发现了php/tmp文件夹有关的奇怪行为.Php在使用时使用另一个文件夹/tmp.PHP 5.6.7,nginx,php-fpm.

我以两种方式执行相同的脚本:通过浏览器和通过shell.但是当它通过浏览器启动时,文件不在真实/tmp文件夹中:

<?php
$name = date("His");

echo "File /tmp/$name.txt\n";

shell_exec('echo "123" > /tmp/'.$name.'.txt');

var_dump(file_exists('/tmp/'.$name.'.txt'));

var_dump(shell_exec('cat /etc/*release | tail -n 1'));
Run Code Online (Sandbox Code Playgroud)

php -f script.php

File /tmp/185617.txt
bool(true)
string(38) "CentOS Linux release 7.0.1406 (Core)
Run Code Online (Sandbox Code Playgroud)

文件在哪里?在/ tmp

$ find / -name 185617.txt
/tmp/185617.txt
Run Code Online (Sandbox Code Playgroud)

如果通过http://myserver.ru/script.php我获取它

File /tmp/185212.txt
bool(true)
string(38) "CentOS Linux release 7.0.1406 (Core)
Run Code Online (Sandbox Code Playgroud)

但文件在哪里?

$ find / -name 185212.txt
/tmp/systemd-private-nABCDE/tmp/185212.txt
Run Code Online (Sandbox Code Playgroud)

为什么php认为/tmp应该在/tmp/systemd-private-nABCDE/tmp

php nginx tmp centos7

21
推荐指数
1
解决办法
1万
查看次数

log_message 在 codeigniter 中的应用程序文件夹下不起作用

我有一个 Codeigniter 应用程序,我在其中记录错误、调试和信息消息。在 config.php 中,我将阈值设置为 4。我可以在 application/log 文件夹中看到日志文件。现在我尝试从控制器的方法中添加自定义日志。我用了

log_message("error", "this is my custom error");
Run Code Online (Sandbox Code Playgroud)

但这不是在日志文件中记录。到目前为止我尝试过的

  • 更改了日志文件位置
  • 更改了日志文件权限
  • 使用“调试”、“信息”更改级别。
  • 应用服务器文件中的更改以查看它是否适用于另一台服务器。

没有写日志。在现有的日志文件中,我可以看到来自核心文件的日志消息。我无法从应用程序文件夹中写入任何内容。

php logging codeigniter

1
推荐指数
1
解决办法
900
查看次数

标签 统计

php ×2

centos7 ×1

codeigniter ×1

logging ×1

nginx ×1

tmp ×1