Cannot write to cache directory

I just installed the Pim on a Debian, after a while of using I get the following message :

Failed to write cache file “/home/pim/public_html/var/cache/dev/twig/07/0750e3c3b9ce47a08d943c6c37ca77f7f1f7afe6294830dc82a8cff820624b2a.php”.
So it’s a folder permission problem.
Why is this happening? is is a symfony or a Pimcore problem? thank you

Hm strange, it seems more like a configuration problem.
That are the permissions set to? With what user is php executed on your setup?


Hi, thanks for replying, me too I’m sure it’s a config problem bcause the var/cache and all subfolder are set to 755.
I am under Virtualmin, Debian 8.9, PHP 7.1.12, I created a virtualhost, a user called pim, and all scripts are owned by “pim”

and php is also executed as pim?

just do try to delete the var/cache folder as the user, that is also used for php.
this should be possible.

It’s what I do, but after a while the same problem happens.
how to execute an arbitrary php file since there is the rewrite?
I would like to execute whoami in a php file to ensure it’s the pim user.

Check if SELinux is enabled. If so, disable it.

It causes weird problems with PHP permissions though the permissions on unix are correct. Experienced it a lot of times on my own :wink:

Hi I checked with sestatus SELinux is not enabled

What is your setup? Apache or nginx/PHP-FPM?

My config is Apache FastCGI

Hm, thats the only one I never used :smiley:

Check which user is configured to run Apache FastCGI and maybe you could check which user/group owns the folder the twig file wants to be written to. In your example the folder would be “07”.

Hi I checked ths user that execute the php files, it’s pim, so no problem on this side. As I said the problem is not happening at the start, but after a few hours.

Is by any chance your maintenance job (cron job) NOT running under the same user as your web server?
It is very important that your web server, CLI PHP and cron job are all running under the same user.
Under which user did you add the cron job?

Cheers, Igor

I was not aware of the cronjob at all ! can you point me to a reference resource? I just started to use Pimcore, so I don’t think there is any cronjob to be scheduled?

See nr. 5 (Maintenance Cron Job) on this page:

So, a different question. Are you running any CLI commands? Under which user are you running them?

Cheers, Igor

I do not run any CLI command so far.

Sorry, then I am also out of ideas.
But do check who is the owner of the cache folder after you get the error. That might give a clue.

Cheers, Igor

all the folder are owned by “pim” here is a screenshot of the error i get again this morning

I looked at the file /vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php

        $profileIndexed = is_file($file);
    if (!$profileIndexed) {
        // Create directory
        $dir = dirname($file);
        if (!is_dir($dir) && false === @mkdir($dir, 0777, true) && !is_dir($dir)) {
            throw new \RuntimeException(sprintf('Unable to create the storage directory (%s).', $dir));

it tries to create a 777 dir, however the dir that are successfully created are 755

any luck in symfony forums? this seems to be not a pimcore specific problem.
maybe you get some hints there?

Thank you so much! After having installed something with composer with sudo I realised that the var/cache/prod directory was with root permissions… I followed the steps of
“sudo /opt/bitnami/php/bin/php /opt/bitnami/php/bin/composer.phar”

In my case I had nginx and php-fpm configured as www-data user, also my entire pimcore install dir was owned by www-data.

The issue was Centos default config for SELinux. Disabling them in my pimcore directory solved the issue, but i still had to fiddle around with it to make everything work.