无法设置环境变量 - Apache 2.4.57 AlmaLinux

问题描述 投票:0回答:1

我在将 LANG 环境变量设置为我的 apache Web 服务器时遇到一些问题。

当我在 php 文件中打印配置(使用 php_info())时,我得到以下条目(针对环境):

事实上,它应该已经在默认服务设置(/usr/lib/systemd/system/httpd.service)上进行了设置:

# See httpd.service(8) for more information on using the httpd service. # Modifying this file in-place is not recommended, because changes # will be overwritten during package upgrades. To customize the # behaviour, run "systemctl edit httpd" to create an override unit. # For example, to pass additional options (such as -D definitions) to # the httpd binary at startup, create an override unit (as is done by # systemctl edit) and enter the following: # [Service] # Environment=OPTIONS=-DMY_DEFINE [Unit] Description=The Apache HTTP Server Wants=httpd-init.service After=network.target remote-fs.target nss-lookup.target httpd-init.service Documentation=man:httpd.service(8) [Service] Type=notify Environment=LANG=C # <----------------------------------- ...
即使我尝试使用 /etc/systemd/system/httpd.service.d/xxx.conf 等其他文件修改服务环境:

[Service] Environment="LANG=C" #Environment=LANG=C #Environment=ABC=C #Environment="DEF=C" #EnvironmentFile=/etc/sysconfig/httpd
环境仍然只包含“USER”和“HOME”。

附加信息:

httpd -v Server version: Apache/2.4.57 (AlmaLinux) Server built: Jul 20 2023 00:00:00
有什么想法吗?预先感谢!

apache environment
1个回答
0
投票
一种可能的方法是在 apache 配置文件中使用

SetEnv

。添加您的配置行,例如:

SetEnv LANG C
有关更多信息,您可以访问 apache 

文档

© www.soinside.com 2019 - 2024. All rights reserved.