简体   繁体   English

php-fpm 系统环境变量的目的是什么?

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

My scenario我的场景

I have set up in 1 VM (centos7):我已经在 1 个 VM (centos7) 中进行了设置:

  • Nginx nginx
  • php-fpm 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在指南的某些地方,我不得不在 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.在指南中,据说这些是php-fpm系统环境变量。 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.另外,我不得不说我的 nextcloud 在没有注释这些变量的情况下工作没有错误。 But just for testing, I commented the lines back again, and nextcloud continued working as usual.但只是为了测试,我再次评论了这些行,nextcloud 继续像往常一样工作。

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?在nginx和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.我猜,主要用途是为特定 PHP-FPM 池传递一个具有不同值的环境变量。 Eg you have installed some CLI tool (converting between image formats for example) under /usr/local/bin/foo ).例如,您已经在/usr/local/bin/foo下安装了一些 CLI 工具(例如在图像格式之间进行转换)。 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 .它不能,除非它可以在PATH环境变量中找到它(默认情况下不包括/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更改 PHP-FPM 用户的PATH (在池设置中定义),例如在~/.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?如果激活,在nginx和php-fpm的通信过程中?

No, this is nothing about NGINX->PHP-FPM.不,这与 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.这就是 PHP-FPM 将如何运行其工作进程(在哪个环境下),因此它会影响 PHP 脚本将如何/哪个环境看到。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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