您好,登錄后才能下訂單哦!
系統(tǒng):centOS5.6
下載mongo源碼包,pcre,epel,js
1 #wget http://downloads.mongodb.org/src/mongodb-src-r1.8.1.tar.gz
#wget http://ftp.mozilla.org/pub/mozilla.org/js/js-1.7.0.tar.gz
#wget http://sourceforge.net/projects/pcre/files/pcre/8.12/pcre-8.12.tar.bz2
安裝 python :
#yum install -y python-devel
安裝scons: 下載scons
tar zxf scons-2
cd scons-2
python setup.py install
安裝spidermonkey庫,下載支持c的js api庫 點此下載js-
yum install -y boost boost-devel
tar zxvf js-
cd js/src/
export CFLAGS="-DJS_C_STRINGS_ARE_UTF8"
make -f Makefile.ref
JS_DIST=/usr gmake -f Makefile.ref export
cd ../..
安裝pcre
tar zxf pcre-8.12.tar.gz
cd pcre-8.12
./configure --enable-utf8 --enable-unicode-properties
make && make install
cd ..
安裝MongoDB
cd mongodb-src-r
scons all // scons可能出現(xiàn)找不到pcre庫的現(xiàn)象(修改/etc/ld.so.conf也無用,是scons自身的問題),這時需要打開mongodb-src-r
scons --prefix=/usr/local/mongo install
如果需要安裝lib和head,使用如下方式安裝
scons --prefix=/usr/local/mongo --full install
創(chuàng)建配置文件
mkdir -p /usr/local/mongo/etc /usr/local/mongo/data /usr/local/mongo/log/ /usr/local/mongo/repair
vim /usr/local/mongo/etc/mongo.conf
在mongo.conf中添加下面的內(nèi)容
dbpath = /usr/local/mongo/data
logpath = /usr/local/mongo/mongodb.log
repairpath = /usr/local/mongo/repair
pidfilepath = /usr/local/mongo/mongodb.pid
directoryperdb = true logappend = true noauth = true port = 27017 maxConns = 1024 fork = true rest = true quota = true quotaFiles = 1024 nssize = 16 啟動mongodb ln -s /usr/local/mongo/bin/mongod /usr/bin/mongod mongod -f /usr/local/mongo/etc/mongo.conf 看看是不是啟動起來了,但是使用這種方式管理mongodb服務(wù)器很不明智,我們完善一下: mkdir -p /usr/local/mongo/srv vim /usr/local/mongo/srv/mongodb-start 添加下面的內(nèi)容 #!/bin/sh mongod -f /usr/local/mongo/etc/mongo.conf vim /usr/local/mongo/srv/mongodb-stop 添加下面的內(nèi)容 #!/bin/bash pid=`ps -o pid,command ax | grep mongod | awk '!/awk/ && !/grep/ {print $1}'`; if [ "${pid}" != "" ]; then kill -2 ${pid}; fi 添加執(zhí)行權(quán)限 chmod a+x /usr/local/mongo/srv/mongodb-start chmod a+x /usr/local/mongo/srv/mongodb-stop vim /etc/rc.d/init.d/mongodb 添加下面的內(nèi)容 #! /bin/sh # # mongodb – this script starts and stops the mongodb daemon # # chkconfig: - 85 15 # description: MongoDB is a non-relational database storage system. # processname: mongodb # config: /usr/local/mongo/etc/mongo.conf # pidfile: /usr/local/mongo/mongodb.pid PATH=/usr/local/mongo/bin:/sbin:/bin:/usr/sbin:/usr/bin NAME=mongodb test -x $DAEMON || exit 0 set -e case "$1" in start) echo -n "Starting MongoDB... " /usr/local/mongo/srv/mongodb-start ;; stop) echo -n "Stopping MongoDB... " /usr/local/mongo/srv/mongodb-stop ;; *) N=/etc/init.d/$NAME echo "Usage: $N {start|stop}" >&2 exit 1 ;; esac exit 0 添加服務(wù) chmod a+x /etc/rc.d/init.d/mongodb chkconfig --add mongodb chkconfig --level 345 mongodb on /etc/rc.d/init.d/mongodb start php mongo 擴展安裝: 服務(wù)器環(huán)境Cent OS 5.6 64位, php版本 5.2.17編譯安裝,安裝路徑/usr/local/php 首先下載最新的php mongodb擴展源碼,源碼可以在http://pecl.php.net/package/mongo下載到 wget http://pecl.php.net/get/mongo-1.2.2.tgz tar zxf mongo-1.2.2.tgz cd mongo-1.2.2 進(jìn)入文件夾后,首先運行phpize來準(zhǔn)備編譯擴展的環(huán)境,phpize這個程序的介紹在這里 /usr/local/php/bin/phpize 運行后執(zhí)行結(jié)果如下:
Configuring for:
PHP Api Version: 20041225
Zend Module Api No: 20060613
Zend Extension Api No: 220060519
運行后,./configure 腳本就會生成了,這個時候我們運行./configure腳本來進(jìn)行配置
./configure --with-php-config=/usr/local/php/bin/php-config
--with-php-config這個參數(shù)是告訴配置腳本php-config這個程序的路徑,php-config的介紹在這里
上面命令在正確配置的環(huán)境下運行結(jié)果如下
creating libtool
appending configuration tag "CXX" to libtool
configure: creating ./config.status
config.status: creating config.h
這時用make來編譯擴展
make && make install
正確編譯執(zhí)行結(jié)果如下:
Build complete.
Don't forget to run 'make test'.
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/
完成后,請編輯你php.ini文件增加一行
extension=mongo.so
一般默認(rèn)的編譯php的ini文件在
/usr/local/php/etc/php.ini
重啟你的web服務(wù)器或者php-fpm,打印phpinfo,如果看到mongo項表,那么mongodb的擴展安裝成功了
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。