Compiling PHP on a 64bit CentOS installation

When you try to compile your PHP on a CentOS 64bit system, you can run into the following with just the default parameters, about not finding the MySQL development libraries.

First, make sure you have those libraries installed.

# yum install mysql-devel

And see if your configure command outputs something similar to this.

# ./configure –with-mysql …

checking for MySQL support… yes

checking for specified location of the MySQL UNIX socket… no

checking for MySQL UNIX socket location… no

checking for mysql_close in -lmysqlclient… no

checking for mysql_error in -lmysqlclient… no

configure: error: mysql configure failed. Please check config.log for more information.

You need to specify the –with-libdir parameter at the very beginning of your configure command, to tell your compiler you’re using 64bit libraries.

# ./configure –with-libdir=lib64 –with-mysql  …

# make

Alternatively, you can also use the following setup.

# LDFLAGS=-L/usr/lib64/mysql ./configure –with-mysql …

# LDFLAGS=-L/usr/lib64/mysql make

If you use the last method, it’s important to note that you need to specify the LDFLAGS