Monday, September 29, 2014

APACHE SetEnv directive (from .htaccess) not send to CGI process

I don't understand Apache2 mecanism in this scenario :



1/ In this location : var/www/cgi-bin/ (user's group rights : www-data)

i've a CGI script (php-cgi) who will execute PHP app + VAR environement version :



#!/bin/bash
# file : var/www/cgi-bin/cgi-php
exec "/usr/bin/php-cgi$PHP_VERSION"


This script have : chmod a+x executed at runtime by user www-data (Apache server)



All PHP versions are located in :





/usr/bin/php-cgi5.6



/usr/bin/php-cgi7.0



/usr/bin/php-cgi7.1



/usr/bin/php-cgi7.2





All versions working fine.



2/ In Apache Server .conf file, i use :




Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Require all granted
AllowOverride All



SetEnv PHP_VERSION 7.1
ScriptAlias /cgi-bin-php/ /var/www/cgi-bin/
Action php-cgi /cgi-bin-php/php-cgi
AddHandler php-cgi .php


When Apache2 restart i can see in http : PHP Version 7.1 loaded (works fine).



3/ If in .htaccess file i put another PHP_VERSION variable, this not sent ??




File : /var/www/html/.htaccess



SetEnv PHP_VERSION 5.6


In this case .htaccess file do nothing at all.
In http i can see : PHP Version 7.1



Question :

Why SetEnv PHP_VERSION X.X at runtime is working (when i start Apache2).



And why i can't set a new variable (SetEnv PHP_VERSION X.X) from .htaccess file ?
I think Apache won't send $PHP_VERSION variable to the shell environment (Ubuntu Server 16.04).



If anyone can help me...
Thanks a lot.



Source : https://www.codejam.info/2014/08/apache-get-php-version-from-environment.html

No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...