cloudnine
By:
cloudnine

Is it a must to set environment variables in Laravel 5?

April 26, 2017 190 views
Applications PHP Frameworks Ubuntu

On a droplet, I have created two Linux user accounts and setup Laravel 5 for each of them at the following paths:

  • User account 1 >> Maps to dev.example.com.conf virtualhost>> Maps to dev.example.com, with Laravel installed at /home/devuser/public_html
  • User account 2 >> Maps to beta.example.com.conf virtualhost>> Maps to beta.example.com, with Laravel installed at /home/betauser/public_html

I installed Laravel through composer and at the root of each Laravel install, I notice a .env file, which has the Laravel API key automatically written to it. But, that file also has a whole bunch of other variables, including the following:


APPENV=local
APP
DEBUG=true
APPKEY=Key(obfuscated)
APP
URL=http://localhost

DBCONNECTION=mysql
DB
HOST=127.0.0.1
DBPORT=3306
DB
DATABASE=homestead
DBUSERNAME=homestead
DB
PASSWORD=secret

CACHEDRIVER=file
SESSION
DRIVER=file
QUEUE_DRIVER=sync

etc.


The default Laravel page loads when I try https://dev.example.com and https://beta.example.com (installed LetsEncrypt and redirected all requests to https), but I am a bit confused if it's also necessary to specify the details in the respective .env files as below:

APPENV=dev
APP
DEBUG=true
APPKEY=Key(obfuscated)
APP
URL=https://dev.example.com

and, also specify the respective db details.

Thanks in advance.

Be the first one to answer this question.