phpmyadmin使用时提示-变量 $cfg[‘TempDir’] (./tmp/)无法访问

Phpmyadmin 在管理数据库时,提示 “变量 $cfg[‘TempDir’] (./tmp/)无法访问。phpMyAdmin无法缓存模板文件,所以会运行缓慢。” 这个提示在phpmyadmin实际使用中并不会中断操作,可以忽略不看,提示也只是说会导致运行缓慢。 如果对这一提示不想忽略掉,要处理掉的话,需要对临时文件夹 tmp的权限进行修改。

按照网络上很多文章给的答案,大部分是梭哈式操作,直接给 tmp文件夹“777”权限,但是777权限意味着所有用户对于tmp文件夹都会读写致性的权限,会增加服务器风险。

翻阅了下官方文档,给出的解决方法是修改tmp文件加的所有者为网站所有者,然后设置“700”权限。就可以解决了。也不会增加风险。

chown www-data:www-data tmp
chmod 700 tmp

 

下面是官方原文:Configuration — phpMyAdmin 5.1.4 documentation

The name of the directory where temporary files can be stored. It is used for several purposes, currently:

This directory should have as strict permissions as possible as the only user required to access this directory is the one who runs the webserver. If you have root privileges, simply make this user owner of this directory and make it accessible only by it:

chown www-data:www-data tmp
chmod 700 tmp

If you cannot change owner of the directory, you can achieve a similar setup using ACL:

chmod 700 tmp
setfacl -m "g:www-data:rwx" tmp
setfacl -d -m "g:www-data:rwx" tmp

If neither of above works for you, you can still make the directory chmod 777, but it might impose risk of other users on system reading and writing data in this directory.

Warning

Please see top of this chapter (Web server upload/save/import directories) for instructions how to setup this directory and how to make its usage secure.

 

 

此条目发表在搜索引擎优化分类目录。将固定链接加入收藏夹。