PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, March 2, 2022

[FIXED] CakePHP 3 Cache File Permissions

 March 02, 2022     amazon-ec2, cakephp, cakephp-3.4, cakephp-3.x, cron     No comments   

Issue

I have a CakePHP 3 app with shells that I run from crontab.

When I run the shells through crontab, it creates cache files owned by the user running the crontab, which is not the user that runs apache...

Sometimes when I run the crontab the cached models are owned by apache and the shell fails, sometimes when I visit a page the models are owned by ec2-user and the page fails...

I posted a question on github, https://github.com/cakephp/cakephp/issues/11265#issuecomment-333951638

I was told to modify the chmod option for the cache config, I tried the following but it didn't work...

/**
 * Configure the cache adapters.
 */
'Cache' => [
    'default' => [
        'className' => 'File',
        'path' => CACHE,
        'url' => env('CACHE_DEFAULT_URL', null),
        'chmod' => 777
    ],

Any ideas on how I can make the default file permissions 777 on the cake cache files?


Solution

I would suggest having the chron run as the correct user OR having the chron task change owner and keep permissions as set but if you really want to have it all as it is and just change the permissions then you can use the mask option which I assume is what they meant.

Cache Config Options

Set using the following:

'Cache' => [
    'default' => [
        'mask' => 0777,
        // other config options
    ],
]


Answered By - KaffineAddict
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing