First of all, Identify the user name under which the webserver is running. Here are some default cases

Nginx on Linux uses account – www-data Apache on Debian systems uses account – www-data Apache on Redhat systems uses account – apache

Setup Laravel File Permissions

Assuming that the webserver is running with www-data user on your system . So all files should have the same user ownership as the webserver user. Use the chown command to set owner and group-owner for all files and directories recursively. Next, set 644 permission for all files and 755 for all directories. We can achieve this with chmod command and find commands together as below: To make Laravel work properly, you need to give read and write permissions to the web server for storage, cache and any other directories. So run the following commands: Now, your Laravel application is secured with proper permissions. But as all the files have owner and group-owner to web server, you may face an issue during changes via FTP/sFTP. To solve this problem add your user to the webserver user group: Read our another tutorial to properly create an SFTP account for the web server document root.

Conclusion

In this tutorial, You have learned to properly configure file permissions for the Laravel applications.