skip to Main Content

I have some issues to set the LANG environment variable to my apache webserver.

When I print out the configuration (using php_info()) at my php-File I get the following entries (for environment):

enter image description here

Regarding the fact, that it should already been set on the default service settings (/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  # <-----------------------------------

...

Even when I try to modify enviroment of the service with additional files like /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

The environment still just contains "USER" and "HOME".

Additional information:

httpd -v
Server version: Apache/2.4.57 (AlmaLinux)
Server built:   Jul 20 2023 00:00:00

ENV Apache Module is loaded:

[root@alma-master ~]# httpd -M
Loaded Modules:
...
env_module (shared)
...

Any ideas? Thanks in advance!

2

Answers


  1. Chosen as BEST ANSWER

    The reason for this behavior was PHP-FPM (which seems to be a default module at recent linux versions) - in older version this module was not installed when I run "yum install php"

    All you have to do - set the parameter "clear_env" (default yes) to no.

    /etc/php-fpm.d/www.conf:

    clear_env = no
    

  2. One possible way is to use SetEnv in apache config file. Add in your config line like:

    SetEnv LANG C
    

    For more information you can visit apache documentation.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search