I’m having trouble using Server environment variables with Apache.
Here is some info about the environment :
- OS : Debian 8.10 Jessie
- Web hosting plateform : Plesk
- PHP : 7.1.8
Executing scripts that use the environments variables work fine if I execute with PHP-CGI, but if I execute the script though the web page, I can’t recuperate the environment variables.
The user is different when accessing the script through a web page but i can’t load the environment variables for the page.
So far, i’ve tried setting the environment variables in :
- /etc/environment
- .bashrc of the user
- .htaccess
- apache2ctl
- PHP commande “putenv”
- ld.so.conf.d
So far, nothing works.
My question : how can i recuperate environment variables though a web page and not with php-cgi?
Thanks
2
Answers
Ok after 3 weeks of trial and error i have found the solution for my case.
Here are the steps i had to take to make it work:
If you use Plesk, you can add to “Additional directives” on PHP of your subscription:
Then, when you check to phpinfo() you can see this: