mahbad mahbad - 8 months ago 65
Apache Configuration Question

PHP - - ini "(none)" and not loading extensions

So I ran into something I'm just hoping I can get some understanding on. There is a clean Centos machine with a clean install of PHP. It had the mongoDB driver installed as well. When accessing the web app through the browser, it kept complaining the mongo client didn't exist. All of the installation procedures were followed,

php.ini
contained
extension=mongo.so
, and httpd restarted. PHP
info()
did not contain the Mongo conf. What ended up working was adding a
mongo.ini
file to the
/etc/php.d
directory with the
extension=mongo.so
written to it.

I'm getting a sneaky suspicion
php.ini
wasn't being loaded correctly, but I don't understand why. The reason I'm thinking this is, for one, it worked after adding
mongo.ini
. Second, there are mismatched PHP
info()
outputs from the CLI and browser gui.

cli output

and from the GUI

gui output

Both of these were snapped seconds apart. No configuration changes or restarts were made. For some reason the CLI output says the loaded configuration file was
/etc/php.ini
which was expected. The browser GUI however shows
(none)
. What is going on here? Is this why the
extension=mongo.so
was never loading from the
php.ini
file?

versions

Apache/2.4.6
PHP/5.4.16
CentOS Linux release 7.3.1611

[someUser@someServer etc]# find / -name php.ini
/etc/php.ini


Is SO even the proper place for this? or should I move to a different forum?

update

After reading Grigory Ilizirov's comments, and doing some research, I think the question is answered if he wants to post it. Looks like the php configs for apache wasn't being loaded. I had just assumed the
/etc/php.ini
file was all that was needed to be edited. Now I just need to figure out how the heck I'm going to do that.

update 2

Reverted back to a clean install and did everything again. This time around, same results from the CLI and web GUI as before, but now mongo wouldn't load at all despite being added in
/etc/php.d/mongo.ini
. suspect SELinux is interferring with apache.
mongo.ini
is no longer showing in the additional .ini file sections. Disabling SELinux and rebooting allows it to load to apache.

FINAL

This is indeed an SELinux issue. Now then, does this belong on SO for future users?

Answer Source

It was indeed SELinux interfering with Apache's access to the PHP configuration file. Adding the security context fixed it.

semanage fcontext -at httpd_sys_content_t '/etc/php.ini'
semanage fcontext -at httpd_sys_content_t '/etc/php.d/(/.*)?'
restorecon -Rv /etc/
systemctl restart httpd

apache found the config file

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download