Error:file_put_contents(meta/services.json): failed to open stream: Permission denied?

0 votes

I am new to Laravel. I was trying to open http://localhost/test/public/ and I got

Error in exception handler.

I googled around and changed the permission of storage directory using chmod -R 777 app/storage but to no avail.

I changed debug=>true in app.php and visited the page and got Error in exception handler:

The stream or file "/var/www/html/test/app/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied in /var/www/html/test/bootstrap/compiled.php:8423

Then I changed the permissions of storage directory using the command chmod -R 644 app/storage and the 'Error in exception handler' error was gone and a page is loaded. But in there I am getting this:

file_put_contents(/var/www/html/laravel/app/storage/meta/services.json): failed to open stream: Permission denied
Apr 3 in Laravel by kartik
• 10,990 points
634 views

1 answer to this question.

0 votes

Hello @kartik,

Below steps helped me fix the issue.

1.Find out the apache user - created a test.php file in the public folder with the code

<?php echo exec('whoami'); ?>

         And run the file from the web browser. It would give the apache user. In my case, it is ec2-user as I was using the aws with cronjob installed in /etc/cron.d/. It could be different user for others.

2.Run the below command on the command line.

        sudo chown -R ec2-user:<usergroup> /app-path/public

You need to identify and use the right "user" and "usergroup" here.

Thank You!!

answered Apr 3 by Niroj
• 22,110 points

Related Questions In Laravel

0 votes
1 answer

Error:Laravel Installation failed, reverting ./composer.json to its original content.?

Hello, You need to install php zip extension. Something ...READ MORE

answered Mar 26 in Laravel by Niroj
• 22,110 points
821 views
0 votes
1 answer

Error:login in Laravel. How to solve?

Hey, First check if your model login has a field password in ...READ MORE

answered Mar 26 in Laravel by Niroj
• 22,110 points
84 views
0 votes
1 answer

Error: “No scheduled commands are ready to run.” in Laravel?

Hello @kartik, Run php artisan and see if your commands ...READ MORE

answered Apr 6 in Laravel by Niroj
• 22,110 points
228 views
0 votes
1 answer

How to download and install Lavavel framework?

Hey @kartik, First you must have xampp install ...READ MORE

answered Mar 17 in Laravel by Niroj
• 22,110 points
62 views
0 votes
1 answer

How to make anchor tag with routing using Laravel?

Hey @kartik, First you have to go to ...READ MORE

answered Mar 18 in Laravel by Niroj
• 22,110 points
417 views
0 votes
1 answer

What is redirection in Laravel?

Named route is used to give specific ...READ MORE

answered Mar 18 in Laravel by Niroj
• 22,110 points
62 views
0 votes
1 answer

How to install Laravel via composer?

Hello, This is simple you just need to ...READ MORE

answered Mar 23 in Laravel by Niroj
• 22,110 points
64 views
0 votes
1 answer

What are named routes in Laravel and How can specify route names for controller actions?

Hey @kartik, Named routing is another amazing feature of ...READ MORE

answered Mar 23 in Laravel by Niroj
• 22,110 points
139 views
0 votes
1 answer

Error:Failed to open stream: Permission denied in Laravel?

Hii @kartik, To solve permissions issue on Laravel, ...READ MORE

answered Apr 3 in Laravel by Niroj
• 22,110 points
373 views
0 votes
1 answer

Error: Exception file_put_contents failed to open stream: No such file or directory in Laravel?

Hello, You should typically run the php artisan config:cache command ...READ MORE

answered Mar 31 in Laravel by Niroj
• 22,110 points
644 views