简体   繁体   English

phpMyadmin无法导入文件,错误:open_basedir>已启用,而无法访问/ tmp目录

[英]phpMyadmin can’t import file with error: open_basedir > enabled without access to the /tmp directory

After installing apache-mysql-php on Debian. 在Debian上安装apache-mysql-php之后。 I can't import .sql files to MySQL through phpMyAdmin. 我无法通过phpMyAdmin将.sql文件导入MySQL。 Error says: 错误提示:

Uploaded file cannot be moved, because the server has open_basedir enabled without access to the /tmp directory (for temporary files). 无法移动上载的文件,因为服务器已启用open_basedir,而无法访问/ tmp目录(用于临时文件)。

open_basedir is commented in both /etc/php5/apache2/php.ini and /etc/php5/cli/php.ini and safe_mode is OFF. /etc/php5/apache2/php.ini/etc/php5/cli/php.ini中都注释了open_basedir ,并且safe_mode为OFF。

I set 777 permission to /var/tmp still get the error. 我将777权限设置为/var/tmp仍然收到错误。

While you say that open_basedir is commented out, what is the output of phpinfo() ? 当您说open_basedir被注释掉时, phpinfo()的输出是什么? There should be an open_basedir setting in there. 那里应该有一个open_basedir设置。 And perhaps there is an .htaccess file—or another php.ini config—that is setting open_basedir somewhere. 也许有一个.htaccess文件(或另一个php.ini配置)在某个地方设置了open_basedir That said, according to the official phpMyAdmin docs : 就是说,根据官方的phpMyAdmin文档

Since version 2.2.4, phpMyAdmin supports servers with open_basedir restrictions. 从版本2.2.4开始,phpMyAdmin支持具有open_basedir限制的服务器。 However you need to create temporary directory and configure it as $cfg['TempDir']. 但是,您需要创建临时目录并将其配置为$ cfg ['TempDir']。 The uploaded files will be moved there, and after execution of your SQL commands, removed. 上载的文件将移动到该位置,并且在执行SQL命令后将其删除。

So while you say that open_basedir is commented out—implying it is not being used—perhaps you should open up your phpMyAdmin config and set the cfg_TempDir to point to /var/tmp . 因此,尽管您说open_basedir被注释掉了-暗示它没有被使用-也许您应该打开phpMyAdmin配置并设置cfg_TempDir指向/var/tmp The config.php file is located here in Ubuntu 12.04: config.php文件位于Ubuntu 12.04中:

/usr/share/phpmyadmin/config.inc.php

Note that the error message refers to /tmp/ but you are referring to /var/tmp/ . 请注意,错误消息指向/tmp/但是您指向的是/var/tmp/

Additionally, the issue seems to be covered here in the community wiki reference for PHP related error: 此外,社区Wiki参考中似乎涵盖了PHP相关错误的问题:

The fix is normally to change the PHP configuration, the related setting is called open_basedir. 解决方法通常是更改PHP配置,相关设置称为open_basedir。

Sometimes the wrong file or directory names are used, the fix is then to use the right ones. 有时使用了错误的文件或目录名称,然后使用正确的名称进行修复。

So in your case you can perhaps adjust the php.ini to have this setting: 因此,您可以调整php.ini使其具有以下设置:

open_basedir "/var/tmp/:/tmp/:/"

And note that the only php.ini that matters in a case of web related issues like this is /etc/php5/apache2/php.ini . 并注意,在类似Web的问题中唯一重要的php.ini/etc/php5/apache2/php.ini The CLI php.ini located here /etc/php5/cli/php.ini is strictly for CLI use and has nothing to do with the Apache PHP module. /etc/php5/cli/php.ini所在的CLI php.ini严格供CLI使用,与Apache PHP模块无关。

I had the same problem and solved as follows: 我有同样的问题,并解决如下:
I opened the file /etc/phpmyadmin/apache.conf and found a tag with parameters inside. 我打开文件/etc/phpmyadmin/apache.conf并找到一个带有参数的标签。 The last one was open_basedir 最后一个是open_basedir

php_admin_value open_basedir /usr/share/phpmyadmin/:/etc/phpmyadmin/:/var/lib/phpmyadmin/:/usr/share/php/php-gettext/:/usr/share/javascript/:/usr/share/php/tcpdf/

I simply prepend /tmp/: and that solved my problem 我只是在/ tmp /前面加了一个,就解决了我的问题

php_admin_value open_basedir /tmp/:/usr/share/phpmyadmin/:/etc/phpmyadmin/:/var/lib/phpmyadmin/:/usr/share/php/php-gettext/:/usr/share/javascript/:/usr/share/php/tcpdf/

of course I had to restart apache after that, but that was all. 当然,那之后我不得不重新启动apache,但是仅此而已。

This is a problem of the php.ini file. 这是php.ini文件的问题。 The problem is that the open_basedir is not set. 问题是未设置open_basedir You must set it in php.ini and also set the upload_tmp_dir to be under the open_basedir . 您必须在php.ini设置,并将upload_tmp_dir设置在open_basedir

There is the same problem in Windows. Windows中存在相同的问题。 Can be solved by setting ie open_basedir = C:\\Apache24\\htdocs (use your path to htdocs folder) and upload_tmp_dir = C:\\Apache24\\htdocs\\tmp . 可以通过设置open_basedir = C:\\Apache24\\htdocs (使用htdocs文件夹路径)和upload_tmp_dir = C:\\Apache24\\htdocs\\tmp

An addendum to Viter Rod's answer above is that you also have to grant full access to the tmp folder. 上述Viter Rod答案的附录是,您还必须授予对tmp文件夹的完全访问权限。 So run: 因此运行:

sudo chmod 777 tmp/ 须藤chmod 777 tmp /

It should work after that. 在那之后它应该工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM