How to set up file permissions for Laravel?

前端 未结 15 2118
忘了有多久
忘了有多久 2020-11-22 00:08

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 La

15条回答
  •  名媛妹妹
    2020-11-22 00:34

    The permissions for the storage and vendor folders should stay at 775, for obvious security reasons.

    However, both your computer and your server Apache need to be able to write in these folders. Ex: when you run commands like php artisan, your computer needs to write in the logs file in storage.

    All you need to do is to give ownership of the folders to Apache :

    sudo chown -R www-data:www-data /path/to/your/project/vendor
    sudo chown -R www-data:www-data /path/to/your/project/storage
    

    Then you need to add your computer (referenced by it's username) to the group to which the server Apache belongs. Like so :

    sudo usermod -a -G www-data userName
    

    NOTE: Most frequently, groupName is www-data but in your case, replace it with _www

提交回复
热议问题