Welcome! Log In Create A New Profile


php-fpm environment variables on starup

Posted by snagytx 
php-fpm environment variables on starup
July 15, 2015 10:55AM

I really want to use php-fpm (thinking ahead for high request volume) but I need to load a DB driver that needs some environment variables to be loaded on startup.

Does anybody have any details on how to do it?

I tried updating: the pool config file with:

env[XXX] = 'YYY'

but if in the driver I do a "getenv(XXX)" the environment variable is not there.

If I run "php-fpm -i" from the command line I can see that the env variable is passed to to my driver correctly.

For Reference I run:

CentOS 7 with php 5.4.16(the version that comes with CentOS 7) any clues in the right direction are appreciated

Thank you.
Re: php-fpm environment variables on starup
July 16, 2015 09:13AM
in case somebody hits the same issue:

In my case the manager needs to get the environment variables on startup.

Looking at the php-fpm.service file I noticed that there is a "EnvironmentFile" variable pointing to "/etc/sysconfig/php-fpm". I added "XX=YY" in the /etc/sysconfig/php-fpm file restarted php-fpm and the issue was fixed, the environment variable was read.

I second issue I hit was a restriction from selinux, it took me a while to realize that selinux was blocking the driver to work fine. Fixes selinux permission and now everything works fine.

hope this prevents others from fighting with this
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 158
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready