AOEpeople / Aoe_ClassPathCache

Class path cache for Magento autoloader
http://www.fabrizio-branca.de/magento-class-path-cache.html
Open Software License 3.0
49 stars 16 forks source link

Permission denied on classPathCache.php #23

Open Maikel-Koek opened 9 years ago

Maikel-Koek commented 9 years ago

Hello,

We ran into an issue on one of our clients' servers. After we run the Mage cron, all the pages stay blank, and lines like the following appear in our error_log:

[Tue Dec 02 09:34:38 2014] [error] [client 31.160.176.209] PHP Warning:  file_get_contents(/var/www/vhosts/ts-shops.nl/httpdocs/var/cache/classPathCache.php): failed to open stream: Permission denied in /var/www/vhosts/ts-shops.nl/httpdocs/.modman/Aoe_ClassPathCache/app/code/local/Varien/Autoload.php on line 164, referer: http://www.ts-shops.nl/index.php/admin/scheduler/index/key/24a06a7cd7b89deb8d0ed5a0c4fc042f/
[Tue Dec 02 09:34:39 2014] [error] [client 66.249.67.74] PHP Warning:  file_get_contents(/var/www/vhosts/ts-shops.nl/httpdocs/var/cache/classPathCache.php): failed to open stream: Permission denied in /var/www/vhosts/ts-shops.nl/httpdocs/.modman/Aoe_ClassPathCache/app/code/local/Varien/Autoload.php on line 164
[Tue Dec 02 09:34:41 2014] [error] [client 80.100.41.121] PHP Warning:  file_get_contents(/var/www/vhosts/ts-shops.nl/httpdocs/var/cache/classPathCache.php): failed to open stream: Permission denied in /var/www/vhosts/ts-shops.nl/httpdocs/.modman/Aoe_ClassPathCache/app/code/local/Varien/Autoload.php on line 164, referer: http://www.ts-shops.nl/index.php/admin/sales_order_create/index/key/35ebc65ff9cf18ac1eef94895619d61d/

When we delete the classPathCache.php file, all is well again. We noticed that the file user and group changes when we run the cron.php file, and this has to be the cause of the errors (and thus the blank pages).

When created by calling a webpage: -rw-rw-r--. 1 apache apache 148817 dec 2 10:42 classPathCache.php When created after running cron.php: -rw-rw-r--. 1 ts-83shop psacln 172K dec 2 10:32 classPathCache.php

I tried changing the file permissions to 0777 in app/code/local/Varien/Autoload.php (see below), but this didn't solve the problem.

...
                if (file_put_contents($tmpFile, $fileContent)) {
                    if (@rename($tmpFile, self::getCacheFilePath())) {
                        @chmod(self::getCacheFilePath(), 0777);
                    } else {
                        @unlink($tmpFile);
                    }
                }
...

How can we solve this issue?

tmotyl commented 9 years ago

can you configure your cron job to run as a apache user?

LeeSaferite commented 9 years ago

You should be running cron jobs as the same user that the server uses.