前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >open_basedir restriction in effect. File(/tmp) is not within the allowed path(s):

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

作者头像
BinGo_Blog
发布2022-11-01 16:40:18
6720
发布2022-11-01 16:40:18
举报
文章被收录于专栏:BinGo's BlogBinGo's Blog
概述

在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

代码语言:javascript
复制
<?php
    echo sys_get_temp_dir() . PHP_EOL;
?>

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

修改 php-fpm配置文件

代码语言:javascript
复制
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服务

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 概述
  • 解决
    • 其他问题
      • 解决方法
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档