4

I am running the following cake command:

./Console/cake schema create DbAcl

Now the database tables are created but at the end im getting the following error:

Warning: SplFileInfo::openFile(/var/www/bloglic-2013/cake/app/tmp/cache/persistent/myapp_cake_core_object_map): failed to open stream: Permission denied in /var/www/bloglic-2013/cake/lib/Cake/Cache/Engine/FileEngine.php on line 313


Warning Error: SplFileInfo::openFile(/var/www/bloglic-2013/cake/app/tmp/cache/persistent/myapp_cake_core_file_map): failed to open stream: Permission denied in [/var/www/bloglic-2013/cake/lib/Cake/Cache/Engine/FileEngine.php, line 313]

Warning Error: _cake_core_ cache was unable to write 'file_map' to File cache in [/var/www/bloglic-2013/cake/lib/Cake/Cache/Cache.php, line 309]

Warning Error: SplFileInfo::openFile(/var/www/bloglic-2013/cake/app/tmp/cache/persistent/myapp_cake_core_method_cache): failed to open stream: Permission denied in [/var/www/bloglic-2013/cake/lib/Cake/Cache/Engine/FileEngine.php, line 313]

Warning Error: _cake_core_ cache was unable to write 'method_cache' to File cache in [/var/www/bloglic-2013/cake/lib/Cake/Cache/Cache.php, line 309]

Now I added chmod 755 to all of the folders, and redone the command, but without any luck. Can anyone tell me how can I fix this?

Update

Abit more information:

Here is my rights to the folders mentioned above:

marc@Marc> cd /var/www/bloglic-2013/cake
marc@Marc> ls -ld app/tmp/cache/persistent/
drwxrwxrwx 2 marc marc 4096 Aug 13 22:50 app/tmp/cache/persistent/

marc@Marc> chmod 755  app/tmp/cache/persistent/
marc@Marc> ls -ld lib/Cake/Cache/
drwxrwxr-x 3 marc marc 4096 Aug  2 10:16 lib/Cake/Cache/

marc@Marc> ls -ld lib/Cake/Cache/Cache.php
-rwxr-xr-x 1 marc marc 16179 Aug  2 10:16 lib/Cake/Cache/Cache.php

marc@Marc> ls -ld lib/Cake/Cache/Engine/
drwxr-xr-x 2 marc marc 4096 Aug  2 10:16 lib/Cake/Cache/Engine/

marc@Marc> ls -ld lib/Cake/Cache/Engine/FileEngine.php 
-rwxr-xr-x 1 marc marc 9759 Aug  2 10:16 lib/Cake/Cache/Engine/FileEngine.php

marc@Marc> ls -ld lib/Cake/Cache/Cache.php
-rwxr-xr-x 1 marc marc 16179 Aug  2 10:16 lib/Cake/Cache/Cache.php

Also note that i cannot open or run any of my actions and views without getting the same messages

More information

marc@Marc /var/www/bloglic-2013/cake $ ls -l app/tmp/cache/persistent/
total 44
-rw-r--r-- 1 www-data www-data  945 Aug 13 18:45 controllers_hashes.txt
-rw-rw-r-- 1 www-data www-data   43 Aug 13 18:53 myapp_cake_core_acl_en-us
-rw-rw-r-- 1 marc     marc       43 Aug 13 23:04 myapp_cake_core_cake_console_
-rw-rw-r-- 1 marc     marc       43 Aug 13 23:04 myapp_cake_core_cake_dev_
-rw-rw-r-- 1 www-data www-data   43 Aug 13 22:59 myapp_cake_core_cake_dev_en-us
-rw-rw-r-- 1 www-data www-data   43 Aug 13 22:59 myapp_cake_core_cake_en-us
-rw-rw-r-- 1 www-data www-data   43 Aug 13 22:59 myapp_cake_core_default_en-us
-rw-rw-r-- 1 www-data www-data 5686 Aug 13 22:59 myapp_cake_core_file_map
-rw-rw-r-- 1 www-data www-data  163 Aug 13 22:59 myapp_cake_core_method_cache
-rwxr-xr-x 1 marc     marc      441 Aug 13 22:21 myapp_cake_core_object_map
Marc Rasmussen
  • 19,771
  • 79
  • 203
  • 364
  • i'm guessing the user/process trying to access the cache files is not marc, and has no write permissions. try 777 or change the user to marc – Elpy Aug 13 '13 at 21:24
  • @Elpy He tries to execute command `./Console/cake schema create DbAcl` from console, so he is probably marc. – Serge S. Aug 13 '13 at 21:25
  • Marc, do you have already files `myapp_cake_core_object_map`, `myapp_cake_core_file_map` etc? Could you show `ls -l app/tmp/cache/persistent/` (list files)? Maybe you try to overwrite them, but have no permission to files themselves, not the directory. – Serge S. Aug 13 '13 at 21:27
  • @SergeS. ive added the output of that command – Marc Rasmussen Aug 13 '13 at 21:30
  • Use `-l` option (minus L, not minus one). I need a long listing to see permissions and owners. Anyway, if you delete these files, you may get success. – Serge S. Aug 13 '13 at 21:33
  • Have you tried to remove all listed files? – Serge S. Aug 13 '13 at 21:44
  • @SergeS. im no longer getting the error however isnt those files being used elsewhere where i might need them? – Marc Rasmussen Aug 13 '13 at 21:49
  • Some of them are used by CakePHP to store cache, to avoid `SHOW TABELS` towards database, and object lookups in your application. Normally CakePHP should be able to write to those files – Serge S. Aug 13 '13 at 21:54
  • @SergeS. Does that mean i need them or not? – Marc Rasmussen Aug 13 '13 at 21:55
  • CakePHP needs them. I didn't check if it even may work without access to them. Note that CakePHP creates them automatically. – Serge S. Aug 13 '13 at 22:22

1 Answers1

4

You (user marc) are not in group www-data, so you have no write access to the files:

myapp_cake_core_file_map
myapp_cake_core_method_cache

I recommend to delete those files, set chmod 755 for all tmp folders, and let CakePHP to create them. To let CakePHP create tmp files just access any web page of your application, not run console command.

You will see then who is owner of the files, and you'll know user under which your application runs.

If after this you'll need to use cake console command, just add yourself to the group of application:

usermod -a -G www-data marc
Serge S.
  • 4,855
  • 3
  • 42
  • 46
  • usermod -a -G marc gives usermod: Permission denied. usermod: cannot lock /etc/passwd; try again later – Marc Rasmussen Aug 13 '13 at 21:58
  • Try `sudo usermod ...`. You may have no rights to do this, unless you know the admin. – Serge S. Aug 13 '13 at 22:20
  • if i try this i stil do not get access to the file and the flaw continue only if i delete those files i can go through without a warning – Marc Rasmussen Aug 13 '13 at 22:25
  • If I do 755, and let CakePHP recreate files, it won't because it has permission denied. What does that mean and how would you fix it? – mgPePe Sep 19 '13 at 14:49
  • `chmod 755` allows writing only for owner of the folder. If owner of `tmp/models` is not `www-data`, than CakePhp will be unable to create those files. You could change ownership of folder to `www-data` using command `chown` to fix this. There is a number of another options. See http://www.linux.org/threads/file-permissions-chmod.4094/ to understand file permission concepts. – Serge S. Sep 19 '13 at 15:16