这里指php的mongodb驱动。
版本:
> cat /etc/os-release
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"
> php -v
PHP 7.1.14 (cli) (built: Feb 26 2018 13:55:05) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
> nginx -v
nginx version: nginx/1.12.2
> mongod --version
db version v3.6.3
git version: 9586e557d54ef70f9ca4b43c26892cd55257e1a5
OpenSSL version: OpenSSL 1.0.1e-fips 11 Feb 2013
allocator: tcmalloc
modules: none
build environment:
distmod: rhel70
distarch: x86_64
target_arch: x86_64
安装/配置过程:
--> 安装 php-fpm (ref: https://github.com/terrylinooo/daily/wiki/Install-Nginx,-PHP-7,-MariaDB-10-(LEMP)-on-CentOS-7)
yum install php71w-fpm
安装完毕后配置/etc/php-fpm.d/www.config:listen = /var/run/php-fpm/php-fpm.sock
listen.owner = nobody
listen.group = nobody
user = nginx
group = nginx
后面启动nginx时可能出错,执行: chown nginx:nginx /var/run/php-fpm/php-fpm.sock
--> 安装 mongodb driver for php (ref: http://blog.csdn.net/username11211/article/details/52945488)
> wget https://pecl.php.net/get/mongodb-1.4.1.tgz
> tar -xvzf mongodb-1.4.1.tgz
> cd mongodb-1.4.1
> phpize
> ./configure --with-php-config=/usr/bin/php-config
> make && make install
--> 配置php.inicgi.fix_pathinfo=0
在php.ini文件中添加extension=mongodb.so
--> 配置nginx.config
server段中添加:location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
--> 启动php-fpm
systemctl start php-fpm
systemctl enable php-fpm
--> 重启nginx
systemctl restart nginx