简体   繁体   中英

How to fix this symfony permission error?

On my live site I'm facing this problem when I load my browser:

ContextErrorException in FileProfilerStorage.php line 158: Warning: file_put_contents(/var/www/html/var/cache/dev/profiler/c9/73/fb73c9): failed to open stream: Permission denied

How can I fix this problem at the live site?

Run

sudo chmod -R 777 var/cache

in your project directory, later clear the cache using

app/console cache:clear

An reset permissions again

sudo chmod -R 777 var/cache

Every time the cache is cleared reset permissions of folder cache to avoid this type of problems with created files during the clear process.

Note: app/console could be bin/console

You should try this set of permissions which are recommended by AWS:

First you need through a terminal go to your project directory and run the command:

ls -las

where you will see something like:

在此处输入图片说明

Note the columns where it says: webapp , that tells you which user/group have access to your project, so what you need to do now is go to your apache config file (normally you can find it in linux on: /etc/httpd/conf/httpd.conf) once you opened the file by using vi, vim or you favourite text editor you should look for User & Group and ensure that the user/group is the same one that the one from the image above and ensure that the user belongs to the group you have had configured or set on your httpd.conf then you should run the following command to apply the right set of permissions for users & groups by doing:

sudo chmod 2775 /var/www
find /var/www -type d -exec sudo chmod 2775 {} \;
find /var/www -type f -exec sudo chmod 0664 {} \;

and now it should work fine.

Note that /var/www is an example of where you could host your project but it depends on your configuration in the file httpd.conf

Hope this helps.

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