Compiling PHP on a 64bit CentOS installation

Want to help support this blog? Try out Oh Dear, the best all-in-one monitoring tool for your entire website, co-founded by me (the guy that wrote this blogpost). Start with a 10-day trial, no strings attached.

We offer uptime monitoring, SSL checks, broken links checking, performance & cronjob monitoring, branded status pages & so much more. Try us out today!

Profile image of Mattias Geniar

Mattias Geniar, February 12, 2011

Follow me on Twitter as @mattiasgeniar

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



Want to subscribe to the cron.weekly newsletter?

I write a weekly-ish newsletter on Linux, open source & webdevelopment called cron.weekly.

It features the latest news, guides & tutorials and new open source projects. You can sign up via email below.

No spam. Just some good, practical Linux & open source content.