一,安装mongodb,php扩展
[root@localhost ~]# yum install php-pecl-mongo mongodb mongodb-devel mongodb-serverphp扩展,mongodb服务端,mongodb客户就装好了。
二,配置/etc/mongodb.conf
[root@localhost www]# cat /etc/mongodb.conf |awk '{if($0 !~ /^$/ && $0 !~ /^#/) {print $0}}' logpath=/var/log/mongodb/mongodb.log //日志位置 fork = true //后台运行 logappend=true //追加日志 port = 27017 //端口 dbpath=/var/lib/mongodb //数据库路径 pidfilepath=/var/run/mongodb/mongodb.pid //pid路径上面基本都配置,但是yum安装的时候为什么没有创建/var/lib/mongodb这个文件夹呢
[root@localhost lib]# mkdir -p /var/lib/mongodb [root@localhost lib]# chown mongodb:mongodb -R /var/lib/mongodb/三,启动mongodb服务端,并查看
[root@localhost www]# /etc/init.d/mongod start //启动 //查看 [root@localhost www]# netstat -tpnl|grep 27017 tcp 0 0 0.0.0.0:27017 0.0.0.0:* LISTEN 4641/mongod这样mongodb就能正常动作了。
看一下php扩展是不是装好了,
mongodb php扩展
四,测试php mongodb扩展