- Dir:
/var/www/my-website.com/
- User:
john
- Web server group:
www-data
Set folder permissions for laravel project:
sudo usermod -aG www-data john
cd /var/www/my-website.com/
sudo chown -R john:www-data .
sudo find . -type d -exec chmod 755 {} \;
sudo find . -type f -exec chmod 644 {} \;
sudo chmod g+w -R storage bootstrap/cache
sudo chmod g+s -R .
If using Apache, make sure all directories have execute permission (/var, /var/www, /var/www/my-website.com/, ...)
Firstly:
cd /var/www/my-website.com/
sudo usermod -a -G www-data john
It may be necessary to reload the terminal for the change to be applied if the current user is john
.
- Set your user as the owner
sudo chown -R john .
- Set the web server as the group owner
sudo chgrp -R www-data .
- Set file/folder permission 750 permissions for everything
sudo find . -type d -exec chmod 750 {} \;
sudo find . -type f -exec chmod 640 {} \;
Use 755
and 644
if the web server is apache.
Set permissions for writable folders
sudo chmod g+w -R <folder>
- New files and folders inherit group ownership from the parent folder
sudo chmod g+s -R .
Use one or more of the solutions below:
On CentOS, create file /etc/systemd/system/httpd.service.d/umask.conf
:
[Service]
UMask=0002
Then reload:
systemctl daemon-reload
sudo apachectl restart
Reference:
sudo vi /etc/supervisord.conf
[supervisord]
umask=002
Then reload config
sudo supervisorctl reread
sudo supervisorctl update
Config laravel config/cache.php
config
return [
'stores' => [
'file' => [
'driver' => 'file',
'path' => storage_path('framework/cache/data'),
'permission' => 0777,
],
],
];
Make sure all directories have execute permission (/var, /var/www, /var/www/my-website.com/, ...)