search
Homephp教程PHP源码Centos6.x installs Mongodb and Mongodb php extension

跳至 [1] [全屏预览]
#mongodb 安装到/usr/local 目录
cd /usr/local
#获取并下载最新稳定版本 https://www.mongodb.com/download-center?jmp=nav
#百度云盘 http://pan.baidu.com/s/1i47YB0T
wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.2.8.tgz
tar zxvf mongodb-linux-x86_64-3.2.8.tgz
mv mongodb-linux-x86_64-3.2.8 mongodb
cd mongodb
mkdir db
mkdir logs
cd bin

#新建配置文件
vi mongodb.conf
#复制下面的配置文件
dbpath=/usr/local/mongodb/db
logpath=/usr/local/mongodb/logs/mongodb.log
pidfilepath=/usr/local/mongodb/mongo.pid
fork=true
logappend=true
shardsvr=true
auth=true
port=27017
nohttpinterface=true
#结束

#重新绑定mongodb的配置文件地址和访问IP
/usr/local/mongodb/bin/mongod --bind_ip localhost -f /usr/local/mongodb/bin/mongodb.conf

#添加服务mongodb
/usr/local/mongodb/bin/mongod
show dbs #列出所有数据库
use admin #切换到admin数据库,添加的账号才是管理员账号。
show collections
db.system.users.find()
db.createUser({user:"root",pwd:"123456",roles:[{role:"root",db:"admin"}]}) #添加管理员账号:root 密码:123456 权限:有数据库admin的所有操作权限
db.auth('root','123456') #添加管理员用户认证,认证之后才能管理所有数据库
exit #退出

vi /etc/rc.d/init.d/mongod #设置开机启动MongoDB
#!/bin/sh
# chkconfig: - 64 36
# description:mongod
case $1 in
	start)
		/usr/local/mongodb/bin/mongod --maxConns 20000 --config /usr/local/mongodb/bin/mongodb.conf
		
;;
	stop)
		/usr/local/mongodb/bin/mongo localhost:27017/admin --eval "db.auth('root', '123456');db.shutdownServer()"
;;
	status)
		/usr/local/mongodb/bin/mongo localhost:27017/admin --eval "db.auth('root', '123456');db.stats()"
;;
esac

chmod +x /etc/rc.d/init.d/mongod #添加脚本执行权限
chkconfig mongod on #设置开机启动
service mongod stop #关闭MongoDB
service mongod start #启动MongoDB


#重启一下系统测试下能不能自启

#进入mongodb的shell模式 
/usr/local/mongodb/bin/mongo
#查看数据库列表 
show dbs
#当前db版本 
db.version();

#安装mongodb完成。

#开始安装 mongodb php扩展
#获取最新扩展插件 https://pecl.php.net/package/mongodb

#下载最新版本
cd /www/wdlinux/php
wget https://pecl.php.net/get/mongodb-1.1.8.tgz

#解压
tar zxvf mongodb-1.1.8.tgz
cd ./mongodb-1.1.8
/www/wdlinux/php/bin/phpize

#编译
make

#安装
make install 

#修改php.ini
[mongodb]
extension=mongodb.so

#完成 访问 phpinfo.php 
<?php
    phpinfo();
?>

2. [图片] mmm.png    

Centos6.x installs Mongodb and Mongodb php extension
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.