R
R
root092021-07-16 18:11:47
Access rights
root09, 2021-07-16 18:11:47

How to properly set up chmod for laravel?

It is not possible to properly configure chmod folder permissions for laravel.
Found a topic on stackoverflow
https://stackoverflow.com/questions/30639174/how-t...

Did everything as written there

sudo chown -R $USER:www-data .
sudo find . -type f -exec chmod 664 {} \;   
sudo find . -type d -exec chmod 775 {} \;
sudo chgrp -R www-data storage bootstrap/cache
sudo chmod -R ug+rwx storage bootstrap/cache


But there is a problem, the cache is not cleared.
php artisan cache:clear gives error (works with sudo)
Failed to clear cache. Make sure you have the appropriate permissions.


The most interesting thing is that immediately after executing
sudo chmod -R ug + rwx storage bootstrap/cache
php artisan cache: clear works fine, it clears everything, but if you go to the site, as I understand it, a new cache file is created with rights that do not allow you to delete this file, why is this happening and how can I deal with it?
For the first time such a problem, past sites were loaded without problems, but here, apparently, something was written wrong.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Ukolov, 2021-07-16
@root09

if I go to the site, then as I understand it, a new cache file is created with rights that do not allow deleting this file, why does this happen and how can I deal with it?
This means that your web server is most likely running as root.
Wait until the file is created again and execute ls -l bootstrap/cache- you will see which user the web server is running under.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question