Magento – Magento still writing in system /tmp

cachece-1.9.2.2file-permissions

I've read several threads about this, but still can't resolve the issue.

We use apache + PHP-FPM. In Magento tree files are owned by apache-user:dev. Now, using 775 / 664 for dirs and files. Also, we disabled redis and using files for backend cache.

When I clear / flush cache in backend, most files get written in magento-dir/var/cache as usual, but I noticed some files are written in system /tmp (not in /tmp/magento). Actually, 14 files with "Locale" serialized data:

zend_cache---internal-metadatas...

zend_cache---Zend_LocaleC...

zend_cache---Zend_LocaleL...

That is, some files get written correctly in var/cache and others in system /tmp directory.

Running scripts in magento root to get system var dir:

<?php
echo sys_get_temp_dir();
?>

returns /tmp

and magento var:

<?php 

require_once('app/Mage.php'); //Path to Magento
umask(0);
Mage::app();

$var_dir = Mage::getModel('core/config')->getVarDir(); 
echo $var_dir;

Returns magento-dir/var, as expected.

Also, permissions seem correct, since most files get written properly.

Anyone with this behavior?

Best Answer

It happens when you do not have writing permissions on var folder. Make sure you can read and write it.