php.ini read only from /opt/local/var/db/php5

Scott Haneda talklists at
Tue Nov 17 00:26:27 PST 2009

On Nov 16, 2009, at 10:55 PM, Steve Edwards wrote:

> I'm using and Apache and PHP ports, a

What version of Apache, and what version of php are you using?

I am at php5 @5.3.0_1+apache2+macosx

> nd my php.ini is not being read from where it should be.  According  
> to my phpinfo(), it is loading php.ini from /opt/local/etc/php5,

That is where mine is read from.

> yet any changes I make in that file make no effect, and the Loaded  
> Configuration File is set to (none).

I am assuming you restart apache, in some way or another, after you  
make these changes?

> I noticed a while ago that my other config files (APC.ini,  
> imagick,ini, xdebug.ini, memcache.ini) were not read unless they  
> were in /opt/local/var/db/php5,

I have in /opt/local/var/db/php5
curl.ini   gd.ini     imap.ini   mcrypt.ini zlib.ini

For the php5 Portfile for version 5.3.0, if you look at about line  
set phpinidir           ${prefix}/etc/${my_name}
set extraphpinidir      ${prefix}/var/db/${my_name}

So it is as intended to have the extras in the /opt/local/var/db/php5  

However, /opt/local/etc/php5 should be where php.ini is read from,  
assuming we are on the same version of php installed by the same  
Portfile.  I see any changes with no issue as long as I reload.

> and that seems to be the case with php.ini.  Once I put a copy in / 
> opt/loca/var/db/php5, any changes I made in that file are shown in  
> phpinfo, and Loaded Configuration File shows /opt/local/var/db/php5/ 
> php.ini.

I think it should work fine in the extraphpinidir, but it would be  
nice to discover why your install is not reading from the normal  

Can you show the output of `php -i` ?  Specifically, seeing the  
configure options would be helpful...

Mine has:

I wonder what your 'with-config-file-path' is set to.  Even going to  
back 5.2.10, the phpinidir is set to the same,

Some more snips, for which you should be equivalent...
Configuration File (php.ini) Path => /opt/local/etc/php5
Loaded Configuration File => /opt/local/etc/php5/php.ini
Scan this dir for additional .ini files => /opt/local/var/db/php5

Additional .ini files parsed => /opt/local/var/db/php5/curl.ini,

It would be good to see the line that says 'Loaded Configuration File'  
when the file is non existent, when it only exists in prefix/etc and  
when it only exists in prefix/var and when it exists in both.

Is your httpd.conf file, assuming Apache 2, have uncommented, at added  
the line:
LoadModule php5_module        modules/

And do you also have the line:
Include /opt/local/apache2/conf/extras-conf/mod_php.conf

> So my questions are:
> 1) Why is the one in /opt/loca/var/db/php5 the only one that works?
> 2) Why does Configuration File (php.ini) Path show as /opt/local/etc/ 
> php when that is not the file that is loaded?
> 3) Can my setup be fixed so that the /opt/local/etc/php/php.ini is  
> the file that is used?

I do not know how much you rely on your machine being up and running,  
and what other custom changes you have made.  If this is just a  
version issue, it should be a simple sudo port upgrade php5, or maybe  
you are version 4, in which case a bit of the above is not right.

You could do an uninstall and reinstall of php5, that should work it  
all out. Something like:
sudo port uninstall php5
sudo port install php5

Please add the variants you need, and backup and move aside any ini or  
other config files that you may want t keep around.

Scott * If you contact me off list replace talklists@ with scott@ *

More information about the macports-users mailing list