php compiles and installs mysqli extension, reporting fatal error: ext/mysqlnd/mysqlnd.h: No such file or directory

Compiling and installing php mysqli extension

phpize
./configure && make && make install

The following error message was encountered.

/bin/sh /usr/local/src/php-7.2.11/ext/mysqli/libtool --mode=compile cc -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -I. -I/usr/local/src/php-7.2.11/ext/mysqli -DPHP_ATOM_INC -I/usr/local/src/php-7.2.11/ext/mysqli/include -I/usr/local/src/php-7.2.11/ext/mysqli/main -I/usr/local/src/php-7.2.11/ext/mysqli -I/usr/local/server/php/include/php -I/usr/local/server/php/include/php/main -I/usr/local/server/php/include/php/TSRM -I/usr/local/server/php/include/php/Zend -I/usr/local/server/php/include/php/ext -I/usr/local/server/php/include/php/ext/date/lib  -DHAVE_CONFIG_H  -g -O2   -c /usr/local/src/php-7.2.11/ext/mysqli/mysqli.c -o mysqli.lo 
mkdir .libs
 cc -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -I. -I/usr/local/src/php-7.2.11/ext/mysqli -DPHP_ATOM_INC -I/usr/local/src/php-7.2.11/ext/mysqli/include -I/usr/local/src/php-7.2.11/ext/mysqli/main -I/usr/local/src/php-7.2.11/ext/mysqli -I/usr/local/server/php/include/php -I/usr/local/server/php/include/php/main -I/usr/local/server/php/include/php/TSRM -I/usr/local/server/php/include/php/Zend -I/usr/local/server/php/include/php/ext -I/usr/local/server/php/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /usr/local/src/php-7.2.11/ext/mysqli/mysqli.c  -fPIC -DPIC -o .libs/mysqli.o
In file included from /usr/local/src/php-7.2.11/ext/mysqli/mysqli.c:34:0:
/usr/local/src/php-7.2.11/ext/mysqli/php_mysqli_structs.h:42:33: **fatal error: ext/mysqlnd/mysqlnd.h: No such file or directory**
 #include "ext/mysqlnd/mysqlnd.h"
                                 ^
compilation terminated.
make: *** [mysqli.lo] Error 1

The point is to look at this sentence. fatal error: ext/mysqlnd/mysqlnd.h: No such file or directory. In the php extension package, the mysqlnd.h library file cannot be found.

But after looking at mysqlnd directory, we found that all the files are in.

At this time in reading the wrong information. /Usr / local / SRC / php-7.2.11/ext/mysqli/php_mysqli_structures. H: 42:33, enter this file, and see line 42.

#include "ext/mysqlnd/mysqlnd.h

This is written in C language. Load the library file mysqlnd.h from the relative path ext, but there is no ext in the mysqli directory. We can solve this problem by creating a soft link:

The php installation package in my host is in / usr/local/src / directory

ln -s /usr/local/src/php-7.2.11/ext/  /usr/local/src/php-7.2.11/ext/mysqli

After the soft link is created, when you need to load the file in the EXT directory in / usr/local/src/php-7.2.11/ext/mysqli, you will directly go to / usr/local/src/php-7.2.11/ext/ to load it.

Recompile the installation now

make clean	//Clear it first
./configure && make && make install

The following prompt appears, indicating that the installation is complete.

Then go to php.ini to add extension instructions

Finally, restart the php service and complete the installation.

Keywords: Operation & Maintenance PHP C

Added by markhard on Tue, 10 Dec 2019 13:52:00 +0200