Home > Article > Backend Development > When compiling and installing PHP, configure: error: mysql configure failed. Plea_PHP tutorial
This article comes from: phpoa
It’s been a long time since I compiled and installed PHP. I just wanted to play with nginx. I have no choice but to compile it once and test it. The compilation parameters I added are:
# ./configure –prefix=/usr/local/php –with-config-file-path=/etc –with-gd –enable-gd-native-ttf –with-mysql –with-iconv-dir – with-freetype-dir –with-jpeg-dir –with-png-dir –with-zlib –with-libxml-dir –enable-xml –disable-debug –disable-rpath –enable-discard-path –enable-safe- mode –enable-bcmath –enable-shmop –enable-sysvsem –enable-inline-optimization –with-curl –with-curlwrappers –enable-mbregex –enable-fastcgi –enable-force-cgi-redirect –enable-mbstring –with- mcrypt
Unexpectedly, the following error always occurs
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.
Google for a long time, all the answers are as follows, halo, this is also called an answer, then I have to recompile mysql. This php is very troublesome. This must be wrong.
The Internet search said: When installing PHP, the installation directory of mysql was not specified. But I have already specified it, so this statement is wrong. In fact, the main reason is that mysql-level is not installed, that is, the version of mysql is wrong. You should change it to the
mysql-max-5.0.21 version (which contains all mysql-related content) Software package)
/usr/bin/ld: skipping incompatible /usr/lib/mysql/libmysqlclient.so when searching for -lmysqlclient
/usr/bin/ld: skipping incompatible /usr/lib/mysql/libmysqlclient.a when searching for -lmysqlclient
/usr/bin/ld: cannot find -lmysqlclient
collect2: ld returned 1 exit status
configure: failed program was:
#line 59854 "configure"
# include "confdefs.h"
Looking at the error message in the config.log... Oh, it turns out there is a problem with the version. I remembered that my systems are all X86 and the libs are all 64-bit. So the solution is very easy.
This is libmysqlclient. a library is in /usr/lib64/mysql, not in /usr/lib/mysql.
So you can do the following method to solve it
#export LDFLAGS=-L/usr/lib64/mysql
OR
Please change
-L/usr/lib/mysql
in Makefile to
-L/usr /lib64/mysql