• Reading time ~ 1 min
  • 27.11.2023

To ensure the safe operation of the Laravel project, it is necessary to assign the correct access rights to files and folders.
In this post, we will provide general rules of access rights that are suitable for most Laravel projects.

  1. Назначаем группу и пользователя web сервера владельцем файлов
    sudo chown -R www-data:www-data /var/www/my_project

    Для того, чтобы ваш пользователь мог так-же работать со всеми файлами и папками, необходимо назначить группу и пользователя следующим образом:
    sudo chown -R my_user:www-data /var/www/my_project

    my_user - Need to be replaced with your username
    www-data - Your web server

  2. Назначаем права к каталогам и файлам
    sudo find  /var/www/my_project -type f -exec chmod 644 {} \;  
    sudo find  /var/www/my_project -type d -exec chmod 755 {} \;
  3. Даем права на на запись в папку cache и storage
    sudo chgrp -R www-data storage bootstrap/cache
    sudo chmod -R ug+rwx storage bootstrap/cache

    Команды на папку storage и cache выполнять из корня проекта!

group"/var/www/my_project" - needs to be replaced with the path to yourproject Your project's

files and folders should now be sufficiently protected.

Comments

No comments yet
Yurij Finiv

Yurij Finiv

Full stack

ABOUT

Professional Fullstack Developer with extensive experience in website and desktop application development. Proficient in a wide range of tools and technologies, including Bootstrap, Tailwind, HTML5, CSS3, PUG, JavaScript, Alpine.js, jQuery, PHP, MODX, and Node.js. Skilled in website development using Symfony, MODX, and Laravel. Experience: Contributed to the development and translation of MODX3 i...

About author CrazyBoy49z
WORK EXPERIENCE
Contact
Ukraine, Lutsk
+380979856297