Symfony permission denied

╄→гoц情女王★ 提交于 2019-12-10 09:44:04

问题


Can anyone help me fix the below error message I'm getting? I've finally got Symfony installed on a VM and it seems to be working ok except for the fact that I'm getting occasional messages for things like this:

[1/2] ContextErrorException: Warning: SessionHandler::read(): open(/var/lib/php5/sess_d8qgvn11jdu8rfuo1f0njokc67, O_RDWR) failed: Permission denied (13) 

From what I've picked up from reading around, I'm thinking it's because I have a mismatch between the owner/permissions between linux and the webserver but I don't know how this would happen (I'm just taking this as fact and I don't really understand how/why to prevent making the same mistakes in the future).

Each time I've been getting one of these errors I'm submitting a mix of the below commands to try and fix the problem but I'm guessing it's not the right way to go about it (text in brackets is my understanding/guessing of what they do):

sudo chmod a+x <path> Modifies the permissions of the directory

sudo chmod -R 775 <path> Similar to previous except that it SETS the permissions -R applies it recursively

sudo chown -R <usr>:www-data <path> Changes the owner/group of the directory/file


回答1:


You can take a look at http://symfony.com/doc/current/book/installation.html on "Setting up Permissions" section. It talks about app/logs and app/cache, but you can do the same on any other folder you need




回答2:


In Symfony3, I had this error after installing symfony in a new fresh VPS, I resolved it using the already noted : chmod -R 775 for the LOG and CACHE but now for the SESSIONS folder.

chmod -R 775 var/sessions



回答3:


Similar symfony permissions issue this worked for me:

sudo chown <yourcliusername> /var/lib/php5

Source: https://stackoverflow.com/a/33991320/1438029




回答4:


Duplicated answer from https://stackoverflow.com/a/39346877/4276533

You can set path for sessions manually. See Symfony doc on sessions directory.

# app/config/config.yml
framework:
    session:
        handler_id: session.handler.native_file
        save_path: '%kernel.root_dir%/sessions'


来源:https://stackoverflow.com/questions/27367388/symfony-permission-denied

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!