概述

在upload上传图片时发现无法上传成功,通过官方资料发现TMPDIR目录未指定。

FastCGI sent in stderr: "PHP message: PHP Notice: Unknown: file created in the system's temporary directory in Unknown on line 0PHP message: PHP Warning: Unknown: open_basedir restriction in effect. File(/tmp) is not within the allowed path(s): (/wwwroot) in Unknown on line 0PHP message: PHP Warning: File upload error - unable to create a temporary file in Unknown on line 0" while reading response header from upstream
<?php
    echo sys_get_temp_dir() . PHP_EOL;
?>

[root@php-server ~]#php /wwwroot/aa.php 
/tmp

解决

修改 php-fpm配置文件

env[TMP] = /wwwroot/tmp
env[TMPDIR] = /wwwroot/tmp
env[TEMP] = /wwwroot/tmp
其他问题

修改完成后又有报错

FastCGI sent in stderr: "PHP message: PHP Notice: Unknown: file created in the system's temporary directory in Unknown on line 0PHP message: PHP Warning: File upload error - unable to create a temporary file in Unknown on line 0" while reading response header from upstream, client:
解决方法

忘记创建临时目录,将临时目录创建并赋予用户组权限后重启php服务

END

本文标题:open_basedir restriction in effect. File(/tmp) is not within the allowed path(s):

本文作者:宇宙最帅的男人

本文链接:https://lolicp.com/linux/202116121.html

版权声明:转载或者引用本文内容请注明来源及原作者,本文著作权归作者 (宇宙最帅的男人) 所有。

除非另有说明,本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议

最后修改:2021 年 06 月 16 日
如果觉得我的文章对你有用,请随意赞赏