I'm trying to set a local environment variable to test my PHP app on a windows machine. I added SetEnv API_HOST /foo/bin
in the file C:\\Apache24\\conf\\httpd.conf
and restarted the server by executing httpd -k restart
at the command line.
In my app I check the variable $_SERVER['API_HOST']
and I always get null and it isn't null in the development server since the environment variable is set there.
I also tried to create confs files, set the env variable and include the files in the httpd.conf, but also doesn't work.
I was expecting this to be straight forward, but it seems something is missing. Any idea why it isn't working?
Thanks.
Sorry, forgot to answer earlier. It started working with the following in the httpd.conf:
<VirtualHost *:80>
DocumentRoot "path/to/project-root"
ServerName localhost
SetEnv API_HOST /foo/bin
</VirtualHost>
And restart the apache server by going to the path C:\\Apache24\\bin
on the cmd and execute httpd -k stop
and httpd -k start
. I tried httpd -k restart
several times before and didn't work, don't know why.
Cheers
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.