I am attempting to get MySQL working in PHP on CentOS with Apache that was installed from source by some one else. PHP was also installed from source so yum install php-mysql doesnt work though it does work for CLI PHP but thats not the php apache is using. I have downloaded the new source for php and installed it to replace the old php. My config command was

./configure --with-apxs2=/usr/local/apache/bin/apxs --with-MySQL=/usr/local/mysql --prefix=/usr/local/php --with-config-file-path=/usr/local/php --disable-cgi --with-zlib --with-gettext --with-gdbm

At this point I cant get any mysql code to work and phpinfo() does not show info for MySQL but it does show the above configure command. It maybe something I need to change in my php.ini. Alternatively if I can just use php installed with yum that would work. Just it would need to know php is installed at /usr/local/apache/ or that I need the libphp5.so module for the yum installed php and not the one compiled from source.

1 Answer 1


Which version of PHP? If 5.3 or higher, you could try:


That's the mysql native driver that php started using in php 5.3

Also, in case you haven't, browse through the installation instructions here if it's not 5.3:


  • Thanks a million, recompiled with that flag and it worked like a charm.
    – spetz
    Jul 22, 2011 at 14:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .