4

We have a application that makes use of an Apache environment parameter to determine what config it should use. Around 5 instances of the application are is hosted on one cPanel / WHM development server.

We could use the .htaccess to set the right environment, but that results in uncommitted changes. cPanel should handle this variable via the vhost file, basically each vhost should have a different value:

SetEnv APP_ENV dev
SetEnv APP_ENV test
SetEnv APP_ENV trans

So, how can we let cPanel handle environment variables? It doesn't seem that this is possible, given the SetEnv can't be found in the vhost template.

https://blog.rac.me.uk/2013/05/29/new-relic-cpanel-apache-and-fastcgi-php/

Rvanlaak
  • 2,971
  • 20
  • 40

1 Answers1

1

We can do this with custom php.ini file (most of the hosting provider give option to create custom php.ini file, create custome php.ini file for each domain )

Add configuration in custom php.ini file

APP_ENV="dev"

form php code we can use get_cfg_var() function to retrieve

<?php
echo "current env is   : ".get_cfg_var('APP_ENV');
?>

Output

Output

Bikesh M
  • 8,163
  • 6
  • 40
  • 52