安装 MongoDB

https://www.mongodb.com/try/download/community

如果是Yum安装,可以Package选项选server,然后拷贝链接后使用yum直接安装,如

yum install https://repo.mongodb.org/yum/redhat/7/mongodb-org/4.4/x86_64/RPMS/mongodb-org-server-4.4.2-1.el7.x86_64.rpm

systemctl start mongod #启动
systemctl enable mongod #自动启动
systemctl daemon-reload #保存系统启动配置文件
systemctl is-enabled mongod #查看配置是否生效

 

安装MongoDB shell

下载:https://www.mongodb.com/try/download/shell

yum install https://downloads.mongodb.com/compass/mongodb-mongosh-1.0.1.el7.x86_64.rpm

 

安装php-MongoDB扩展

可以用pecl安装php的mongo扩展
pecl install mongodb #如果php版本<7,需要安装的是mongo,pecl install mongo

#pecl uninstall mongodb #需要卸载可以执行

安装完成后会显示,说明安装成功了

Build process completed successfully
Installing '/usr/lib64/php/modules/mongodb.so'
install ok: channel://pecl.php.net/mongodb-1.8.2
configuration option "php_ini" is not set to php.ini location
You should add "extension=mongodb.so" to php.ini

修改php配置
vi /etc/php.ini 添加 extension=mongodb.so


重启php
systemctl restart php-fpm

 

查看PHP是否已经挂载redis模块

php -m|grep mongodb

 

posted on 2023-03-28 09:20  lbnnbs  阅读(68)  评论(0编辑  收藏  举报