下载对应版本的PHP源码并解压,我的版本是php-5.4.16
进入源码目录下的ext/mysqlnd,并编译出mysqlnd.so
<code><span>cp</span> config9<span>.m</span>4 config<span>.m</span>4 sed -ie <span>"s{ext/mysqlnd/php_mysqlnd_config.h{config.h{"</span> mysqlnd_portability<span>.h</span><span>#修改源文件</span> phpize <span>#执行phpize,增加./configure 配置</span> ./configure --with-php-c/to/php-config <span>#配置文件为原php的bin下的php-config</span> sudo make &&sudo make install <span>#编译安装</span></code>
如果不晓得php-config在哪,可以用这个命令查找
<code>sudo find <span>/</span><span>-name</span> php<span>-config</span></code>
进入ext/mysql,编译出mysql.so
<code>phpize <span>.</span>/configure <span>--</span><span>with</span><span>-php</span><span>-config</span><span>=</span>/path/<span>to</span>/php<span>-config</span><span>--</span><span>with</span><span>-mysql</span><span>=</span>mysqlnd make <span>&&</span> make install</code>
进入ext/mysqli,编译出mysqli.so
<code>phpize <span>.</span>/configure <span>--</span><span>with</span><span>-php</span><span>-config</span><span>=</span>/path/<span>to</span>/php<span>-config</span><span>--</span><span>with</span><span>-mysqli</span><span>=</span>mysqlnd make <span>&&</span> make install</code>
在php.ini中加入
<code><span>extension=<span>mysqlnd</span></span><span>extension=<span>mysql</span></span><span>extension=<span>mysqli</span></span></code>
以上就介绍了PHP 动态编译安装 mysqli mysql mysqlnd,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。