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.


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
| improve this answer | |
  • 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? – Mark Aug 8 '11 at 8: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 8 '11 at 9: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 8 '11 at 9:16
  • Did you edit appropriate php.ini and add extension=mysql.so ? – plaes Aug 8 '11 at 9:24
  • 1
    You will run into serious problems when Ubuntu updates its PHP packages, and you don't. – cweiske Aug 8 '11 at 14:56

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
| improve this answer | |
  • When you've changed the configuration, do you have to remake it? Do I run make and make install? – Mark Aug 8 '11 at 8: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 8 '11 at 8:36
  • "This was my first time installing PHP from source." – Mark Aug 8 '11 at 9:19
  • Installing that still has not solved the issue. – Mark Aug 8 '11 at 9:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.