Wordpress environmental variables with nginx

Posted March 12, 2021 283 views

How do I use environmental variables for my wp-config.php? Where do I set these variables?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

Hello @mlmarinas,

Can you please share what your end goal is? I’m not entierly sure what you mean by the above question but I’ll give it a try to answer as best to my knowledge as possible.

When you mention environmental variables with Nginx, all I can think is about environments that are added in PHP-FPM. You can set the environment variable in /etc/php/php-fpm.d/www.conf like this:

env[APP_ENV] = development

Then you’ll be able to get it with getenv(‘APP_ENV’) anywhere on your PHP application, as long as you are using that php-fpm instnace.

Is that what you were after?