Trying to set and use environment variables with PHP on Ubuntu 14.04

185 Views Asked by At

I am trying to set and use environment variable on my ubuntu 14.04 box with PHP.

I tried the following:

edited /etc/apache/envvars file, and added the following:

export MY_TEST=/home/myfolder/

And added the following line to /etc/apache2.conf:

PassEnv MY_TEST

Then I wrote a test script:

<?php
echo getenv('MY_TEST');

I restarted Apache2:

sudo service apache2 restart

and then I did:

php mytest.php

Nothing.

I then tried editing the /etc/apache2/apache2.conf file by adding:

SetEnv MY_TEST="/home/myfolder/"

I restarted the Apache2 server, and then ran the script. Nothing. What am I doing wrong?

0

There are 0 best solutions below