1

I have this strange and stupid problem I'm trying to resolve for a couple of hours now. I have installed apache 2.2.10 (it was compiled from source a long time ago), and PHP-5.3.6. Both are working just great except for the fact I can't get PHP to load the php.ini file.

This is my config.nice file:

'./configure' \
'--prefix=/usr/local/php-5.3.6' \
'--with-config-file-path=/usr/local/php-5.3.6/lib' \
'--with-apxs2=/usr/local/apache-2.2.10/bin/apxs' \
'--with-curl' \
'--with-mysql' \
'--with-zlib' \
'--with-bz2' \
'--with-gd' \
'--with-jpeg-dir' \
'--with-png-dir' \
'--enable-mbstring' \
'--with-freetype-dir' \
'--with-t1lib' \
'--enable-gd-native-ttf' \
'--enable-gd-jis-conv' \
'--with-openssl' \
'--with-openssl-dir' \
'--enable-pcntl' \
"$@"

I've used this config.nice for all the PHP versions since 5.2 with slight changes and it is working this way on a couple of servers. It's probably something small I'm missing and I can't figure what it is.

I set the '--with-config-file-path' because I though php can't find it's own path or something. In the defined path I have a file called php.ini which is copied from the PHP 5.3.6 tarball (php.ini-development).

The file should be working as it's the original but I can't see because it's not loading - phpinfo() returns:

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

Does anybody have an idea what may be the problem ?

Relevant info:
@Server OS: Slackware 12.2
@Apache Version: 2.2.10
@Apache User / Group: daemon / daemon
@PHP Version: 5.3.6 (Latest)
@PHP ini file: /usr/local/php-5.3.6/lib/php.ini
@PHP ini file perms: 777 (daemon.daemon)

tftd
  • 1,480
  • 7
  • 24
  • 38

2 Answers2

2

I'm guessing the file isn't actually there or there is a permissions problem. I'd run echo "<?php phpinfo() ?>" | strace php 2>&1 | grep php.ini to see what is happening.

Mark Wagner
  • 17,764
  • 2
  • 30
  • 47
  • The file is there 100% :) This is what I get when I entered your command - http://pastebin.com/X2XX9GiW – tftd May 05 '11 at 18:38
  • "Loaded Configuration File => /usr/local/php-5.3.6/lib/php.ini" It worked that time. How are you calling php when it doesn't work? – Mark Wagner May 05 '11 at 18:59
  • Hmm... That's really strange. I'm calling it from a apache server (from my browser actually) – tftd May 05 '11 at 19:26
  • It is a permission problem. Apache usually doesn't run as root. That user needs to be able to read php.ini. You could make the perms 644 on it. – Mark Wagner May 05 '11 at 20:05
  • I figured it out. There was a "PHPINIDir" set in apache's virtual hosts. That was forcing apache to tell PHP "Use the php.ini in X dir" and there wasn't any php.ini there. Thanks for the help :) – tftd May 05 '11 at 20:07
1

For people who still couldn't get this resolved: In my case, it was SELinux permissions that was preventing PHP loading php.ini. Changing the context for the php.ini file with the following commands did the trick:

semanage fcontext -a -t httpd_config_t "/usr/local/lib/php.ini"
restorecon -v -R /usr/local/lib/
Elsint
  • 11
  • 1