我无法从 apache 获取环境变量

我无法从 apache 获取环境变量

在 Centos 8 上,我在 VirtualHost 配置中添加了一个 SetEnv:

<VirtualHost *:XXXX>
    Alias /static/ /opt/industrialisation/xxxx/xxxx/xxxx/
    <Directory /opt/industrialisation/xxx/xxxx/>
        Require all granted
        <Files wsgi.py>
            Require all granted
        </Files>
    </Directory>
    WSGIDaemonProcess myproject python-home=/opt/venv/venv-xxxxx python-path=/opt/industrialisation/xxxx/xxxxx/
    WSGIProcessGroup myproject
    WSGIScriptAlias / /opt/industrialisation/xxxx/xxxx/xxxxx/wsgi.py
    SetEnv VARIABLE_NAME variable_value
</VirtualHost>

我停止并启动 httpd 服务:

[root@xxxxx ~]# systemctl stop httpd.service
[root@xxxxx ~]# systemctl start httpd.service

服务运行良好:

[root@xxxxxxx ~]# systemctl status httpd.service
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
  Drop-In: /usr/lib/systemd/system/httpd.service.d
           └─php-fpm.conf
   Active: active (running) since Mon 2023-03-06 21:57:56 CET; 5min ago
     Docs: man:httpd.service(8)
 Main PID: 49075 (httpd)
   Status: "Total requests: 1; Idle/Busy workers 100/0;Requests/sec: 0.00313; Bytes served/sec:  19 B/sec"
    Tasks: 231 (limit: 22084)
   Memory: 43.4M
   CGroup: /system.slice/httpd.service
           ├─49075 /usr/sbin/httpd -DFOREGROUND
           ├─49076 /usr/sbin/httpd -DFOREGROUND
           ├─49077 /usr/sbin/httpd -DFOREGROUND
           ├─49078 /usr/sbin/httpd -DFOREGROUND
           ├─49079 /usr/sbin/httpd -DFOREGROUND
           └─49080 /usr/sbin/httpd -DFOREGROUND

mars 06 21:57:56 xxxxxxx.xxxxxxx.net systemd[1]: Starting The Apache HTTP Server...
mars 06 21:57:56 xxxxxxx.xxxxxxx.net systemd[1]: Started The Apache HTTP Server.
mars 06 21:57:56 xxxxxxx.xxxxxxx.net httpd[49075]: Server configured, listening on: port xxx, port xxxx, port xxxx

我检查变量是否可用但不可用:

[root@xxxxxxx ~]# cat /proc/49075/environ | tr '\0' '\n'
LANG=C
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
NOTIFY_SOCKET=/run/systemd/notify
INVOCATION_ID=a3e117c7287b445b9b9932f7ec8883b1
JOURNAL_STREAM=9:220753

我还认为系统变量(如 HOSTNAME)将可用于进程 httpd,但我只看到这 5 个变量。

这正常吗?是不是我的 proc 检查有问题?我很困惑。

相关内容