php追加编译scws、mysqli和mongo、pgsql扩展模块

一、scws编译安装

wget http://www.ftphp.com/scws/down/scws-1.2.0.tar.bz2

tar jxf scws-1.2.0.tar.bz2
cd scws-1.2.0
./configure --prefix=/opt/scws
make && make install
cd phpext/
/opt/php-5.3.8/bin/phpize
./configure --with-scws=/opt/scws --with-php-config=/opt/php-5.3.8/bin/php-config
make && make install
vim /opt/php-5.3.8/etc/php.ini
 extension = "scws.so"
/etc/init.d/php-fpm restart


二、mongo编译安装

下载http://webscripts.softpedia.com/scriptDownload/MongoDB-PHP-Driver-Download-70187.html

tar zxf mongo-php-driver-1.3.7.tar.gz

cd mongo-php-driver-1.3.7

/opt/php/bin/phpize

./configure --with-php-config=/opt/php/bin/php-config

make && make install

vim /opt/php/etc/php.ini

 extension = "mongo.so"

/etc/init.d/php-fpm restart

测试mongo是否连通:

  1. <?php    

  2. $m = new Mongo('mongodb://lxx:[email protected]:27017');  

  3. //mongodb://username:password@IP:port

  4. $a = $m->connect();  

  5. if($a){  

  6. echo"success";  

  7. }  

  8. else{  

  9. echo"wrong";  

  10. }  

  11. ?>  

三、mysqli安装

进入php源码包php-5.3.8/ext/mysqli/

/opt/php/bin/phpize

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

make && make install

在php.ini中添加extension = "mysqli.so",重启php-fpm

但报错:PHP Warning:  PHP Startup: Invalid library (maybe not a PHP library) 'mysqli.so' in Unknown on line 0  

原来我服务器上的php是5.2.4版本,而我用高版本的5.3.4的php源码去追加编译,导致不兼容。重新下载5.2.4的php重复上面安装过程即可。

四、pgsql

1、进入php编译目录下的 ext/pgsql/ 下;
2、根据php安装位置 执行 /usr/local/php/bin/phpize;

yum install postgresql-devel

3、./configure --with-php-config=/usr/local/php/bin/php-config
4、make && make install

5、将编译完的扩展添加到 php.ini 最后 重启php-fpm

你可能感兴趣的:(PHP,mongo,scws)