Search code examples
nginxenvironment-variableslaravel-valet

Environment variable in Valet


I am using default installation of Valet (https://laravel.com/docs/5.4/valet).

I have small experience with nginx, therefore I can't locate where should I store envvars for Valet.

For apache it would be quite easy - /etc/apache2/envvars

As a temporary solution on PHP, index.php, I use putenv('APP_ENV=dev'); but I would like to do this globally without touching index file.

Thanks.


Solution

  • Since I find this post when I am looking for an answer, it will be easier for me if I leave a note for my self here.

    Since I installed nginx using brew, nginx config is located in /usr/local/etc/nginx, and environment variables are already set in fastcgi_params file.

    Append to file

    /usr/local/etc/nginx/fastcgi_params

    a new line, for example

    fastcgi_param APP_ENV dev;

    If you don't want to set this environment variable globally, it can be overwritten for each site config in ~/.valet/Nginx/site.dev between location ~ \.php$ { closure.