Put the Laravel Application .env variables in AWS Software panel - laravel

I have a Laravel App running in AWS and I want to delete the .env file and use the Env variables that Elastic Beanstalk has for security reasons.
Should I just put every variable in AWS, Or they are variables that need to stay in the .env file?
This is my .env file:
APP_NAME=
APP_ENV=
APP_KEY=
APP_DEBUG=
APP_URL=
LOG_CHANNEL=
DB_CONNECTION=mysql
BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
SESSION_LIFETIME=120
QUEUE_DRIVER=sync
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_DRIVER=
MAIL_HOST=
MAIL_PORT=
MAIL_USERNAME=
MAIL_PASSWORD=
MAIL_ENCRYPTION=
MAIL_FROM_ADDRESS=
MAIL_FROM_NAME=
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=
AWS_BUCKET=
API_STANDARDS_TREE=
API_SUBTYPE=
API_PREFIX=
API_DOMAIN=
API_VERSION=v1
API_NAME="name"
API_DEFAULT_FORMAT=
JWT_SECRET=

You can put all of your environment variables into Elastic Beanstalk configuration. Laravel loads a .env file but technically it's optional since it loads those values into the environment. If those values are already in the environment then that's fine. The Laravel configuration files attempt to load from the environment variables and not the .env file.
TLDR: Go ahead and place them in the Elastic Beanstalk configuration, it means you can change them easily without having to mess with your code.

Related

My application in Laravel and vuejs, when I deploy to a VPS, in vue components API call goes to the localhost instead of my server IP address

In some vue components I have http request using axios to the server to access this route http://35.184.16.20/api/location-type the problem is; instead of that route http request goes to http://localhost:8000/api/location-type.
in vue part in the app.js file I have //axios.defaults.baseURL='http://localhost:8000/api/'; axios.defaults.baseURL='http://35.184.16.20/api/'; when I push to server I'll comment out the localhost and uncomment the serve ip. It was working fine, after my server ip address changed this problem raised.
I changed to production in the .env but still having the problem.
this is .env in the life server
APP_NAME=Laravel
APP_ENV=production
APP_KEY=base64:hkzyStjgzyyDQk7DjIK0nXHOIUQ/5mUYcM0fQP6hCnE=
APP_DEBUG=false
APP_URL=http://35.184.16.20
LOG_CHANNEL=stack
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=db_username
DB_PASSWORD=db_password
BROADCAST_DRIVER=pusher
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_MAILER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=
MAIL_PASSWORD=
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=
MAIL_FROM_NAME="${APP_NAME}"
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
PUSHER_APP_ID=myid
PUSHER_APP_KEY=somekey
PUSHER_APP_SECRET=somesecret
PUSHER_APP_CLUSTER=mt1
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
I couldn't find out why this problems raised, but I did reset my branch to a commit before this problem happened. thanks for your comments.

Swift_TransportException: Cannot send message without a sender address Laravel 7

MAIL_MAILER was MAIL_MAILER=smtp and i changed it to MAIL_MAILER=log to see the message email in the file laravel.log
I am using laravel 7, MAIL_DRIVER was changed to MAIL_MAILER in this version
where is the error? And how i can resolve this?
i have this in my .env:
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:fmT3dL+Uhb0su5Vpetm2tv2RFqF/0PxP9kY9scCu1L0=
APP_DEBUG=true
APP_URL=http://localhost
LOG_CHANNEL=stack
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=root
DB_PASSWORD=
BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_MAILER=log
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=mimail#gmail.com
MAIL_FROM_NAME="API Restful"
MAILGUN_DOMAIN=-----
MAILGUN_SECRET=-----
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
In case this happens to someone else and OP's fix doesn't solve it, another thing to try is to remember to restart artisan serve after modifying .env (unless it is configured to detect changes automatically, obviously).

links will not work on laravel app with azure server

Hey folks any advice would be so helpful. My first time deploying to azure. The app deploys nice and slick, but i find that my app opens to the index page, but will not link to any others.
"The resource you are looking for has been removed, had its name changed, or is temporarily unavailable."
s
The path is set to public in the application settings
i have scaled up the ressources, added a web-config file then removed it again, the app functions with local host... I'm sure this is not the first time this has been an issue... Thanks
.env file
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:ymq4IuQRQdVHqcamf8wMfuqo1IwbpVTcZZrBZ3CnEyo=
APP_DEBUG=true
APP_URL=http://jobquest1030.scm.azurewebsites.net
LOG_CHANNEL=stack
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=joboard
DB_USERNAME=root
DB_PASSWORD=
BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

Things to ensure when deploy new laravel 5 project to VPS server

I have just finished my Laravel development (with some jquery / javascript) project and I am preparing to officially launch the website with vps servier. For the smooth running and security of the website, I only know how to handle some things in the .env file like blow:
Besides this configuration, are there any other things I have handle it before launching the website officially?
.env
APP_NAME=MyProject
APP_ENV=production
APP_KEY=base64:u93RlbQ5zcs.............
APP_DEBUG=false
APP_LOG_LEVEL=debug
APP_URL=http://mydomain
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=mydbname
DB_USERNAME=myuser
DB_PASSWORD=*******************
BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
MAIL_USERNAME=info#mydomain.com
MAIL_PASSWORD=*******************
MAIL_ENCRYPTION=SSL
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
It seems OK, i have seen similar .env files running on various production servers.

Laravel 5.3 production gey generate error failed to open stream

I've copied the example .env file on production server and made a .env with the following info (IP is fake numbers). I get an error when generating the app key saying PHP Warning: require(/var/www/laravel/bootstrap/../vendor/autoload.php): failed to open stream: No such file etc.
APP_ENV=production
APP_KEY=
APP_DEBUG=false
APP_LOG_LEVEL=error
APP_URL=http://108.99.999.99
DB_CONNECTION=mysql
DB_HOST=108.99.999.99
DB_PORT=3306
DB_DATABASE=npr
DB_USERNAME=root
DB_PASSWORD=mypasswordhere
BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=
MAIL_PASSWORD=
MAIL_ENCRYPTION=null
PUSHER_APP_ID=
PUSHER_KEY=
PUSHER_SECRET=
You need to run composer install or composer dump-autoload.
As you don't have autoload.php file which is generated by composer.

Resources