Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP.ini does not load automatically even though it exists at the config location

Ok this is probably just me not knowing enough about php but here it goes.

I'm on Ubuntu Hardy. I have a custom compiled version of PHP which I have compiled with these parameters.

./configure
--enable-soap
--with-zlib
--with-mysql
--with-apxs2=[correct path]
--with-config-file-path=[correct path]
--with-mysqli
--with-curlwrappers
--with-curl
--with-mcrypt

I have used the command pecl install pecl_http to install the http.so extension. It is in the correct module directory for my php.ini. My php.ini is loading and I can change things within the ini and effect php. I have included the extension=http.so line in my php.ini.

That worked fine. Until I added these compilation options in order to add imap

--with-openssl
--with-kerberos
--with-imap
--with-imap-ssl

Which failed because I needed the c-client library which I fixed by apt-get install libc-client-dev After which php compiles fine and I have working imap support, woo.

HOWEVER, now all my calls to HttpRequest which is part of the pecl_http extention in http.so result in Fatal error: Class 'HttpRequest' not found errors. I figure the http.so module is no longer loading for one reason or another but I cannot find any errors showing the reason.

You might say "Have you tried undoing the new imap setup?" To which I will answer. Yes I have. I directly undid all my config changes and uninstalled the c-client library and I still can't get it to work. I thought that's weird... I have made no changes that would have resulted in this issue. After looking at that I have also discovered that not only is the http extension no longer loading but all my extensions loaded via php.ini are no longer loading.

Can someone at least give me some further debugging steps? So far I have tried enabling all errors including startup errors in my php.ini which works for other errors, but I'm not seeing any startup errors either on command line or via apache. And yet again the php.ini appears to be being parsed given that if I run php_info() I get settings that are in the php.ini.

Edit it appears that only some of the php.ini settings are being listened to. Is there a way to test my php.ini?

Edit Edit It appears I am mistaken again and the php.ini is not being loaded at all any longer. However, If I run php_info() I get that it's looking for my php.ini in the correct location.

Edit Edit Edit My config is at the config file path location below but it says no config file loaded. WTF Permission issue? It is currently 644 so everyone should be able to read it if not write it. I tried making it 777 and that didn't work.

Configuration File (php.ini) Path   /etc/php.ini
Loaded Configuration File   (none)

Edit Edit Edit Edit By loading the ini on the command line using the -c command I am able to run my files and using -m shows that my modules load So nothing is wrong with the php.ini

Edit Edit Edit Edit Edit I have had it pointed out to me that my ini directory config should be a path to find the php.ini file in not the file itself. To this end I have tried settings /etc,/etc/, and letting php set the default directory then moving my ini file into that directory. All fail :(

Edit Edit Edit Edit Edit I have had it pointed out to me that my ini directory config should be a path to find the php.ini file in not the file itself. To this end I have tried settings /etc,/etc/, and letting php set the default directory then moving my ini file into that directory. All fail :(

Edit Edit Edit Edit Edit Edit Further info, command line run of php --ini and ls of dir it points at in the php settings. Also run with -c option on command line where the run succeeds and not when i don't include -c

j@j:/usr/local/lib$ php -ini | grep Configuration
Configuration File (php.ini) Path => /usr/local/lib
Loaded Configuration File => (none)
Configuration
j@j:/usr/local/lib$ ls /usr/local/lib
php  php.ini  python2.5  site_ruby
j@j:/usr/local/lib$ php -c /usr/local/lib/php.ini /var/www/toolbelt/test.php
j@j:/usr/local/lib$ php /var/www/toolbelt/test.php

Fatal error: Class 'HttpRequest' not found in /var/www/toolbelt/test.php on line 7
jonathan@jonathan:/usr/local/lib$

Edit Edit Edit Edit Edit Edit Edit Further info. Utilizing the strace method shown in another stack exchange article I tested to see if there were any attempts to open the ini file made in the loading of php. There were not

j@j:/usr/local/lib$ sudo strace  -e trace=open php -ini 2>&1 |grep  php.ini
Configuration File (php.ini) Path => /usr/local/lib
j@j:/usr/local/lib$ sudo strace  -e trace=open php -ini 2>&1 |grep  /usr/local/lib
Configuration File (php.ini) Path => /usr/local/lib
extension_dir => /usr/local/lib/php/extensions/no-debug-non-zts-20060613 => /usr/local/lib/php/extensions/no-debug-non-zts-20060613
include_path => .:/usr/local/lib/php => .:/usr/local/lib/php
like image 465
Jonathan Park Avatar asked Feb 26 '23 03:02

Jonathan Park


1 Answers

Ok hopefully this will prevent someone else from banging their head against a wall for hours.

I have found my own solution in clean building my php. It turns out that you can alter the with-config-file-path option and have it alter the path that shows up in the phpinfo() and php -ini output. HOWEVER, if you don't clean your build the place where the setting actually gets used does not get rebuilt and will f up your build.

Note to self: always clean your build. I knew this before but got thrown off by the fact that the rebuild does in fact change what php tells me the directory is.

like image 85
Jonathan Park Avatar answered Feb 27 '23 17:02

Jonathan Park