PHP Standalone compilation installation extension (Mysqli,pdo-mysql)

Source: Internet
Author: User
Tags php compiler zts


php compiler Installation Extension (Mysqli,pdo-mysql)

Qunying.liu

201410.30

1. Description of the environment:


System: CentOS 6.3 64-bit Linux

PHP Version: 5.3.13

MySQL version: 5.5.26


PHP installation directory:/usr/local/php

PHP configuration file:/usr/local/php/etc/php.ini

PHP Extension Directory:/usr/local/php/lib/php/extensions/no-debug-non-zts-20090624/

MySQL installation directory:/usr/local/mysql


Ini:

; Directory in which the loadable Extensions (modules) Reside.extension_dir = "/usr/local/php/lib/php/extensions/ no-debug-non-zts-20090624/"


2. Compile and install the extension:


PHP extension Installation Pdo_mysql module, under the Linux system, the following steps to complete the module installation:


# TAR-ZXVF Php-5.3.13.tgz

# CD Php-5.3.13/ext/pdo_mysql

#/usr/local/php/bin/phpize

# Cp/usr/local/mysql/bin/mysql_config/usr/bin/mysql_config

#./configure--with-php-config=/usr/local/php/bin/php-config--with-mysql-config=/usr/bin/mysql_config-- With-pdo-mysql=/usr/local/mysql--enable-pdo=shared

# Make && make install


Note: Make test will error, but does not affect the normal installation of the compilation, can be ignored:

=====================================================================php          : /usr/local/php/bin/php php_sapi    : cliphp_version  : 5.3.13ZEND_VERSION: 2.2.0PHP_OS      : Linux -  centos 6.3 linux x64ini actual  : /usr/local/php/etc/php.inimore . inis  :  cwd         : /usr/local/src/ php/php-5.3.13/ext/pdo_mysqlextra dirs  : ================================================ =====================running selected tests. skip pdo mysql bug  #33689   (query ()  execute ()  and fetch ()  return  false on valid select queries)  [tests/bug_33689.phpt] reason:  Sqlstate[hy000] [2002] can ' t connect to local mysql server through socket  '/tmp/mysql.sock '   (2) skip pdo mysql bug  #37445   (premature stmt object destruction)  [tests/bug_37445.phpt] reason:  Sqlstate[hy000] [2002] can ' T connect to local mysql server through  socket  '/tmp/mysql.sock '   (2) skip pdo mysql bug  #39483   (problem  with handling of \ char in prepared statements)  [TESTS/BUG_39483.PHPT]  reason: sqlstate[hy000] [2002] can ' t connect to local mysql  server through socket  '/tmp/mysql.sock '   (2) skip pdo mysql bug  #41698   (float parameters truncated to integer in prepared statements)  [ Tests/bug_41698.phpt] reason: sqlstate[hy000] [2002] can ' t connect to local  mysql server through socket  '/tmp/mysql.sock '   (2) Php warning:  opendir (ext/pdo/tests):  failed to open dir: no such file or directory in /usr/local/ src/php/php-5.3.13/ext/pdo_mysql/run-tests.php on line 597error: cannot open  directory: ext/pdo/testsmake: [test] error 1  (ignored)


PHP extension Installation mysqli module, under the Linux system, the following steps to complete the module installation:


# TAR-ZXVF Php-5.3.13.tgz

# CD Php-5.3.13/ext/mysqli

#/usr/local/php/bin/phpize

#./configure--with-php-config=/usr/local/php/bin/php-config--with-mysqli=/usr/bin/mysql_config

# Make && make install


Configuration Process Error:

Checking for mysql_set_server_option in -lmysqlclient... noconfigure: error:  wrong mysql library version or lib not found. Check  config.log for more information.configure: failed program was:| /*  confdefs.h.  */| |  #define  PACKAGE_NAME  "|  #define  package_tarname   "|  #define  PACKAGE_VERSION " |  #define  PACKAGE_STRING  "|  #define  PACKAGE_BUGREPORT  "" | /* end confdefs.h.  */| | /* override  any gcc2 internal prototype to avoid an error.  */| # ifdef __cplusplus| extern  "C" |  #endif | /* we use char because  int might match the return type of a gcc2|     builtin and then iTs argument prototype would still apply.  */| char mysql_set_ server_option  ();| int| main  () | {| mysql_set_server_option  ();|    ;|   return 0;| }configure:3473: result: noconfigure:3801:  error: wrong mysql library version or lib not found. check  config.log for more information.

The MySQL library file was not found, stating that the MySQL environment variable is not set correctly or that the Mysql-devel library is not installed.

Yum-y install Mysql-devel or source code compilation installation Mysql-devel




3. Modify the PHP configuration file


Sed-i '/pdo_mysql.so/d '/usr/local/php/etc/php.ini

Sed-i '/^extension_dir/a extension = "pdo_mysql" '/usr/local/php/etc/php.ini


Sed-i '/mysqli.so/d '/usr/local/php/etc/php.ini

Sed-i '/^extension_dir/a extension = "mysqli" '/usr/local/php/etc/php.ini


4. Restart Apache or Nginx for the configuration to take effect:

/usr/local/apache/bin/apachectl-k Restart or/etc/init.d/httpd restart

/usr/local/nginx/sbin/nginx-s Reload or/etc/init.d/nginx restart



Note:

When compiling PHP, add this--with-mysqli=/usr/local/mysql/bin/mysql_config

The reported error is configure:error:wrong MySQL library version or Lib not found

At compile time directly write--wit-mysqli not add path, because PHP itself has this module, no need to add MySQL configuration file path.



This article from "Ops said: from rookie to veteran" blog, please be sure to keep this source http://liuqunying.blog.51cto.com/3984207/1570056

PHP Standalone compilation installation extension (Mysqli,pdo-mysql)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.