0

I'm moving from a prefork apache setup to event mode with php-fpm. In prefork mode, I can use SetEnv directives in an htaccess file like so:

SetEnv CI_ENV testing

And that value ends up in PHP:

echo $_SERVER["CI_ENV"]; // outputs "testing"

However, with apache in event mode, that value no longer gets into PHP. Is something broken? What is the best, most orthodox way to fix this? Should I put a SetEnv command in the VirtualHost directive? In the php-fpm.conf file? Please advise.

S

S. Imp
  • 506
  • 1
  • 3
  • 17
  • Everyone will be delighted to know that this question has earned me the Tumbleweed badge. – S. Imp Mar 30 '18 at 15:08
  • Everyone would be delighted to know if this was actually the case - not in htaccess, but you could set it in the virtualhost directive ? – commonpike Nov 14 '18 at 20:22

1 Answers1

0

Everyone should be delighted to know that you can in fact put a SetEnv directive in your VirtualHost in the apache configuration file and this still works, even with PHP-FPM.

In my case, that file is /etc/apache2/sites-available/default-ssl.conf:

sudo nano /etc/apache2/sites-available/default-ssl.conf

Within the VirtualHost in there, you can add your SetEnv directive:

    <VirtualHost _default_:443>
            ServerAdmin webmaster@localhost
            DocumentRoot /var/www/html

            # ETC ETC ETC

            # added because it doesn't work from .htaccess file with PHP-FPM
            SetEnv CI_ENV testing

            # ETC ETC ETC
    </VirtualHost>
S. Imp
  • 506
  • 1
  • 3
  • 17