简体   繁体   中英

CakePHP: Permission denied (13)

I would like to know why the cakephp is giving this error.. I changed all that files to 777 permission but doesn't work :(

Warning: session_start() [function.session-start: open(/tmp/sess_c885be0c60e567d6c6c7571c61601f71, O_RDWR) failed: Permission denied (13) [CORE/Cake/Model/Datasource/CakeSession.php line 618]

session_start - [internal], line 
CakeSession::_startSession() - CORE/Cake/Model/Datasource/CakeSession.php, line 618
CakeSession::start() - CORE/Cake/Model/Datasource/CakeSession.php, line 190
CakeSession::check() - CORE/Cake/Model/Datasource/CakeSession.php, line 216
SessionHelper::flash() - CORE/Cake/View/Helper/SessionHelper.php, line 123
include - APP/View/Layouts/default.ctp, line 53
View::_evaluate() - CORE/Cake/View/View.php, line 945
View::_render() - CORE/Cake/View/View.php, line 907
View::renderLayout() - CORE/Cake/View/View.php, line 535
View::render() - CORE/Cake/View/View.php, line 479
Controller::render() - CORE/Cake/Controller/Controller.php, line 948
ScriptsController::javascript() - APP/Controller/ScriptsController.php, line 31
ReflectionMethod::invokeArgs() - [internal], line ??
Controller::invokeAction() - CORE/Cake/Controller/Controller.php, line 486
Dispatcher::_invoke() - CORE/Cake/Routing/Dispatcher.php, line 187
Dispatcher::dispatch() - CORE/Cake/Routing/Dispatcher.php, line 162
[main] - APP/webroot/index.php, line 111

First off, chmodding everything to 777 is a really bad idea . It means giving every user on the server full access to everything, meaning anyone with access to your webserver can edit or even delete your files. Comparing it with a real-life issue, it would be like like there's a problem with the lock on your car door and you just decide to never lock your door again. It's avoiding the problem rather than fixing it and you shouldn't be surprised if at one day your radio is gone.

That being said, the core of your problem is that your Cake application (or actually the internal PHP function session_start that it is calling) does not have permissions to write the file /tmp/sess_c885be0c60e567d6c6c7571c61601f71 , which is the PHP session file. By default, most PHP installations try to write their session to the /tmp folder on the server. In this case, that doesn't seem to work.

These are a few of the solutions that are possible:

  1. If the application is running on a server that's not administered by yourself (eg if you have a paid hosting plan and just have FTP access to your own domain folder), contact the person/party that administers the server and ask them to make the /tmp directory writable. They should be able to properly fix this.

  2. In your app/Config/core.php , set a different way to have Cake sessions stored. There are several options available, all explained in the file itself (right here ). Using the cake , cache or database option should make sure your sessions can always be properly accessed.

  3. If you administer the web server yourself, you could give PHP sessions their own folder with the proper access rights. This step consists of a few tasks:

    • Create a folder for the sessions, a common path is /var/lib/php/session
    • Make your webserver user (usually apache or www-data ) is the owner of this folder (eg chown apache.apache /var/lib/php/session )
    • Set the proper chmod level to the folder, since only the webserver's user/group would need full access, a chmod of 640 will do ( chmod 640 /var/lib/php/session )
    • Edit the session.save_path in your php.ini file to this folder, so you'll have a line that says: session.save_path = "/var/lib/php/session"
    • Restart your webserver and you should be good to go!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM