Laravel Forge, suddenly env is empty - laravel

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?

Related

APP_URL not refreshing after a change

I'm building a Laravel 9 app using Docker.
I'm just starting, so I merely updated the APP_URL variable in the .env (from "http://localhost" to "http://mydomain.local").
After this, I ran the following commands:
php artisan cache:clear
php artisan config:clear
php artisan route:clear
composer dump-autoload
and I restarted the Docker container of the app.
Yet, when I access http://mydomain.local in my browser, the app doesn't load. It still loads properly when I user http://localhost as originally configured.
What am I missing?
This is because you probably didnt edit the vhost..
Just changing the APP_URL in the .env file doesnt change how the browser resolves a domain name.
See this thread to learn how to edit a vhost file: WAMP Server virtual hosts configuration

Laravel: local running the application with ASSET_URL set to local port loads forever

I am new with Laravel.
The app runs perfectly fine in the production but when running it locally it takes lot of time to load even for a simple login page (something around 15min).
I tried running it with command:
php artisan serve
and:
php -S 127.0.0.1:8000 -t public/
Tried removing:
APP_DEBUG=true
But nothing helped. Also tried:
php artisan view:clear
php artisan route:cache
But I get an error as lot of routes use closure and changing them is lot of effort.
It loads rapidly when I remove or change url in .env for ASSET_URL.

Laravel can't access database

I cvurrently have a laravel application running on heroku, the issue here is, I keep getting the error that I can't connect to the database: SQLSTATE[HY000] [1045] Access denied for user 'user'#'ec2-54-74-209-179.eu-west-1.compute.amazonaws.com' (using password: YES). Now the host is wrong here, the environment files are TOTALLY different (except for the username) then what the error gives....
How can I resolve this issue?
I've tried to use the DB_URL env, but that gives the same result...
Did you set the .env correctly on what's running on their server?
You can see all your projects in laravel at TOOLS->DEPLOYEMNT->CONFIGURATIONS
add all the info and connect to the remote project. I did the same and changed the .env directly there.
and of course you have to clean all the cache cause even if you change the .env it will not work until you'll clear it
php artisan cache:clear;
php artisan config:clear;
php artisan route:clear;
Obviously this need to be executed on the project on heroku or aws (as it appears from the Error)

how to make changes in .env file without reloading server

I am using a form from front end to change my .env file variable values, after changing the values, changes are being saved in my env file, but its not reflecting on my laravel application, after restarting my server its reflecting on my website, but i cant do this if its in live server, I tried PHP artisan config:clear and PHP artisan cache:clear but none of its working.
Can anyone please tell me how to do this without restarting server.
I am trying to change these values in .env
HTTP_HOST=http://
SFTP_HOST=10.10.10.64

Laravel 5.4 Token Mismatch Exception on live server

I am facing Token mismatch exception in Laravel 5.4 on live server. On my local machine running Windows XAMPP, the application works fine. When I deployed it to live machine running CENTOS 7 and LAMP stack, I see a redirecting to myhostname.com/login at the top left corner of the browser and then lands on an error page showing:
token mismatch exception on line 68 of VerifyCsrfToken.php.
I had this same problem and what i did was:
First in your .env file remove: SESSION_DOMAIN
And in set session driver like: SESSION_DRIVER=file (if your want it to save to a file)
then do: php artisan cache:clear
then `php artisan config:clear
that worked for me.
Try to clear config cache on the server with :
artisan cache:config
You will need to clear config cache also if you edited config/app.php for some reason.
In addition there is an other possible reason : you copied not only the application but also the cache/session files when you deployed your application to production. Basically everything in the storage folder should be ignored on deployment.
Run this command
php artisan config:clear
Verify .env file
delete current .env file and create new .env file from .env.example
verify that config/session.php has is correct or not modified.
You can check the file permission as well of storage directory

Resources