By simPod
I’m using this command to set environmental variable
export COMMIT_ID='x'
When I use printenv I can see it defined. However, PHP can’t see it using getenv('COMMIT_ID')… What am I doing wrong?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hi there!
What is probably happening is that you set the environment variable with a regular system user (the one you are logged in), but as the web server runs with another user (usually www-data), you don’t have access to that variable from inside your PHP code.
If you are using Ubuntu, you might try setting the variable in the file /etc/environment, so it will be available to all users in the system. This might help: https://help.ubuntu.com/community/EnvironmentVariables#System-wideenvironmentvariables
you can set all your environmental variables in /etc/environment and access them from php using getenv function
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.