Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP not loading php.ini

Tags:

php

apache

Running PHP/Apache on a redhat 6.5 environment. Running into some issues with the PHP installation. PHP was installed and compiles from source and I used the following command to configure it.

'./configure' '--prefix=/u/g/php' '--with-libxml-dir=/u/g/util/libxml2/' '--with-apxs2=/u/g/apache/bin/apxs' '--with-config-file-path=/u/g/php/config' '--enable-mbstring'

This works I can run php and appache. However I am trying to enable some extension and the php.ini file I have configured is not getting read.

In the php_info() it has

Configuration File (php.ini) Path   /u/g/php/config

However as I understand it, it should contain the file like so /u/g/php/config/php.ini

Started/stopped the service..

Any ideas?

like image 807
user3032973 Avatar asked Sep 16 '25 05:09

user3032973


2 Answers

Most servers have more than one php.ini file. My best guess is that you're editing the wrong one. To see which one is actually being used by php, run this:

<?php
$inipath = php_ini_loaded_file();

if ($inipath) {
    echo 'Loaded php.ini: ' . $inipath;
} else {
    echo 'A php.ini file is not loaded';
}
?>

Edit: if this returned 'not loaded', try this in SSH:

php --ini

Or do this in php:

phpinfo();

http://php.net/manual/en/function.php-ini-loaded-file.php

Also, be sure to restart apache after changing the php.ini file.

like image 134
Citizen Avatar answered Sep 17 '25 20:09

Citizen


Sometimes due to error in php.ini files the configuration files are not loaded after that specific error line. In that case you have to thoroughly check the php.ini file and fix the errors.

Alternatively you can download fresh php.ini files for your php version and replace your existing file with the new one.

After making changes in the new file restart your server using service apache2 restart

like image 45
Haseeb Basra Avatar answered Sep 17 '25 20:09

Haseeb Basra