I am running Apache 2.2.26 with PHP 5.4.24 on Mac OS X 10.9.4. I have several virtual hosts running on this system, and all of them run successfully. I'm trying to add environment variables to one of the virtual hosts, and I don't want them to be in .htaccess so my only option is adding them to the in httpd-vhosts.conf.
The problem is that the environment variables don't appear after I install them in the httpd-vhosts.conf file (and, of course, after I restart Apache "sudo apachectl restart"). If, however, I add them to .htaccess (just for comparison purposes), they appear just fine. What am I missing?
NameVirtualHost *:80
<VirtualHost *:80>
ServerName mysite.local
DocumentRoot "/path/to/mysite.com"
SetEnv siteid 1234
ErrorLog "/var/log/apache2/mysite.local-error_log"
</VirtualHost>
I've also double-checked my php.ini file to be sure there's nothing prohibitive there, and the only relevant line looks good:
variables_order = "GPCSE"
Again, just to be clear, my virtual hosts RUN FINE. It's just that the environment variables don't appear when called in my PHP code. I've tried each of these three commands:
echo $_SERVER["siteid"];
echo getenv("siteid");
echo apache_getenv("siteid");
What can I be doing wrong??