O
O
ObehanProger2020-03-27 06:23:37
Access rights
ObehanProger, 2020-03-27 06:23:37

What permissions should I set for each folder inside a Laravel project?

By negligence, I set the rights entirely to the entire project 777. In the official documentation, I only found that the rights to the storage, public and bootstrap / cache folders should give the right to write. But what about the rest of the directories? What minimum rights should be set separately for app, bootstrap, config, database, public, resorces, routes, vendor, storage?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Voskresensky, 2020-03-28
@andrey_sunday

1 you need to make the web server the owner of the files

sudo chown -R www-data:www-data /path/to/your/laravel/root/directory

2 set 644 on files
sudo find /path/to/your/laravel/root/directory -type f -exec chmod 644 {} \;

3 install 755 on folders
sudo find /path/to/your/laravel/root/directory -type d -exec chmod 755 {} \;

4 We give the rights to the web server to write storage and cache
sudo chgrp -R www-data storage bootstrap/cache
sudo chmod -R ug+rwx storage bootstrap/cache

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question