简体   繁体   中英

What is the purpose of the php-fpm system environment variables?

My scenario

I have set up in 1 VM (centos7):

  • Nginx
  • php-fpm
  • Nextcloud

For this task, I have followed this guide (of course, I had to change some settings to make it work in my environment)

My question

In some point of the guide, I had to uncomment these lines in the config file for php-fpm /etc/php-fpm.d/www.conf

env[HOSTNAME] = $HOSTNAME
env[PATH] = /usr/local/bin:/usr/bin:/bin
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp

In the guide, It was said that these were php-fpm system environment variables. I had to uncomment them to active them.
I know nothing about these variables, but I know that they are taking as values some info of my system.
Also, I have to say that my nextcloud is working without errors with these variables uncommented. But just for testing, I commented the lines back again, and nextcloud continued working as usual.

So what I want to learn and currently I can't understand is:
Why the guide says that these variables are needed? What is the function of these variables, if activated, in the communication process between nginx and php-fpm?

Why the guide says that these variables are needed?

Because it is a somewhat junky, extraneous addition to the article.

What is the function of these variables

The primary use would be, I guess, having an environment variable pass with a different value for specific PHP-FPM pool. Eg you have installed some CLI tool (converting between image formats for example) under /usr/local/bin/foo ). Then you want to have your website to be able to launch that. It can't unless it can find it in PATH environment variable (which, by default does not include /usr/local/bin .

So you have two options there:

  1. Change the PATH for the PHP-FPM user (defined in pool settings), eg in ~/.bashrc

  2. env[PATH] = /usr/local/bin:/usr/bin:/bin

So this is just one of the ways to achieve the same.

if activated, in the communication process between nginx and php-fpm?

No, this is nothing about NGINX->PHP-FPM. It is just how PHP-FPM will run its worker processes (with which environment), so it affects how/which environment PHP scripts will see.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM