Cannot write to cache directory


#1

Hello,
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


#2

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

BR
Christian


#3

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”


#4

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.


#5

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.
Thanks


#6

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:


#7

Hi I checked with sestatus SELinux is not enabled


#8

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


#9

My config is Apache FastCGI


#10

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”.


#11

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.


#12

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


#13

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?


#14

See nr. 5 (Maintenance Cron Job) on this page:
https://pimcore.com/docs/5.0.x/Development_Documentation/Getting_Started/Installation.html

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

Cheers, Igor


#15

I do not run any CLI command so far.


#16

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


#17

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


#18

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


#19

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 docs.bitnami.com/aws/apps/pimcore
“sudo /opt/bitnami/php/bin/php /opt/bitnami/php/bin/composer.phar”