In my previous Centos 6.10 server , I have been able to pass some environment variables to httpd by adding to /etc/sysconfig/httpd

. ~/.envvars

.envvars content is

export MY_PASSWORD='somepassword'

and then in http.conf


and easily accessing the variable in php trough $_SERVER['MY_PASSWORD'] but after upgrading to Centos 7.7 this stopped working, in the logs I get:

AH00111: Config variable ${MY_PASSWORD} is not defined

any help is greatly appreciated


I solved the issue by doing two changes : in ~/.envvars after I do the export , I added this line to pass the environment variable to systemd:

systemctl import-environment MY_PASSWORD

and then instead of calling the declaration script in .bash_profile I used /etc/rc.d/init.d/functions to ensure the variables are declared before the daemon starts, for some reason the directive ExecStartPre didn't work

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.