Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP doesn't load extensions specified in php.ini, but loads with dl()

Tags:

php

Php doesn't load extensions specified through php.ini

php -v doesn't give any errors or warnings

php -i | grep extension_dir shows that extension_dir is set to where extension files are, but they don't show up in extension list in php -m

However running php -r 'dl("apc.so"); phpinfo();' | grep apc shows that modules load normaly with dl() function.

I installed php-5.3.5 from source. Configured with

'--enable-fastcgi'
'--enable-fpm'
'--enable-mbstring'
'--enable-pdo'
'--enable-inline-optimization'
'--enable-sockets'
'--enable-zip'
'--enable-mbregex'
'--enable-xml'
'--enable-sysvsem'
'--enable-sysvshm'
'--enable-pcntl'
'--enable-ftp'
'--enable-soap'
'--enable-shmop'
'--disable-rpath'
'--disable-debug'
'--with-mcrypt'
'--with-zlib'
'--with-curl'
'--with-bz2'
'--with-mysql'
'--with-gettext'
'--with-gd'
'--with-pdo-mysql'
'--with-pcre-regex'
'--with-mhash'
'--with-pic'
'--with-zlib-dir'
'--with-ttf'
'--with-openssl'
'--with-png-dir'
'--with-libdir=lib64'
'--without-pdo-sqlite'
'--without-sqlite'

uname -a prints:

Linux ip-*-*-*-* 2.6.34.7-56.40.amzn1.x86_64 #1 SMP Fri Oct 22 18:48:49 UTC 2010 x86_64 x86_64 x86_64 GNU/Linux

Php runs on nginx 0.9.5 through php-fpm

like image 638
Nekuromento Avatar asked Mar 20 '11 12:03

Nekuromento


1 Answers

For extensions to be loaded, you must have one line such as the following one :

extension=apc.so

in the php.ini (or any other .ini file) file that's used by PHP.


If extensions load properly when you're using dl(), it means your extensions are OK (no wrong version or anything like that).

The next step, so is to :

  • Make sure you have added the extension=... lines to your php.ini file
  • Make sure you've modified the right php.ini file

You can check which php.ini file is used : it's displayed in the ouput of phpinfo().


Note : with some Linux distributions, the php.ini file used in CLI is not the same one as the one used with Apache (not sure about the one used for nginx).

like image 93
Pascal MARTIN Avatar answered Sep 27 '22 16:09

Pascal MARTIN