LMSouq
php-dev Open

How to set up file permissions for Laravel?

RO
Robo Robok
1 month ago
3 views
Problem Description
I'm using Apache Web Server that has the owner set to `_www:_www`. I never know what is the best practice with file permissions, for example when I create new Laravel 5 project. Laravel 5 requires `/storage` folder to be writable. I found plenty of different approaches to make it work and I usually end with making it `777` chmod recursively. I know it's not the best idea though. The official doc says: > Laravel may require some permissions to be configured: folders within > `storage` and `vendor` require write access by the web server. Does it mean that the web server needs access to the `storage` and `vendor` folders themselves too or just their current contents? I assume that what is much better, is changing the **owner** instead of permissions. I changed all Laravel's files permissions recursively to `_www:_www` and that made the site work correctly, as if I changed chmod to `777`. The problem is that now my text editor asks me for password each time I want to save any file and the same happens if I try to change anything in Finder, like for example copy a file. What is the correct approach to solve these problems? 1. Change `chmod` 2. Change the owner of the files to match those of the web server and perhaps set the text editor (and Finder?) to skip asking for password, or make them use `sudo` 3. Change the owner of the web server to match the os user (I don't know the consequences) 4. Something else

AI-Generated Solution

Powered by LMSouq AI · GPT-4.1-mini

✓ Solution Ready
Analyzing problem and generating solution…
Was this solution helpful?
Back to Knowledge Base