Environment variables and PHP

前端 未结 4 991
抹茶落季
抹茶落季 2020-12-09 04:34

I have an ubuntu server with a handful of custom environment variables set in /etc/environment as per the ubuntu community recommendation

When I use php from the com

4条回答
  •  暖寄归人
    2020-12-09 04:47

    The problem is when you run the php-fpm. The process not load the environment.
    You can load it in the startup script.
    My php-fpm is install by apt-get.
    So modify the

    /etc/init.d/php5-fpm

    and add (beware the space between the dot and the slash)

    . /etc/profile

    and modify the /etc/profile to add

    . /home/user/env.sh

    In the env.sh. You can export the environment whatever you need.

    Then modify

    php-fpm.conf

    add env[MY_ENV_VAR_1] = 'value1' under the [www] section.
    Last. restart the php-fpm. You'll get the environment load by the fpm.

提交回复
热议问题