在 centos 下编译安装 php 时,有时候经常会忘了某些扩展,比如 pdo,mysqli,但是到扩展目录下,我们又找不到相应的 扩展文件,(.so 文件) ,这样的情况下只能 编译安装该模块,生成对应的 so 文件,然后在 php.ini 中添加相应的 扩展记录,重启 php
安装mongo拓展:
- $ tar zxvf mongodb-mongodb-php-driver-<commit_id>.tar.gz
- $ cd mongodb-mongodb-php-driver-<commit_id>
- $ /usr/local/php/bin/phpize
- $ ./configure –with-php-config=/usr/local/php/bin/php-config
- $ sudo make install
就可以了,我们以安装 mysqli 为例。
首先进入 php 源码包 如果 找不到可以可下载一个 地址在这里:
完成后,请编辑你php.ini文件增加一行
extension=mongo.so
一般默认的编译php的ini文件在
/usr/local/php/etc/php.ini
重启你的web服务器或者php-fpm,打印phpinfo,如果看到mongo项表,那么mongodb的扩展安装成功了
其他命令:
- 查看所有模块
- [root@baseservice01 etc]# /usr/local/php/bin/php -m | grep -i mongo —mongo已安装成功
mongo - 查看所有信息
- [root@baseservice01 etc]# /usr/local/php/bin/php -i
- [root@baseservice01 etc]# /usr/local/php/bin/php -i|grep -i conf
Configure Command => ‘./configure’ ‘–prefix=/usr/local/php’ ‘–enable-fpm’ ‘–with-fpm-user=www’ ‘–with-fpm-group=www’ ‘–with-mysql=mysqlnd’ ‘–with-mysqli=mysqlnd’ ‘–with-pdo-mysql=mysqlnd’ ‘–with-iconv-dir’ ‘–with-freetype-dir’ ‘–with-jpeg-dir’ ‘–with-png-dir’ ‘–with-zlib’ ‘–with-libxml-dir=/usr’ ‘–enable-xml’ ‘–disable-rpath’ ‘–enable-magic-quotes’ ‘–enable-safe-mode’ ‘–enable-bcmath’ ‘–enable-shmop’ ‘–enable-sysvsem’ ‘–enable-inline-optimization’ ‘–with-curl’ ‘–with-curlwrappers’ ‘–enable-mbregex’ ‘–enable-mbstring’ ‘–with-mcrypt’ ‘–enable-ftp’ ‘–with-gd’ ‘–enable-gd-native-ttf’ ‘–with-openssl=/usr/local/openssl’ ‘–with-mhash’ ‘–enable-pcntl’ ‘–enable-sockets’ ‘–with-xmlrpc’ ‘–enable-zip’ ‘–enable-soap’ ‘–without-pear’ ‘–with-gettext’ ‘–enable-fileinfo’
Configuration File (php.ini) Path => /usr/local/php/lib –配置文件路径
Loaded Configuration File => /usr/local/php/lib/php.ini –使用的配置文件
Configuration
Openssl default config => /usr/local/openssl/ssl/openssl.cnf