Laravel ErrorException after install in AWS - php

Recently I made an account in AWS. I'm using their EC2 with Ubuntu. I installed my Laravel project and in the command-line wrote chmod -R 777 storage. Now i'm getting an error:
ErrorException in Filesystem.php line 81: file_put_contents(/var/www/html/BlueDrive/bluedrive/drive/bootstrap/cache/services.json): failed to open stream: Permission denied
What should I do to prevent this exception?

This is an access permission problem.
Run the following command:
$ sudo chown nobody /var/www/html/BlueDrive/bluedrive/drive/bootstrap/
$ sudo chmod -R 0755 /var/www/html/BlueDrive/bluedrive/drive/bootstrap/
OR
run
chmod -R 777 /path/to/the/folder

go to the root of your project and
cd into the bootstrap directory. and issue chmod -R 777 .
Remember the storage directory is different from the bootstrap directory.
Laravel create a file name services.json inside boostrap/cache to list all your service providers in your application. laravel will need permission to do so that is why you are seeing that error.

Related

Laravel 7 XAMPP Mac OS: The stream or file "../storage/logs/laravel.log" could not be opened. Permission denied

Yes I know this question has been asked several times but I couldn't find 100% working solution yet. I have installed XAMPP from https://www.apachefriends.org and then I installed Laravel 7 using composer command composer create-project --prefer-dist laravel/laravel:^7.0 blog
Command "php artisan serve" successfully runs the project. BUT if I open the same project from URL "http://localhost/blog/public/" I get the error:
The stream or file
"/Applications/XAMPP/xamppfiles/htdocs/blog/storage/logs/laravel.log"
could not be opened in append mode: failed to open stream: Permission
denied
I cannot set folder permission to 777 because not a good approach. The permission is already "read&write". I have been following this thread.
sudo chown -R $USER:www-data storage
sudo chown -R $USER:www-data bootstrap/cache
and then
chmod -R 775 storage
chmod -R 775 bootstrap/cache
and if it won't work, try changing the 'www-data' group into '_www'.

Laravel: while hosting xampp on localhost in mac getting an error UnexpectedValueException

I am just starting with laravel, when I localhost it in xampp(localhost:8080/app/public) in mac [where app is a file created when I created] it shows an error
`UnexpectedValueException
The stream or file "/opt/lampp/htdocs/app/storage/logs/laravel.log" could not be opened in append mode: failed to open stream: Permission denied`
Please help me with this.
It looks that laravel doesn't have permissions to create logs so come to the root directory of the project and run this command from your terminal
sudo chmod -R 775 .
in your case, your project is in this path /opt/lampp/htdocs/app so move to it first then change permissions like this
$ cd /opt/lampp/htdocs/app
$ sudo chmod -R 775 .

Why am I getting a file_put_contents error even after clearing the cache and modifying storage, vendor and bootstrap permissions CentOS?

I have read many similar posts with a similar error, but after doing the recommended solutions for each of them, I still have not had any success sending a POST API request to my Laravel API instance hosted locally on my vagrant CentOS server.
The error message:
ErrorException: file_put_contents(/vagrant/html/test/storage/framework/cache/data/a2/76/a2767fcc897a34fbe4b83d0a6ad5f44445bd07a5):
failed to open stream: No such file or directory in file
/vagrant/html/test/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php on line 135
What I have tried:
Running the following commands both on the local Laravel instance and on Vagrant:
chmod -R 777 storage/ bootstrap/ vendor/
rm bootstrap/cache/config.php
sudo chown -R root: storage/ vendor/
Thanks in advance for any help! Cheers!

how to view adminlte template without php artisan serve

I have my project created with adminlte template, when i deploy my project i tried it to run without php artisan serve command but i failed i tried this options but all of my design gone away and nothing work as it was before,
This is the error a got when I wrote localhost/akyo/public
The stream or file `
"/opt/lampp/htdocs/akyo/storage/logs/laravel.log" could not be opened:
failed to open stream: Permission denied`
I tried the following options
sudo chmod -R 777 storage
sudo chmod -R 777 bootstrap/cache
sudo chmod -R 777 app/storage
Any one with a way how to fix this
try sudo chmod -R 777 storage/

PHP Laravel: failed to open stream: Permission denied

I am trying to generate email but getting this error:
fopen(/tmp/4701021fcbc23c3a52dde64ccca28857/body): failed to open
stream: Permission denied
Relevant user/group have the permissions but its not working. I used lot of links but none is working.
We are running apache server on linux Ubuntu 14.04.4 LTS and using laravel framework.
Try running this commands in the console, is very important to execute them from your project root directory, if you don't it won't find the specific laravel commands:
cd your_project_path
php artisan cache:clear
chmod -R 777 app
chmod -R 777 storage
composer dump-autoload
I found a similar problem in the laravel.io/forum with further information.
Set up write permissions on storage directory inside your Laravel project directory:
chmod -R 777 storage
You need to access your Laravel project folder so you can run the following command
sudo chmod 777 -R 'your path to project'
Of course you have to replace 'your path to project' with the address of your project folder
for example /var/www/html/LaravelNiceProject
thats it
You can try to write command below to grant your apache user needed privileges:
chown www-data -R storage
Regards dear

Categories