pdo扩展模是有蛮多了,如pdo_mysql也是pdo模块中的一个了,下文我们就以安装pdo_mysql为示例帮助大家介绍一下安装步骤吧,其它的pdo扩展模块安装步骤也可以一样。
假设php目录为/usr/local/php
mysql目录为/usr/local/mysql
1. 进入PHP源码包ext/pdo目录
cd ext/pdo
2. 执行/usr/local/php/bin/phpize[假设PHP的安装目录为/usr/local/php]
/usr/local/php/bin/phpize
3. 配置扩展pdo
./configure --with-php-config=/usr/local/php/bin/php-config --enable-pdo=shared
4. 编译 &&安装pdo
make &&make install
成功则出现
Installing shared extensions: /usr/local/php//lib/php/extensions/no-debug-non-zts-20060613/
Installing header files: /usr/local/php//include/php/
Installing PDO headers: /usr/local/php//include/php/ext/pdo/
说明在/usr/local/php//lib/php/extensions/no-debug-non-zts-20060613/目录下生成了pdo.so文件
5. 在PHP源码包中进入pdo_mysql
cd ext/pdo_mysql
6. /usr/local/php/bin/phpize
/usr/local/php/bin/phpize
7. 配置pdo_mysql[假设Mysql的安装目录为/usr/local/mysql]
1./configure --with-php-config=/usr/local/php/bin/php-config --with-pdo-mysql=/usr/local/mysql
linux下编译安装并开启pdo_mysql扩展的具体步骤:1、进入php源码包里扩展目录
[root@nginx ~]# cd ./php-5.6.7/ext/pdo_mysql/
2、用phpize生成配置文件
[root@nginx pcntl]# phpize
[root@nginx pcntl]# ./configure
3、make &&make install安装
[root@nginx no-debug-non-zts-20131226]# ls
bcmath.so gd.so opcache.a pcntl.so
calendar.so mcrypt.so opcache.so pdo_mysql.so
curl.so memcache.so openssl.so posix.so
4、php.ini配置加载pdo_mysql.so扩展
extension=/usr/local/lib/php/extensions/no-debug-non-zts-20131226/pdo_mysql.so
5、重启php-fpm,浏览器查看phpinfo.
参考:PHP程序员,雷雪松的个人博客--http://www.leixuesong.cn
一、php5编译参数如下:./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-config-file-path=/usr/local/php/etc --with-iconv-dir=/usr/ --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr/local/libxml2 --enable-xml --disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-sockets --with-xmlrpc --enable-zip --enable-soap --enable-exif --enable-calendar --enable-magic-quotes --enable-wddx --enable-dba --with-qdbm &&make &&make install
二、用phpize来加载pdo_mysql,
wget http://pecl.php.net/get/PDO_MYSQL-1.0.2.tgz
tar xzvf PDO_MYSQL-1.0.2.tgz
cd PDO_MYSQL-1.0.2
/usr/local/php/bin/phpize
Configuring for:
PHP Api Version: 20041225
Zend Module Api No: 20060613
Zend Extension Api No: 220060519
./configure –with-php-config=/usr/local/php/bin/php-config
make
make install
三、编辑/usr/local/etc/php.ini文件,添加一句extension=pdo.so,重启apache后生效。
四、验证php,输入php – m命令,里面有pdo_mysq.so
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)