Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extension shows in phpinfo() but not in php -m #502

Closed
sam452 opened this issue May 15, 2015 · 19 comments
Closed

extension shows in phpinfo() but not in php -m #502

sam452 opened this issue May 15, 2015 · 19 comments

Comments

@sam452
Copy link

sam452 commented May 15, 2015

My phpbrew is 1.18.5, using php 5.4.34 as default and I'm encountering some behavior that I believe I've narrowed down to phpbrew. My SO post is here: http://serverfault.com/questions/692072/call-to-undefined-function-ldap-connect-in-ubuntu?noredirect=1#comment853351_692072

tl:dr; ldap extension is reported to be enabled for apache2 as evidenced by phpinfo() and in apache's mods-enabled.

However, when I run php -m in the command line it reports these: Core, ctype, curl, date, dom, ereg, filter, gd, gettext, hash, json, libxml, mbstring, mcrypt, mhash, mysql, mysqli, mysqlnd, openssl, pcre, PDO, pdo_mysql, Phar, readline, Reflection, session, SimpleXML, soap, SPL, standard, tokenizer, xml, xmlreader, xmlwriter, xsl, zip, zlib
ldap is not one of them.

I attempted to manually enable the extension using phpbrew config, but when restarting apache it returns that it cannot because the ldap module is already enabled.

phpldapadmin still reports that the extension is not enabled and php -m confirms it's not. What am I not understanding about this apparent disconnect? thx, sam

@c9s
Copy link
Member

c9s commented May 17, 2015

Is your php apache module compiled with phpbrew +apxs? it looks like your command-line php is different from your php apache module.

@c9s
Copy link
Member

c9s commented May 17, 2015

Please check your apache config of loading php apache module, e.g. LoadModule php5_module modules/libphp5.4.17.so

If you used phpbrew with +apxs variant, you shall see the version name suffix.

@sam452
Copy link
Author

sam452 commented May 18, 2015

Thank you very much for responding. I believe I set up this php with apxs but how to prove it? My apache config? Apache2.conf reports no modules and that's not right. Perhaps you mean my /etc/apache2/mods-enabled? I can see php5.conf, php5.load. I have been using a2enmod to enable modules. The output of phpbrew info can be found here: https://gist.github.com/sam452/7eaba7cdd129d020d8e7

But that's the phpbrew side, you seem to be asking about apache's config. I'm unsure of which config you're referring to?

@c9s
Copy link
Member

c9s commented May 19, 2015

@sam452 your phpbrew setup looks correct, but you have to confirm that your apache loads the correct module. try phpinfo() from your apache, and you can see the build information.

@c9s
Copy link
Member

c9s commented May 19, 2015

Can you also try to grep under /etc/apache2 ?

grep -r 'LoadModule php5_module' /etc/apache2

And

ls -l /usr/lib/apache2/modules

@sam452
Copy link
Author

sam452 commented May 19, 2015

Happy to provide this info: The grep returns:
/etc/apache2/httpd.conf:#LoadModule php5_module libexec/apache2/libphp5.so
/etc/apache2/httpd.conf:LoadModule php5_module /usr/local/opt/php54/libexec/apache2/libphp5.so
/etc/apache2/original/httpd.conf:#LoadModule php5_module libexec/apache2/libphp5.so

And I have no directory called /usr/lib/apache2/modules. This is new to me as I thought as part of apache's new module system they are enabled from the cli?

my phpinfo output is here: https://gist.github.com/sam452/496b81dfec6eee876d5e

@c9s
Copy link
Member

c9s commented May 19, 2015

Looks like your apache2 is running the php you installed via homebrew, not the one you installed from phpbrew. please see the line below:

Configure Command =>  './configure'  '--prefix=/usr/local/Cellar/php54/5.4.35' '--localstatedir=/usr/local/var' '--sysconfdir=/usr/local/etc/php/5.4' '--with-config-file-path=/usr/local/etc/php/5.4' '--with-config-file-scan-dir=/usr/local/etc/php/5.4/conf.d' '--with-iconv-dir=/usr' '--enable-dba' '--with-ndbm=/usr' '--enable-exif' '--enable-intl' '--enable-soap' '--enable-wddx' '--enable-ftp' '--enable-sockets' '--enable-zip' '--enable-shmop' '--enable-sysvsem' '--enable-sysvshm' '--enable-sysvmsg' '--enable-mbstring' '--enable-mbregex' '--enable-bcmath' '--enable-calendar' '--with-zlib=/usr/local/opt/zlib' '--with-ldap' '--with-ldap-sasl=/usr' '--with-xmlrpc' '--with-kerberos=/usr' '--with-gd' '--enable-gd-native-ttf' '--with-freetype-dir=/usr/local/opt/freetype' '--with-icu-dir=/usr/local/opt/icu4c' '--with-jpeg-dir=/usr/local/opt/jpeg' '--with-png-dir=/usr/local/opt/libpng' '--with-gettext=/usr/local/opt/gettext' '--with-libedit' '--with-unixODBC=/usr/local/opt/unixodbc' '--with-pdo-odbc=unixODBC,/usr/local/opt/unixodbc' '--mandir=/usr/local/Cellar/php54/5.4.35/share/man' '--with-mhash' '--with-curl' '--with-snmp=/usr' '--with-bz2=/usr' '--disable-debug' '--with-openssl=/usr' '--with-xsl=/usr' '--with-apxs2=/usr/sbin/apxs' '--libexecdir=/usr/local/Cellar/php54/5.4.35/libexec' '--with-mysql-sock=/tmp/mysql.sock' '--with-mysqli=mysqlnd' '--with-mysql=mysqlnd' '--with-pdo-mysql=mysqlnd' '--enable-pcntl' '--enable-zend-signals' '--enable-dtrace'

@c9s
Copy link
Member

c9s commented May 19, 2015

Can you also post your build log file? e.g. /home/sam/.phpbrew/build/php-5.4.34/build.log

@sam452
Copy link
Author

sam452 commented May 19, 2015

Yes, happily: https://gist.github.com/dea3c9b70a4ac7d344b2. I was unaware I should have installed apache using phpbrew? Should I change the pointers you found? Unsure where you found it. Wait, my apache that I'm using on my Ubuntu VM was installed by apt-get, I believe. But there does seem to be a cross contamination. How to approach resolving this?

@c9s
Copy link
Member

c9s commented May 19, 2015

no, you can't change it, it's just the settings you used for building php.

I found the apxs2 detection failed in your build log:

checking for Apache 2.0 filter-module support via DSO through APXS... no
checking for Apache 2.0 handler-module support via DSO through APXS... [Sat Jan 03 15:14:03.368521 2015] [core:warn] [pid 10151] AH00111: Config variable ${APACHE_LOCK_DIR} is not defined
[Sat Jan 03 15:14:03.368570 2015] [core:warn] [pid 10151] AH00111: Config variable ${APACHE_PID_FILE} is not defined
[Sat Jan 03 15:14:03.368578 2015] [core:warn] [pid 10151] AH00111: Config variable ${APACHE_RUN_USER} is not defined
[Sat Jan 03 15:14:03.368580 2015] [core:warn] [pid 10151] AH00111: Config variable ${APACHE_RUN_GROUP} is not defined
[Sat Jan 03 15:14:03.368588 2015] [core:warn] [pid 10151] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
[Sat Jan 03 15:14:03.372690 2015] [core:warn] [pid 10151] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
[Sat Jan 03 15:14:03.372765 2015] [core:warn] [pid 10151] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
[Sat Jan 03 15:14:03.372770 2015] [core:warn] [pid 10151] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
AH00526: Syntax error on line 74 of /etc/apache2/apache2.conf:
Invalid Mutex directory in argument file:${APACHE_LOCK_DIR}

Seems like you have a syntax error in /etc/apache2/apache2.conf so apxs2 failed to read your config file.

@c9s
Copy link
Member

c9s commented May 19, 2015

The actual steps are:

  • Install apache2 via system's package manager, e.g. apt-get or yum.
  • run which apxs2 to make sure you have apxs2.
  • use phpbrew with +apxs2=$(which apxs2) to specify the apxs binary
  • then phpbrew should compile one libphp***.so file for your apache2.

@c9s
Copy link
Member

c9s commented May 19, 2015

Please also take a look at https://github.com/phpbrew/phpbrew/wiki/Cookbook#apache2-support

@sam452
Copy link
Author

sam452 commented May 19, 2015

Yes, I remember running which apxs2 in this php variant. => /usr/bin/apxs2. Perhaps I should reinstall php 5.4.34 with all the variants and see if the build error occurs again. Unless I should overwrite my ubuntu apache build and all its vhosts? Also I have no /opt/local/ on this Ubuntu install.

@c9s
Copy link
Member

c9s commented May 19, 2015

Can you show me the line 74 of /etc/apache2/apache2.conf? or if you don't mind, could you send me your /etc/apache2/apache2.conf I can check detail for you.

my mail: yoanlin93@{gmail}

@c9s
Copy link
Member

c9s commented May 19, 2015

No you don't have to overwrite the whole apache, you just need the php5 module file.

@c9s
Copy link
Member

c9s commented May 19, 2015

Hi Sam!

I've found the cause, please take a look at:
http://serverfault.com/questions/558283/apache2-config-variable-is-not-defined

It seems that you need to source the apache envvars files to load the environment variables before running the build command:

source /etc/apache2/envvars

You can validate the config by running:

/usr/sbin/apache2 -V

Cheers,
c9s

@sam452
Copy link
Author

sam452 commented May 19, 2015

Yes, the envvars are sourced and the apxs2 appears to be found using the Apache 2.0 handler-module support via DSO.
But my original problem still exists: Apache sees the ldap is enabled, but the CLI does not. I've tried reinstalling the ldap extension by using
phpbrew ext install ldap
The build log shows this nugget at the end:

checking for LDAP support... yes, shared
checking for LDAP Cyrus SASL support... no
configure: error: Cannot find ldap libraries in /usr/lib.

OK, running whereis ldap yields the following:
ldap: /etc/ldap /usr/lib/ldap /usr/include/ldap.h /usr/share/man/man3/ldap.3.gz

Why do you suppose phpbrew is not finding this library unless the /usr/lib/ldap directory is empty? (It's not). Thx for reading this far, sam

@c9s
Copy link
Member

c9s commented May 19, 2015

If you know where the header files of LDAP is, you can specify double dash to pass the configure options:

phpbrew ext install ldap  --  --with-ldap=.... 

please note I am not familiar with LDAP so the option name might be wrong. you can use show command to show the configure options:

phpbrew ext show ldap

@sam452
Copy link
Author

sam452 commented May 29, 2015

Yes, for me in Ubuntu the correct command was found here: https://gist.github.com/kherge-old2/a7172c7102fbd738837d
phpbrew ext install ldap -- --with-libdir=lib/x86_64-linux-gnu

@sam452 sam452 closed this as completed May 29, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants