Local PHP5 installation not reading config file


#1

Hello all!
I’ve been following the instructions at http://wiki.dreamhost.com/index.php/Installing_PHP5 to compile my own custom PHP5 installation, so I can alter some of the php.ini settings. The script runs fine, and PHP is indeed installed – however, PHP now appears to not be loading anything from the local php.ini. Running phpinfo() points at the correct configuration file, but changes to said configuration file aren’t reflected in phpinfo(). I really need output_buffering set to true for my site to work – does anyone have any suggestions for where the problem could be?

Clint Olson


#2

Your phpinfo does point to the ini in your home directory? Then it has to be reading your ini file. Have you tried tweaking any other settings to see if they take?

output_buffering is a numerical value. DH’s default is 4096.

-Scott


#3

[quote] […]
does anyone have any suggestions for where the problem could be?[/quote]
Linkies to pertinent phpinfo() page, please.


#4

Yeah, that’s what I thought, too… only it’s not getting its settings from there. I’ve tried changing several, and no joy.

rubs eyes Ah… I could have sworn it was off by default. At any rate, I’d still really like to get the custom installation working, as I’m trying to add GMP support in to allow for a nice public-key encryption module down the road.

As a side note, even though php_info() points to the directory, it still works fine even if php.ini is removed from the directory. Talk about odd…

Clint Olson


#5

http://www.grabmail.org/info.php


#6

I think that the php.ini you have in your home directory is just to change the defaults set in your PHP5 installation. Have you tried modifying the php.ini in your PHP5 installation directory?

-Scott


#7

Ok, think I may have found the problem. The info.php page will be offline for a bit while I recompile PHP. My guess at this time is that PHP doesn’t like following symlinks in the path to its ini file. It was compiled with the configure setting:

‘–with-config-file-path=/home/softsys/php5/etc/php5/grabmail.org’

However, ‘/home/softsys’ is in reality a symlink to /home/.barou/softsys’. When I replaced php.cgi with a bash script exporting the variable PHPRC as ‘/home/.barou/softsys/php5/etc/php5/grabmail.org/’ before calling the PHP executable, it worked fine. I’ll let you all know how it turns out once it’s recompiled. If this fixes it, the note is probably worth adding to the wiki page.

Clint Olson


#8

Heh, sorry about that – you must have viewed info.php while I was tinkering around with using a bash script as php.cgi. The php.ini in my home directory is just a copy of the one in php5/etc/php5/grabmail.org – at that time, I was just trying to come up with any way at all to make it recognize a php.ini other than one I gave it in the configure option.


#9

Ok, update – recompiling PHP with a modified with-config-file-path doesn’t fix it. One thing I notice (and which you should be able to see right now at http://grabmail.org/info.php) is that PHP isn’t finding the php.ini file, even though it definitely exists in that location.

According to http://www.faqts.com/knowledge_base/view.phtml/aid/30126/fid/471, if PHP can’t locate any config file, it gives the last directory searched (without the filename) in the “Configuration File (php.ini) Path” field of phpinfo(). If I replace php.cgi with a bash script exporting PHPRC as the exact same value as with-config-file-path, it shows /php.ini, while without the bash script it just shows . What gives?

EDIT: Just out of curiosity, is the bash script approach likely to cause a large performance hit, as Apache invokes bash in addition to PHP every time a webpage is accessed? It does seem quite hackneyed, but if it does the trick…

EDIT2: Switched over to the bash script method, at least temporarily. Copies of info.php both ways can be seen at http://www.grabmail.org/info-cgi-nobash.htm and http://www.grabmail.org/info-cgi-bash.htm.

Clint Olson


#10

Don’t use .barou in your path name. Use $HOME which should just be /home/softsys.
Also, do NOT use a bash script for php! It’ll start a new PHP process for each connection. This is a BAD thing if you’re using APC caching system (cause the PHP processes don’t close).

Always point directly to the binary itself. It’s safer. PHP binary will not show php.ini if it does not find a php.ini file.


yerba# rm -rf /etc
yerba#


#11

[quote]Don’t use .barou in your path name. Use $HOME which should just be /home/softsys.
Also, do NOT use a bash script for php! It’ll start a new PHP process for each connection. This is a BAD thing if you’re using APC caching system (cause the PHP processes don’t close).

Always point directly to the binary itself. It’s safer. PHP binary will not show php.ini if it does not find a php.ini file.[/quote]
OK, so… any idea how I can get it so that PHP sees the INI file, then? I don’t know how to make it so that the PHP CGI gets the PHPRC variable, and nothing I’ve tried with regard to the --with-config-file-path option has worked at all.

I honestly don’t know why it’s not finding php.ini by with-config-file-path – it’s definitely pointing to the right directory (I’ve tried it both with the .barou and without it).

Clint Olson


#12

And – ls -l /home/.barou/softsys/php5/etc/php5/grabmail.org – does not show an ini file? That doesn’t make since.

If you do an (exactly like this): ls -l /home/.barou/softsys/php5/etc/php5/grabmail.org
what do you get?


yerba# rm -rf /etc
yerba#


#13

[quote]And – ls -l /home/.barou/softsys/php5/etc/php5/grabmail.org – does not show an ini file? That doesn’t make since.

If you do an (exactly like this): ls -l /home/.barou/softsys/php5/etc/php5/grabmail.org
what do you get?[/quote]
[ivan]$ ls -l /home/.barou/softsys/php5/etc/php5/grabmail.org
total 88
-rw-r–r-- 1 softsys pg185540 41318 2006-07-06 19:26 php.ini
-rw-r–r-- 1 softsys pg185540 41317 2006-07-06 13:48 php.ini.old

It’s there, all right.

Clint Olson


#14

I should add that this is a problem that just cropped up with the most recent version of the installscript. I’d had the old version (the one that installed everything to directories under $HOME/domain.com rather than $HOME/php5, and it worked fine. I like the new one better, though – it seems much more secure to me not to have all those files hosted where they can be got at via the web (even though I theoretically could protect them with .htaccess files).

Clint Olson


#15

As suspected, your php.cgi is compiled for a specifically pathed file as evidenced in the “Configure Command” area at the top:

'--with-config-file-path=/home/softsys/php5/etc/php5/grabmail.org'…so it’ll only use the php.ini file under that directory. If modifying the php.ini in that directory doesn’t fix the problem, then I’m confused too.

PS: Just altered my own php.ini file just for giggles; see:
http://www.netdcon.net/zphp.php
…seems to’ve worked just dandy.


#16

[quote]As suspected, your php.cgi is compiled for a specifically pathed file as evidenced in the “Configure Command” area at the top:
’–with-config-file-path=/home/softsys/php5/etc/php5/grabmail.org’

…so it’ll only use the php.ini file under that directory. If modifying the php.ini in that directory doesn’t fix the problem, then I’m confused too.[/quote]
Yeah, it’s really odd – phpinfo() shows that PHP looked for an INI file in that directory, but didn’t find one – despite it obviously being present. You can see the results at http://www.grabmail.org/info-cgi-nobash.htm – note that the “Configuration File (php.ini) Path” field points only to a directory, and not to a specific php.ini file. This indicates that it’s not finding the file, which is rather strange, considering it’s definitely there, and shows up when I hack it with a bash script to set the PHPRC variable: http://www.grabmail.org/info-cgi-bash.htm

I guess my question now is, is there any way to make the PHPRC environment variable visible to Apache, or at least the part of Apache that spawns PHP as a CGI script? I’m told that substituting a Bash script that sets the PHPRC variable is a no-no – yet, nothing else I’ve tried works. Any ideas?

Clint Olson


#17

It’s finding something; your phpinfo() at: http://www.grabmail.org/info.php is now showing an output buffer of 4096.

Ick, no. But (again) for giggles, you can always try adding a line to your .htaccess to something like:

SetEnv PHPRC [i]value[/i]…but I must confess that I’ve never tried such a thing myself.


#18

Yeah, it was using the Bash script trick to tell PHP where the INI file was.

[quote]Ick, no. But (again) for giggles, you can always try adding a line to your .htaccess to something like:
SetEnv PHPRC value

…but I must confess that I’ve never tried such a thing myself.[/quote]
Ah ha! That seems to have done the trick quite nicely. Thank you very much… I added the SetEnv line to my base .htaccess, removed the Bash script redirect, and everything works fine. Problem solved!

Clint Olson


#19

There’s a last check – check your directory permissions. Each one.

Every single directory needs at least execute permission on other. The last one may also need read.

Did you do anything special with directory permissions? When in doubt do: chmod -r a rX $HOME/php5/
(big X means make executable only if it’s to be executable)

Permissions is the one and last thing that could stop PHP from seeing the INI file.
You could also test its ability to see it by trying to fopen the file for read within PHP. It, in reality, should error out.


yerba# rm -rf /etc
yerba#


#20

[quote]There’s a last check – check your directory permissions. Each one.

Every single directory needs at least execute permission on other. The last one may also need read.

Did you do anything special with directory permissions? When in doubt do: chmod -r a rX $HOME/php5/
(big X means make executable only if it’s to be executable)

Permissions is the one and last thing that could stop PHP from seeing the INI file.
You could also test its ability to see it by trying to fopen the file for read within PHP. It, in reality, should error out.[/quote]
Yup, just checked the permissions, and everything checks out. Besides, wouldn’t permissions affect it when using the PHPRC variable as well as the --with-config-file-path method?

At any rate, I think netdcon has me all sorted out. Adding a SetEnv PHPRC entry into the main .htaccess file seems to have done the trick, without having to resort to a Bash redirect. It still bothers me a bit that --with-config-file-path doesn’t work, but I can live with that. Thank you for all your help!

Clint Olson