Laravel 4.1 Deployment - Production.env.php not recognized

For some reason, my laravel authoring application considers it to be in a local environment.

/var/www/appname/.env.php

<?php return [ 'APP_ENV' => 'production', 'DB_HOST' => 'HIDDEN', 'DB_NAME' => 'HIDDEN', 'DB_PASSWORD' => 'HIDDEN' ]; 

/var/www/appname/bootstrap/start.php

 $env = $app->detectEnvironment(function() { return getenv('APP_ENV') ?: 'local'; }); 

/var/www/appname/app/config/database.php

 ... ... 'mysql' => array( 'driver' => 'mysql', 'host' => getenv('DB_HOST'), 'database' => getenv('DB_NAME'), 'username' => getenv('DB_USERNAME'), 'password' => getenv('DB_PASSWORD'), 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => 'lar_', ), ... ... 

sudo php artisan env (via SSH)

 `Current application environment: local 

php artisan tinker , then getenv('DB_NAME')

 $ php artisan tinker [1] > getenv('DB_NAME'); // false 

So either my environment variables are not set, or Laravel does not recognize my .env.php file for the production environment.

Update

With some help from Anultro in IRC, it looks like .env.php is not loaded yet. Because such an APP_ENV must be set before laravel tries to discover the environments. This makes sense because Laravel needs to know which environment is running before deciding whether to use .env.php or .env.local.php .

Having said that, .env.php should still be used to store db credentials and private keys, etc. But I still have a problem, because the application still returns false when I try to run getenv('DB_NAME')

Any suggestions?

+6
source share
1 answer

For anyone who wants to know ... to solve this problem, I just edited my httpd.conf file on a production server as follows:

 SetEnv APP_ENV production 

Now laravel knows that the application is in production.

If you are using nginx, which now transferred my site to me, to add the following, where you transfer the scripts to the FCGI server on active sites available /etc/nginx/sites-available/{sitename} :

 fastcgi_param APP_ENV production; 
+3
source

All Articles