Saturday, May 13, 2017

apache 2.2 - phpinfo.php is not showing extra folder for additional PHP configuration files

My phpinfo.php is not showing extra folder for additional PHP configuration files. I am running Apache v2.4.4(with PHP DSO) and PHP v5.4.14 on CentOS v6.3 32-bit. Apache and PHP installations are compiled from source.



I have not used the configure option '--with-config-file-scan-dir=PATH' for PHP. (And won't be using because I will be needing more than one folder).



Environment variable PHPRC and Apache Directive PHPIniDir are related to the main PHP file, which leaves me with the Environment variable 'PHP_INI_SCAN_DIR' to work with. Below are the steps what I did:-






'PHP_INI_SCAN_DIR' being an OS Environment variable is required to be set before Apache starts. So I added the following entry to my /etc/profile.d/php.sh file.




PHP_INI_SCAN_DIR="/usr/local/lib/php/custom"
export PHP_INI_SCAN_DIR


Then rebooted the system.




Now the commands 'env | grep PHP', 'php -i | grep INI' and 'php --ini' gives me the following outputs.



=> # env | grep PHP




PHP_INI_SCAN_DIR=/usr/local/lib/php/custom


=> # php -i | grep INI





PHP_INI_SCAN_DIR => /usr/local/lib/php/custom
_SERVER["PHP_INI_SCAN_DIR"] => /usr/local/lib/php/custom


=> # php --ini




Configuration File (php.ini) Path: /usr/local/lib
Loaded Configuration File: /usr/local/lib/php.ini

Scan for additional .ini files in: /usr/local/lib/php/custom
Additional .ini files parsed: (none)




First Attempt



===================




Added the following entry in both apache2/bin/envvars & apache2/bin/envvars-std files.



(Any comments on what is the difference between envvars & envvars-std file?)




PHP_INI_SCAN_DIR="/usr/local/lib/php/custom"
export PHP_INI_SCAN_DIR


Restarted Apache service.

But the value for 'Scan this dir for additional .ini files' from phpinfo.php file shows empty.



Second Attempt



===================



So I removed the entries from envvars & envvars-std. I have module mod_env loaded by default. I added the following in httpd.conf.




SetEnv PHP_INI_SCAN_DIR "/usr/local/lib/php/custom"



Restarted Apache service.
Value for 'Scan this dir for additional .ini files' from phpinfo.php file still shows empty.



Third Attempt



===================



Again, I removed the entries from httpd.conf. Added the same line to Directory section of my VirtualHost in httpd-vhosts.conf.





SetEnv PHP_INI_SCAN_DIR "/usr/local/lib/php/custom"


Restarted Apache service.
Value for 'Scan this dir for additional .ini files' from phpinfo.php file still shows empty.



ANSWERS ON SOME OF YOUR THOUGHTS:





  • Yes, my phpinfo.php file is made of only phpinfo(). It is not a static file.


  • Yes, the browser cache was cleaned. I also tried another browser.




Finally



So, can anyone tell me why my phpinfo file is not showing the extra folder for additional PHP configuration files?



Thanks in advance.

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...