Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

andremellow's avatar

Permission Denied on Ubuntu

Hi, I'm moving from Windows to ubuntu and I've tried everything to make it work, but I can't move forward.

First thing I did was add my user to www-data group

sudo usermod -a -G www-data andre-mello

than create /var/www folder.

that clone using sudo.

sudo clone https://.......git

So I changed group and owner

chgrp -R www-data /var/www/laravel

chown -R www-data /var/www/laravel

gave permission

chmod -R 775 /var/www/laravel/storage

chmod -R 775 /var/www/laravel/bootstrap/cache

The app are writing logs normally in storage/logs

Composer install have worked

But I getting this message when access in browser

ErrorException in Filesystem.php line 81:
file_put_contents(/b1349b087ffe25207b75411bdf223a83): failed to open stream: Permission denied

I've tried even chmod -R 777 /var/www/larevel but getting the same error!

What am I missing?

Thanks

0 likes
5 replies
bashy's avatar

So many permission changing D: sudo git clone?!

Just need a few commands on a few folders.

sudo chgrp -R www-data storage
sudo chgrp -R www-data bootstrap/cache

sudo chmod -R ug+rwx storage
sudo chmod -R ug+rwx bootstrap/cache

If you want to undo .gitkeep/.gitignore changes (not sure if you can exclude chmod/chgrp files)

find storage -type f -name ".gitignore" -exec chmod 644 {} \;
3 likes
andremellow's avatar

@bashy

As I'm at /var/www I haven't permission to create folders using "git clone". So I did with sudo.

I think my problem was that I've added this to my .gitignone /storage/framework/views/* /storage/framework/sessions/*

It suppose to keep the folder and ignore the files right? ( I just saw that there are a .gitignore in this folder in default laravel project code). Any way theses folders wasn't there. After I created, it works. I will do from scratch to make sure I got the thing! :)

bashy's avatar

@andremellow Your /var/www folder should not have root owner/group... add a user for websites and change the folder permissions. What user is the folder?

andremellow's avatar

@bashy, I do had problem with permission, but in the end the problem was the missing /storage/framework/views/ /storage/framework/sessions/ folders!

Thanks!

Please or to participate in this conversation.