0

I know this gets asked a lot here but I've done my homework and cant seem to solve my particular problem. It doesn't seem like my php.ini file is being loaded, even though php -i and php --ini say it is.

Specs:
CentOS 7.2
PHP 5.6.24
Apache 2.4.6

$ php -i | grep "Loaded Configuration"
Loaded Configuration File => /etc/php.ini
$ php --ini | grep "Loaded Configuration"
Loaded Configuration File:         /etc/php.ini

/etc/php.ini exists and has no obvious problems but phpinfo() shows;

Configuration File (php.ini) Path   /etc
Loaded Configuration File   (none)
Scan this dir for additional .ini files /etc/php.d

So my question is why is the phpinfo page showing no loaded config file, and how to I resolve the problem?

My log files for httpd do not show any errors when restarting httpd either.

Thanks in advance.

4
  • PHP on the CLI and PHP on the webserver may use totally different php.ini file locations. What does <?php phpinfo(); ?> accessed via the webserver show as the php.ini location?
    – ceejayoz
    Aug 23, 2016 at 23:34
  • @ceejayoz I suspect that it shows what is already in the post! Aug 24, 2016 at 1:32
  • @MichaelHampton Bed time for me, it would seem. I have no idea how I missed that. Apologies, OP!
    – ceejayoz
    Aug 24, 2016 at 2:44
  • @ceejayoz I'm aware PHP and PHP-cli can use different php.ini files, but thank you for the suggestion anywa
    – Michael
    Aug 24, 2016 at 5:25

1 Answer 1

1

See if you have the correct SELinux label for php.ini. Try running restorecon and then restart web server.

restorecon -v /etc/php.ini 
systemctl restart httpd
3
  • Yes this worked. I'm new to CentOS but am developing an irrational hatred for SELinux, which is primarily based on my lack of understanding of all the special ways it stops me from doing what I'm trying to do. Can you explain why this worked? Also, is there a difference between "systemctl restart httpd" and "services httpd restart" ?
    – Michael
    Aug 24, 2016 at 5:29
  • @Michael restorecon sets the default security context for the specified file. Some file operations doesn't apply the correct SELinux labels. You can always check SELinux labels with -Z flag, eg ls -lZ For you second question, both commands performs the same action. "service" is old and it just redirect the operation to systemctl which is new.
    – Sanjeewa
    Aug 25, 2016 at 23:40
  • Learn something new here every day. Thanks very much for the explanation. Funny thing, I never encountered systemctl until CentOS.
    – Michael
    Aug 29, 2016 at 6:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .