I'm trying to set up an apache environment variable using .htaccess file in the following way:
SetEnv SERVER_KEY "qwerty"
After that i gracefully restart my apache web server:
apachectl graceful
Then i create a file called version.php in /var/www/html
<?php phpinfo() ?>
And go to MYIPADDRESS/version.php to check but i find out that the environment variable has not been set up.
Here are further details: OS: RHEL6 PHP Version: 5.3.3 Apache Version: 2.2.15 (Red Hat)
What do i do?
Update: I solved my problem by changing AllowOverride None to AllowOverride All in the server configuration file!
Check that the htaccess is being read at all, make sure you've configured your host so that it allows (at the very least) "FILEINFO", or better yet, set it to "ALL"
AllowOverride ALL
If not, make sure your mod_env module is being loaded in your server config.
Make sure you're looking in the right place. Apache internal environment variables are passed along to php via the $_SERVER[]
array (on the phpinfo() page, under Apache Environment) and they are different from php runtime environment variables.(which are under Environment),