0

I have am running a local server with PHP 5.3.6, and Apache 2.2.19 running on Ubuntu 11.03. I build both Apache and PHP from source. PHP is working fine with Apache, however it seems to never load any extensions. I have uncommented the ones I want PHP to load, I have checked that PHP is reading the INI file, I have uncommented the extension_dir directive and made sure it was correct.

The files mysqli.so and mysql.so seems to be missing, with a lot of other files too. This was my first time installing PHP from source. I am aware that PHP 5.3.6 does not bundle the MySQL client libraries.

I also checked the PHP repository, and it is no longer maintained. I could use PDO, but I much prefer using the MySQL class.

My question is: Where do I get these files from? I have checked the MySQL site, and it doesn't really help me. PHP only seems to be loading the extensions that are already built into PHP.

Mark
  • 11
  • 1
  • 5

2 Answers2

1

MySQL extensions come in separate packages:

$ apt-cache search mysql |grep php

This is what I have on debian (and it worked automatically after installing it via apt-get):

plaes@machine:~$ dpkg -L php5-mysql
/.
/etc
/etc/php5
/etc/php5/conf.d
/etc/php5/conf.d/pdo_mysql.ini
/etc/php5/conf.d/mysqli.ini
/etc/php5/conf.d/mysql.ini
/usr
/usr/share
/usr/share/doc
/usr/lib
/usr/lib/php5
/usr/lib/php5/20090626
/usr/lib/php5/20090626/mysqli.so
/usr/lib/php5/20090626/pdo_mysql.so
/usr/lib/php5/20090626/mysql.so
/usr/share/doc/php5-mysql
plaes
  • 347
  • 5
  • 10
  • Thanks for your reply pleas. I should have mentioned this, but I did try installing it this way, but it never worked. Where does it put the file once you have downloaded it? –  Aug 08 '11 at 08:11
  • I am going to move the so files that are in there into the directory it is reading from. I will then tell you if it worked or not. Thanks plaes. – Mark Aug 08 '11 at 09:02
  • I made a copy of mysql.so and placed it in /usr/local/php-5.3.6/ext. I did a server restart, but it still has not loaded it. – Mark Aug 08 '11 at 09:16
  • Did you edit appropriate php.ini and add extension=mysql.so ? – plaes Aug 08 '11 at 09:24
  • Yes, I edited it. It is uncommented. I also checked the extension_dir, and the value is "./ext", which I assume is correct. Is there any sort of main path for PHP? Or will it automatically read from its root folder? – Mark Aug 08 '11 at 09:26
  • You can get extension_dir using phpinfo(); – plaes Aug 08 '11 at 09:42
  • Yes... that is where I got the value of `extension_dir` from. – Mark Aug 08 '11 at 09:51
  • Hum.. I'm now all out of ideas :S – plaes Aug 08 '11 at 09:58
  • I simply used the full path for the extension, and that worked. Thank you for telling me where I could obtain these files. I can finally get some sleep. – Mark Aug 08 '11 at 10:51
  • 1
    You will run into serious problems when Ubuntu updates its PHP packages, and you don't. – cweiske Aug 08 '11 at 14:56
1

Missing extension .so files

The extensions listed and commented out in php.ini are just examples. They are not "delivered"/installed with PHP by default. Also, there is no mysql.so file unless you built the extension as a "shared" extension.

If you compile PHP yourself, you need to activate the extensions in the configuration. Run ./configure --help to get the options.

If you change the configuration with the configure script, you need to re-make it of course (make && make install).

configure: error: Cannot find MySQL header files under /usr/share/mysql.

Install the libmysqlclient-dev package or use mysqlnd: --with-mysql=mysqlnd (same for mysqli and pdo-mysql config parameters)

Use dpkg -L libmysqlclient-dev to find the location and pass that, or leave the path empty in the configuration parameter.

Compiling it yourself

You don't seem to know much about compiling code yourself, so the question is if your really need it.

Ask yourself the question why you are compiling it yourself.

Check the weight of it against the problems you have when not using the stock packages from ubuntu:

  • you need to install all the devel package
  • upgrading has to be done manually, and the package manager won't do it for you
cweiske
  • 791
  • 1
  • 13
  • 36
  • When you've changed the configuration, do you have to remake it? Do I run make and make install? –  Aug 08 '11 at 08:29
  • This is the error I get: configure: error: Cannot find MySQL header files under /usr/share/mysql. Note that the MySQL client library is not bundled anymore! I also tried these locations: /usr/bin/mysql /etc/mysql /usr/lib/mysql /usr/share/mysql – Mark Aug 08 '11 at 08:36
  • "This was my first time installing PHP from source." – Mark Aug 08 '11 at 09:19
  • Installing that still has not solved the issue. – Mark Aug 08 '11 at 09:36