I am taking over basic administration duties for a former tech employee for my client. On a CentOS server I have the following:

Apache, PHP and MySQL. He had PHP installed but did not configure it with the MySQL extension (I assume because the server was only hosting a rails-based website).

So I need to reconfigure PHP to use the MySQL extension. Here is the current PHP configure (from phphinfo(); ):

'./configure' '--build=i686-redhat-linux-gnu' '--host=i686-redhat-linux-gnu' '--
target=i386-redhat-linux-gnu' '--program-prefix=' '--prefix=/usr' '--exec-prefix=/usr' '--
bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--
includedir=/usr/include' '--libdir=/usr/lib' '--libexecdir=/usr/libexec' '--
localstatedir=/var' '--sharedstatedir=/usr/com' '--mandir=/usr/share/man' '--
infodir=/usr/share/info' '--cache-file=../config.cache' '--with-libdir=lib' '--with-config-
file-path=/etc' '--with-config-file-scan-dir=/etc/php.d' '--disable-debug' '--with-pic' '--
disable-rpath' '--without-pear' '--with-bz2' '--with-curl' '--with-exec-dir=/usr/bin' '--
with-freetype-dir=/usr' '--with-png-dir=/usr' '--enable-gd-native-ttf' '--without-gdbm' '--
with-gettext' '--with-gmp' '--with-iconv' '--with-jpeg-dir=/usr' '--with-openssl' '--with-
png' '--with-pspell' '--with-expat-dir=/usr' '--with-pcre-regex=/usr' '--with-zlib' '--
with-layout=GNU' '--enable-exif' '--enable-ftp' '--enable-magic-quotes' '--enable-sockets' 
'--enable-sysvsem' '--enable-sysvshm' '--enable-sysvmsg' '--enable-track-vars' '--enable-
trans-sid' '--enable-yp' '--enable-wddx' '--with-kerberos' '--enable-ucd-snmp-hack' '--
with-unixODBC=shared,/usr' '--enable-memory-limit' '--enable-shmop' '--enable-calendar' '--
enable-dbx' '--enable-dio' '--with-mime-magic=/usr/share/file/magic.mime' '--without-
sqlite' '--with-libxml-dir=/usr' '--with-xml' '--with-system-tzdata' '--with-
apxs2=/usr/sbin/apxs' '--without-mysql' '--without-gd' '--without-odbc' '--disable-dom' '--
disable-dba' '--without-unixODBC' '--disable-pdo' '--disable-xmlreader' '--disable-

You can see that he has --without-mysql in there.

When you configure PHP to use --with-mysql, you have to specify the path to mysql right? Or the mysql source? Or something like that? Something like this:


The problem with this existing setup is that MySQL is already installed, except I don't know where its installed at... I know that there is /etc/init.d/mysqld. I also found the following directories:

/usr/lib/mysql/ /usr/include/mysql/ /usr/share/mysql/

Can anyone point me in the right direction here? I just don't know what directory to use with --with-mysql in the PHP configuration.


Okay so I got PHP reconfigured and remade and installed. Now when I restart Apache I get the following:

[warn] module php5_module is already loaded, skipping

Is this because php was already running on the server before? I looked at the httpd.conf and it only has one instance of php5_module getting loaded...

However, when now view the phpinfo(); it shows the PHP being used in the new updated version that I just configured/installed.

Also, the phpinfo(); shows mysql as being used, however when I attempt to install say, Wordpress (which uses MySQL), Wordpress is giving this error:

Your PHP installation appears to be missing the MySQL extension which is required by WordPress.

Where should I be looking now?


Still no solution so far. I've gone through the configuration of PHP to include Mysql and the phpinfo(); (yes I'm using a file.php to view this) shows --with-mysql=shared,/usr (per another users suggestion below). PHP still isn't recognizing MySQL extension as being in the configuration however.

I just don't understand what is the path that you are supposed to put at the end of --with-mysql= ? I have the following directories I've found:

/usr/bin/ contains:
mysql (executable?)

/usr/lib/mysql/ contains:
libdbug.a    libmyisammrg.a      libmysqlclient_r.so         libmysqlclient.so         libmystrings.a  mysqlbug
libheap.a    libmysqlclient.a    libmysqlclient_r.so.15      libmysqlclient.so.15      libmysys.a      mysql_config
libmyisam.a  libmysqlclient_r.a  libmysqlclient_r.so.15.0.0  libmysqlclient.so.15.0.0  libvio.a

/usr/include/mysql/ contains:
chardefs.h  keymaps.h       my_config.h       my_global.h      mysql_com.h      mysql_time.h     readline.h    sql_common.h       tilde.h
decimal.h   m_ctype.h       my_config_i386.h  my_list.h        mysqld_ername.h  mysql_version.h  rlmbutil.h    sql_state.h        typelib.h
errmsg.h    m_string.h      my_dbug.h         my_net.h         mysqld_error.h   my_sys.h         rlprivate.h   sslopt-case.h      xmalloc.h
history.h   my_alloc.h      my_dir.h          my_no_pthread.h  mysql_embed.h    my_xml.h         rlshell.h     sslopt-longopts.h
keycache.h  my_attribute.h  my_getopt.h       my_pthread.h     mysql.h          raid.h           rltypedefs.h  sslopt-vars.h

/usr/share/mysql/ contains:
charsets  english               french     italian      my-innodb-heavy-4G.cnf  mysql_fix_privilege_tables.sql  norwegian     romanian  spanish
czech     errmsg.txt            german     japanese     my-large.cnf            mysql_system_tables_data.sql    norwegian-ny  russian   swedish
danish    estonian              greek      korean       my-medium.cnf           mysql_system_tables.sql         polish        serbian   ukrainian
dutch     fill_help_tables.sql  hungarian  my-huge.cnf  my-small.cnf            mysql_test_data_timezone.sql    portuguese    slovak

Does any of that help?


Yes I'm using virtual hosts. Here is my conf file:

Listen 80
NameVirtualHost *:80

<VirtualHost *:80>
        ServerName thedomain.com
        ServerAlias www.thedomain.com
        DocumentRoot /u1/thedomain.com/public
        RailsEnv production

<VirtualHost *:80>
        ServerName subdomain.thedomain.com
        DocumentRoot /u1/subdomain.thedomain.com/public

I'm attempting to setup a basic Wordpress install on the subdomain. I'm getting this error still:

Your PHP installation appears to be missing the MySQL extension which is required by WordPress.


I just added --with-mysql (with no path) to the PHP config and reinstalled it and PHP just found what it needed from MySQL on its own apparently. Thanks for the insight everyone.

5 Answers 5


Unless mysql is installed in a non standard location you should be able to just specify --with-mysql with no path. you may also want --with-mysqli to get the new improved mysql interface.



you are using virtual hosts? You can check it. Only one PHP instance allowed for one Apache configuration tree (for one apache process). Declaring several PHP instances in different virtual hosts takes no effect.


Regarding your update: The apache warning is telling you that the php5 apache module has already been added somewhere in the configuration. If you go through your configuration, and more importantly included additional configuration files you'll see something like:

#PHP Stuff
AddModule mod_php5.c

in more than one place. Fear not, it's not an important error, and you can just ignore it (or grep through your configuration files, grep -ir 'mod_php5' /etc/httpd.d/*).

As far as the --with-mysql path, in my case the mysql binaries can be found in /usr/local/bin/my* and /usr/local/sbin/my*, so my --with-mysql line can be seen here:

'./configure' '--with-pear' '--disable-cli' '--with-apache=/usr/src/apache_1.3.41' '--with-mysql=/usr/local' '--enable-safe-mode'

(that's just an example, it won't necessarily be correct for your setup). In your case I would try --with-mysql=/usr/share/mysql (out of the options you've given it seem to be most likely to be correct. Try ls /usr/share/mysql/bin/my*)

If you've installed pecl along with php you can actually use pecl to install mysql/mysqli without recompiling everything else. I usually use their cpan-like shell, but I'm told you can just do "pecl install mysql" and "pecl install mysqli" If you use pecl, you can then add the mysql.so and mysqli.so as extension= lines in your php.ini, making sure that your extension_dir is correct. However, the way you're doing it, mysql support should be compiled into php it's self, making any additions to php.ini unnecessary.

Lastly - just from personal experience, if you keep on messing around recompiling php and you start getting really weird linker errors (or weird problems in general) backup your Makefile/config.h and do a make clean first. This will clear out all the intermediary object files.

Erm, one more note - if you use php -i from the command line to get your phpinfo();, make a phpinfo.php test file, as the cli and apache modules can have different php.ini files.

Now that I've actually finished this follow-up, I'm not sure if it will actually fix your problem, however it will hopefully help.


The configure string above doesn't closely resemble that of the PHP5 CentOS/RHEL PHP package, so I'll assume PHP has manually been configured and installed on the machine.

For a recent CentOS/RHEL machine, the following flag to PHP's configure script should suffice:


(as used in the official CentOS/RHEL PHP package).

You'll need the mysql and mysql-devel packages to successfully compile against, and use the MySQL libraries.

For reference: On a CentOS/RHEL system fully using package management, the following will install PHP and the MySQL extension:

yum install php php-mysql



A few days ago I wrote post about compiling PHP on Linux: http://users.livejournal.com/__hedin/182480.html

Sorry, but it on russian (and I can't translate it now). You can use Google Translate instead.

In short, you should use this options on x64 Fedora:

-with-mysql=/usr/bin -with-libdir=lib64

and after make && make install check if libphp5.so appeared in your apache modules directory

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.