php 无法对 tmp 文件夹编辑的问题

Chevereto 图床上传图片的时候发现一个故障,没有写入和移动的权限。

刚开始的时候,我想限制 PHP 只访问指定的网站目录,然后保证网站安全性。于是配置的是 open_basedir = “/web/”

但是后来发现,php 脚本里有先上传到临时文件夹,然后当拷贝文件到指定目录时,操作执行不了

经过相关排查,最后定位到/tmp/没有允许 php 写入的权限。于是配置成 open_basedir = “/web/:/tmp/”

php 和 tmp 相关可疑的文件权限的配置参数

; Sets the directory name where SOAP extension will put cache files.

; open_basedir, if set, limits all file operations to the defined directory
; and below. This directive makes most sense if used in a per-directory
; or per-virtualhost web server configuration file.
open_basedir = “/web/:/tmp/”

; Directory where the temporary files should be placed.
; Defaults to the system default (see sys_get_temp_dir)
; sys_temp_dir = “/tmp”

; Temporary directory for HTTP uploaded files (will use system default if not
; specified).
;upload_tmp_dir =

; where MODE is the octal representation of the mode. Note that this
; does not overwrite the process’s umask.
;session.save_path = “/tmp”



电子邮件地址不会被公开。 必填项已用*标注