“Could not determine temp directory, please specif

2019-03-19 17:30发布

Magento admin throws an exception:

Could not determine temp directory, please specify a cache_dir manually

It is fresh instalation on new hosting package.

4条回答
冷血范
2楼-- · 2019-03-19 17:57

Usually it will happen in shared web hosting, but also some times on individual server, if the permission of tmp folder is set wrong.

Many people suggest to modify the file: /lib/Zend/Cache/Backend/File.php to fix this problem. However, it may be a trap when you upgrade your Magento, as this file resides as core file of Magento. I recommend to use Magento's override feature.

Firstly, copy /lib/Zend/Cache/Backend/File.php to /app/code/local/Zend/Cache/Backend/File.php.

Then on line 91 or near this line, you will find:

'cache_dir' => null,

Change to:

'cache_dir' => "var/tmp/",

You can change the cache folder wherever you want. Now create a directory named tmp(or whatever name you have given above) under var folder and change the permission to 777 if necessary.

查看更多
做自己的国王
3楼-- · 2019-03-19 17:59
  1. Create tmp folder in root of your magento installation with 777 permissions.
  2. Open lib/Zend/Cache/Backend/File.php
  3. Find $_options property and change line: 'cache_dir' => null, to 'cache_dir' => 'tmp',
  4. Refresh page.
查看更多
看我几分像从前
4楼-- · 2019-03-19 18:09

This is only the permission issue. Just set the 777 permission to the cache directory and you are all done. try it.

For more details you can follow the link.

When ever you set the permission be sure it is recurrsively set..

chmod 777 -R /var/cache

this is the function


    public function getTmpDir()
        {
            $tmpdir = array();
            foreach (array($_ENV, $_SERVER) as $tab) {
                foreach (array('TMPDIR', 'TEMP', 'TMP', 'windir', 'SystemRoot') as $key) {
                    if (isset($tab[$key])) {
                        if (($key == 'windir') or ($key == 'SystemRoot')) {
                            $dir = realpath($tab[$key] . '\\temp');
                        } else {
                            $dir = realpath($tab[$key]);
                        }
                        if ($this->_isGoodTmpDir($dir)) {
                            return $dir;
                        }
                    }
                }
            }
            $upload = ini_get('upload_tmp_dir');
            if ($upload) {
                $dir = realpath($upload);
                if ($this->_isGoodTmpDir($dir)) {
                    return $dir;
                }
            }
            if (function_exists('sys_get_temp_dir')) {
                $dir = sys_get_temp_dir();
                if ($this->_isGoodTmpDir($dir)) {
                    return $dir;
                }
            }
            // Attemp to detect by creating a temporary file
            $tempFile = tempnam(md5(uniqid(rand(), TRUE)), '');
            if ($tempFile) {
                $dir = realpath(dirname($tempFile));
                unlink($tempFile);
                if ($this->_isGoodTmpDir($dir)) {
                    return $dir;
                }
            }
            if ($this->_isGoodTmpDir('/tmp')) {
                return '/tmp';
            }
            if ($this->_isGoodTmpDir('\\temp')) {
                return '\\temp';
            }
            Zend_Cache::throwException('Could not determine temp directory, please specify a cache_dir manually');
        }

defined in file lib/Zend/Cache/Backend.php

http://www.webtechnologycodes.com/magento-error-could-not-determine-temp-directory-please-specify-a-cache_dir-manually/

查看更多
啃猪蹄的小仙女
5楼-- · 2019-03-19 18:12

Create an info.php and check for the path beneath upload_tmp_dir to be writable for the webserver.

<?php phpinfo();

Otherwise set the path in your hosting environment. Beware that this setting can not be placed within .htaccess files but some hosters allow individual php.ini files to be placed in your docroot:

upload_tmp_dir = /path/to/docroot/var/tmp/
查看更多
登录 后发表回答