Laravel 7 deployment on Heroku failed - missing session - laravel

My Laravel 7 app deploys to Heroku without any errors during deployment. However, upon opening the app in the browser, I received the following Error Exception:
file_put_contents(/tmp/build_d3cb80e3d9d066f9486ad70783e0f0ba/storage/framework/sessions/BbnXCLFvgRPnTFSdQFvBYlmDhTfaIaesjbCsdVb8): failed to open stream: No such file or directory
I then ran artisan config:clear and redeployed (something which seemed to fix the problem for most others in Laravel 5) but no change.
I then went into config/session and changed 'expire_on_close' to true. I also changed lottery from [2,100] to [100,100] so that all sessions in storage would be swept on each request instead of only in 2% of cases.
I ran artisan config:clear again before redeploying. The Error Exception has now changed to the following:
Symfony\Component\Finder\Exception\DirectoryNotFoundException
The "/tmp/build_d5d0270f_/storage/framework/sessions" directory does not exist.
Note: I am deploying through Github.
I have successfully ran the following commands on the Heroku console:
chmod -R 770 bootstrap/cache
chmod -R 770 storage

Related

Laravel on ElasticBeanstalk 'log file permission denied' error keeps coming up even the permission is set in the .ebextensions config file

I am deploying my Laravel application to the ElasticBeanstalk environment. But I am having issue with laravel.log file permissions.
I deployed my application using "eb deploy" command. After I deployed, I access my application. But it is throwing the following error.
The stream or file "/var/app/current/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied
To solve the issue, I ssh into the server and run the following command.
sudo -u root chmod 777 -R /var/app/current/storage/logs
The problem is solved. Now my application is working. But I deploy my application again running "be deploy" command. After the deployment, the issue popped up again. To solve the issue in a consistent way. I tried to run the command in the .ebextensions config file as follow.
container_commands:
01-migrations:
command: "php artisan migrate --force"
02-log-storage-permissions:
command: "sudo -u root chmod -R 777 /var/app/current/storage/logs/"
I could deploy my application. But the issue still persists. It seems like the command is not working. What is wrong with my configuration and how can I fix it?
I believe that this is because container_commands run when your application is in the staging folder. Thus, after you run 02-log-storage-permissions, your /var/app/current will be replaced anyway with the staging folder. So your chmod wont persist.
To rectify the issue, you can try one of the two options:
Use
02-log-storage-permissions:
command: "sudo -u chmod -R 777 ./storage/logs/"
to change the logs in staging folder.
use postdeploy hook to run your script:
after the Elastic Beanstalk platform engine deploys the application and proxy server.

Laravel Forge, suddenly env is empty

I've deployed a Laravel app on Digitalocean using Laravel Forge. Site runs fine for a day or two, then suddenly the .env file gets wiped, all variables deleted and file is 0 bytes.
php artisan env returns
Current application environment: production
But the file itself is empty. Owner is forge and chmod is 755
I've tried running php artisan config:cache but from time to time the .env file suddenly is completely blank, turning my app to become unavailable of course.
Digitalocean runs nginx.
Does anybody know what could be wrong?

Laravel 5.3 Cannot Find File Error

I've setup a project more than a month ago and all of a sudden (this afternoon) I started getting the following error:
ErrorException in Filesystem.php line 111: file_put_contents(/var/www/html/project/api/storage/framework/cache/d8/00/d800874b5dc22b961e0ee92f8d1c5a09c24ee911): failed to open stream: No such file or directory
I've done research and tried the following with no success:
php artisan cache:clear
chmod -R 777 storage (I know this is not ideal)
composer update
Nothing is working. Before the chmod I was getting a permission error. I'm tapped out of ideas. Does anyone know what is causing this and how to resolve it?
You gave 777 to /storage folder but did you also make sure it's in same group as apache server is running?
Generally apache is in www-data group, add storage and bootstrap folder to be written by this group:
chgrp -R www-data /storage /bootstrap
Assign current user and group permission to read and write:
chmod -R ug+rw /storage /bootstrap
I'm 99% sure this will do it.
My server runs CentOS 7 and somehow Selinux was set to enforcing which breaks Laravel for some reason. I remember changing it when I first set up Laravel, but somehow it reverted back.
So setting it to permissive or disabled fixed it for me.
https://www.centos.org/docs/5/html/5.2/Deployment_Guide/sec-sel-enable-disable.html

After uploading into cpanel Laravel 5.3 throwing InvalidArgumentException error

After Developing a test App using Laravel 5.3, When I uploaded to the Cpanel it throwing Invalid exception Error. According to error message the App looking for some files from my local PC.Even after clearing all files from Storage\framwork\session it behaves alike previous.
App link: http://autocomplete.bappasarkar.info/
NB: After first time uploading the app threw an error
The only supported ciphers are AES-128-CBC and AES-256-CBC
Then I generate key by the artisan command
"php artisan key:generate"
After generating key when the App uploaded for the second time , it's throwing the current Error.
You have permissions issue, the following commands are for *nix based OS's.
Try
sudo chgrp -R www-data storage bootstrap/cache
sudo chmod -R ug+rwx storage bootstrap/cache
You can change the permission through ftp or file manager from Cpanel.

Laravel 5.1 manualy clearing views cache, caused error 500

I just removed all files inside laravelApp/storage/framework/views and all of routes now return error 500.
Command php artisan views:clear and php artisan cache:clear tested, but had no affect.
Error reporting is set to E_All, APP_DEBUG is true both in app.php and .env file, But i see only a simple error 500 (generated by browser).
How can i fix it?
i set permission for my folder that cointain all files
sudo chown -R www-data:www-data /var/www/myweb
(ubuntu)
and it is ok!

Resources