权限错误运行控制台/蛋糕

时间:2013-07-16 15:31:10

标签: cakephp file-permissions chmod cakephp-bake

我正试图第一次运行蛋糕控制台应用程序。从正在运行app的蛋糕Console/cake文件夹中,我得到以下输出

PHP Warning:  SplFileInfo::openFile(/var/www/virtual_host.com/public_html/app/tmp/cache/persistent/myapp_cake_core_file_map): failed to open stream: Permission denied in /var/www/virtual_host.com/public_html/lib/Cake/Cache/Engine/FileEngine.php on line 314

Warning: SplFileInfo::openFile(/var/www/virtual_host.com/public_html/app/tmp/cache/persistent/myapp_cake_core_file_map): failed to open stream: Permission denied in /var/www/virtual_host.com/public_html/lib/Cake/Cache/Engine/FileEngine.php on line 314

Welcome to CakePHP v2.3.7 Console
---------------------------------------------------------------
App : app
Path: /var/www/virtual_host.com/public_html/app/
---------------------------------------------------------------
Current Paths:

 -app: app
 -working: /var/www/virtual_host.com/public_html/app
 -root: /var/www/virtual_host.com/public_html
 -core: /var/www/virtual_host.com/public_html/lib

Changing Paths:

Your working path should be the same as your application path. To change your path use the '-app' param.
Example: -app relative/path/to/myapp or -app /absolute/path/to/myapp

Available Shells:

[CORE] acl, api, bake, command_list, console, i18n, schema, server, test, testsuite, upgrade

To run an app or core command, type cake shell_name [args]
To run a plugin command, type cake Plugin.shell_name [args]
To get help on a specific command, type cake shell_name --help

Warning Error: SplFileInfo::openFile(/var/www/virtual_host.com/public_html/app/tmp/cache/persistent/myapp_cake_core_file_map): failed to open stream: Permission denied in [/var/www/virtual_host.com/public_html/lib/Cake/Cache/Engine/FileEngine.php, line 314]

Warning Error: _cake_core_ cache was unable to write 'file_map' to File cache in [/var/www/virtual_host.com/public_html/lib/Cake/Cache/Cache.php, line 310]

这是ls -l <​​/ p>的输出

drwxrwxr-x 3 DevinCrossman DevinCrossman 4096 Jul 16 14:17 Config
drwxrwxr-x 4 DevinCrossman DevinCrossman 4096 Jul 16 14:17 Console
drwxrwxr-x 3 DevinCrossman DevinCrossman 4096 Jul 16 14:17 Controller
-rw-rw-r-- 1 DevinCrossman DevinCrossman  701 Jul 16 14:17 index.php
drwxrwxr-x 2 DevinCrossman DevinCrossman 4096 Jul 16 14:17 Lib
drwxrwxr-x 3 DevinCrossman DevinCrossman 4096 Jul 16 14:17 Locale
drwxrwxr-x 4 DevinCrossman DevinCrossman 4096 Jul 16 14:17 Model
drwxrwxr-x 2 DevinCrossman DevinCrossman 4096 Jul 16 14:17 Plugin
drwxrwxr-x 4 DevinCrossman DevinCrossman 4096 Jul 16 14:17 Test
drwxrwxrwx 6 DevinCrossman DevinCrossman 4096 Jul 16 14:17 tmp
drwxrwxr-x 2 DevinCrossman DevinCrossman 4096 Jul 16 14:17 Vendor
drwxrwxr-x 9 DevinCrossman DevinCrossman 4096 Jul 16 14:17 View
drwxrwxr-x 6 DevinCrossman DevinCrossman 4096 Jul 16 14:17 webroot

我尝试使用基于this other SO question

的以下内容修改Config / core.php
Cache::config('_cake_core_', array(
    'engine' => $engine,
    'prefix' => 'cake_core_',
    'path' => CACHE . 'persistent' . DS,
    'serialize' => ($engine === 'File'),
    'duration' => $duration,
    'mask' => 0666
));

Cache::config('_cake_model_', array(
    'engine' => $engine,
    'prefix' => 'cake_model_',
    'path' => CACHE . 'models' . DS,
    'serialize' => ($engine === 'File'),
    'duration' => $duration,
    'mask' => 0666
));

但它没有改变任何东西。

任何人都知道我需要更改哪些权限?是否需要更改干净安装的权限是正常的? (app / tmp除外我知道这很正常)

3 个答案:

答案 0 :(得分:2)

app/tmp中的文件是使用模式 664创建的,因此属于www-data的用户(或 Apache)会运行with)允许改变它们。

所以跑步:

sudo adduser mich www-data
newgrp www-data

为我解决了这个问题。

HTH

答案 1 :(得分:1)

将所有权DevinCrossman:整个蛋糕目录sudo chown -R DevinCrossman:www-data .的www-data放在vhost的根目录中。

网络服务器(www-data的成员)需要能够在app / tmp中写入

答案 2 :(得分:0)

也许还应该

sudo adduser www-data mich

这样mich创建的缓存文件可以通过www-data

访问