0

I have an EC2 with CentOS, cpanel and whm installed.

I have multiple accounts, linked with different subdomains. I have same php application deployed in the virtual hosts.

I need to use environment variables, with different values in for different virtual hosts.

For testing, I created a php file with

<?php
    echo getenv("MYVAR");
?>

So far, I have tried setting the environment variables in

  1. /etc/apache2/conf.d/userdata/std/2_4/user/sub.domain.com/env.conf
  2. httpd.conf even though I'm not supposed to
  3. .htaccess because I was desperate

I enabled mod_env from EasyApache from whm.
apachectl -M shows env_module (shared) though I'm not sure if its the same thing.

My userdata file just contained SetEnv MYVAR myvalue, I could not find a single example whether this was right or wrong.

After that, I did /scripts/ensure_vhost_includes --all-users and it added the include statement in httpd.conf. I restarted httpd service, it didnt help.

I even tried /scripts/rebuildhttpdconf, it didnt help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.