Laravel Environment confusion Laravel Environment confusion apache apache

Laravel Environment confusion


You need a .env file per environment that Laravel will run in. It is perfectly acceptable to have a .env for your local, and a different .env on your staging environment, etc, etc.

I am not clear from your question why you need to put variables in your vhost files. Just create a .env for the staging and a .env for the production environments on their respective servers. If you are building from automated scripts (like puppet or similar) the .env are intentionally simple enough that they are easy to create from scripts.

You can even have a few server examples .env stored in your repo named like .env.production-example so you know what your servers should look like (obviously without actually storing credentials in there).