ashoor's avatar

Permission Denied after change to the correct permission

Hi, I got "ERROR 500: Internal Server Error "with no error in laravel log. I checked apache logs i got this

[Tue Jan 17 15:07:52.609639 2023] [php:error] [pid 39218] [client 127.0.0.1:xxx] PHP Fatal error:  Uncaught ErrorException: file_put_contents(/var/www/html/storage/framework/views/31194b376a867d7e5a56653be65b2bc7a5c4040b.php): Failed to open stream: Permission denied in /var/www/html/vendor/laravel/framework/src/Illuminate/Filesystem/Filesy
stem.php:xxx\nStack trace:\n#0 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(266): Illuminate\Foundation\Bootstrap\Hand
leExceptions->handleError()\n#1 [internal function]:

i set permission for storrage folder

sudo chmod -R ugo+rw storage
sudo chmod -R 755 storage
sudo chown -R user:www-data storage

and set owner & group for html folder

sudo chown -R user:www-data html

and var/www

udo chown -R www-data:www-data /var/www

can you help

0 likes
11 replies
Akash_kushwaha's avatar

@ashoor Then try giving them permission of 777 not 755

php artisan cache:clear

chmod -R 777 storage/

composer dump-autoload

Akash_kushwaha's avatar

@ashoor I know but storage folder needs full permission to create, read and write any file.

just on Production keep it 755

Or you can try these too

sudo chgrp -R www-data storage bootstrap/cache

sudo chmod -R ug+rwx storage bootstrap/cache

Akash_kushwaha's avatar

@ashoor Sorry. I did'nt know.

because you already gave it 755 permission then try clearing your apps caches sometime it's cache problem too.

php artisan config:cache

ashoor's avatar

I Just deployed the project on the server and got this error and got the error

ashoor's avatar

Can you help .. in the last week I deployed with the same configuration on anther server with a different ubuntu version but i dont know what is the problem

Akash_kushwaha's avatar

Hi @ashoor have you tried these commands ?

			sudo chgrp -R www-data storage bootstrap/cache
			sudo chmod -R ug+rwx storage bootstrap/cache 

you can read here all about the permissions. https://stackoverflow.com/questions/30639174/how-to-set-up-file-permissions-for-laravel

and if you are using shared host like Cloudways then try clearing its cache and also clear your apps cache too.

php artisan cache:clear

php artisan route:clear

php artisan config:clear

php artisan view:clear

php artisan optimize:clear

Please or to participate in this conversation.