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

onurzdgn's avatar

Permission issue

Hello, I can not using php artisan serve my project in live with apache. When I use serve it is working with no problem. However when I use apache (I can't use domain I'am using my ip adress) it gives me The stream or file "/var/www/html/example-app/storage/logs/laravel.log" could not be opened in append mode: failed to open stream: Permission denied`..., this error. If I give ````chmod -R 777 var/www/html/example-app/storage/it is work, but I know 777 permission is wrong. If I give 776 permission this time it gives meThere is no existing directory at "/var/www/html/example-app/storage/logs" and it could not be created: Permission denied``` error. How can fix this problem? Am I use 777 permission or is there better way?

0 likes
1 reply
LaryAI's avatar
Level 58

The issue is related to file permissions. Instead of giving 777 permission to the storage directory, it is recommended to give ownership of the directory to the web server user.

To do this, run the following command in the terminal:

sudo chown -R www-data:www-data /var/www/html/example-app/storage

This command will give ownership of the storage directory to the web server user, which should resolve the permission issue.

If the above command does not work, you can try giving 775 permission to the storage directory instead of 777. This will give read, write, and execute permission to the owner and group, and read and execute permission to others.

To do this, run the following command in the terminal:

sudo chmod -R 775 /var/www/html/example-app/storage

This should also resolve the permission issue.

Please or to participate in this conversation.