Symfony permission denied

2019-05-09 23:25发布

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

4条回答
\"骚年 ilove
2楼-- · 2019-05-09 23:48

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
查看更多
Deceive 欺骗
3楼-- · 2019-05-09 23:49

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

查看更多
Animai°情兽
4楼-- · 2019-05-09 23:54

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'
查看更多
爱情/是我丢掉的垃圾
5楼-- · 2019-05-10 00:01

Similar symfony permissions issue this worked for me:

sudo chown <yourcliusername> /var/lib/php5

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

查看更多
登录 后发表回答