Linux与Solaris下安装MongoDB与mongo扩展


centos安装说明(源码安装):

进入MongoDB下载中心:http://www.mongodb.org/downloads
We recommend using these binary distributions (官方推荐使用二进制版本!)
根据自己的实际系统环境,下载所要的文件,我的是Linux 64-bit.
wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.2.3.tgz
然后解压:
tar zxvf mongodb-linux-x86_64-2.2.3.tgz
移动目录到/usr/local/mongodb
mv mongodb-linux-x86_64-2.2.3 /usr/local/mongodb
进入mongodb目录
cd /usr/local/mongodb
新建自定义数据目录
mkdir -p ./data/db/
新建日志目录
mkdir log
以后台运行方式启动mongodb
/usr/local/mongodb/bin/mongod --dbpath=/usr/local/mongodb/data/db --logpath=/usr/local/mongodb/log/mongodb.log --fork

设置开机自启动:
echo "/usr/local/mongodb/bin/mongod --dbpath=/usr/local/mongodb/data/db --logpath=/usr/local/mongodb/log/mongodb.log --fork" >> /etc/rc.local
查看MongoDB日志
tail -f /usr/local/mongodb/log/mongodb.log
即可对MongoDB的运行情况进行查看或排错了
或者写入配置文件方式:
mkdir etc
vi mongod.conf
dbpath=/usr/local/mongodb/data
logpath=/usr/local/mongodb/log/mongod.log

directoryperdb=true
logappend=true
fork=true
auth = true
#maxConns = 10000

#启动
/usr/local/mongodb/bin/mongod -f /usr/local/mongodb/etc/mongod.conf
最后增加到path变量
vi /etc/profile
PATH=/usr/local/mongodb/bin:$PATH

ubuntu安装说明:

自带的apt-get install mongodb安装的mongodb启动时候会提示
*** warning: spider monkey build without utf8 support.  consider rebuilding with utf8 support     
解决方法:
rm -rf  /etc/mongodb.conf
apt-get remove mongodb-clients 
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' |tee /etc/apt/sources.list.d/mongodb.list
apt-get update
apt-get install -y mongodb-org
#安装其它版本
apt-get install -y mongodb-org=2.6.1 mongodb-org-server=2.6.1 mongodb-org-shell=2.6.1 mongodb-org-mongos=2.6.1 mongodb-org-tools=2.6.1

Solaris安装说明:

assuming a 64 bit accelerator
/usr/bin/isainfo -kv

# get mongodb# note this is 'latest' you may want a different version
curl -O http://downloads.mongodb.org/sunos5/mongodb-sunos5-x86_64-latest.tgz
gzip -d mongodb-sunos5-x86_64-latest.tgz
tar -xf mongodb-sunos5-x86_64-latest.tar
mv
"mongodb-sunos5-x86_64-2009-10-26" mongo

cd mongo

# get extra libraries we need (else you will get a libstdc++.so.6 dependency issue)
curl -O http://downloads.mongodb.org.s3.amazonaws.com/sunos5/mongo-extra-64.tgz
gzip -d mongo-extra-64.tgz
tar -xf mongo-extra-64.tar
# just as an example - you will really probably want to put these somewhere better:exportLD_LIBRARY_PATH=mongo-extra-64
bin/mongod --help
来源: <http://docs.mongodb.org/ecosystem/tutorial/joyent-cloud/>
 _________________________________________________
solaris下安装安装需要先运行:
export LD_LIBRARY_PATH=mongo-extra-64 (有异常使用,正常情况先不运行)
solaris下启动:
unset LANG;/usr/local/mongo/bin/mongod --logpath /var/log/mongod.log --auth --fork
solaris下编译php的扩展 mongo.so
编译之后的mongo.so 用ldd  mongo.so查看
libgcc_s.so.1 =>         /opt/local/lib/libgcc_s.so.1
64位的话需要指向
/usr/local/mongo/mongo-extra-64/libgcc_s.so.1
默认是指向的32位的libgcc_s.so.1
CFLAGS=-m64 CPPFLAGS=-m64 CCASFLAGS=-m64 ./configure
这样编译就指向64位的libgcc_s.so.1

ubuntu下安装Mongo的php扩展

sudo apt-get install php5-dev php5-cli php-pear 

sudo pecl install mongo 

cd /etc/php5/conf.d/ 

sudo gedit mongo.ini 

复制这段语句到新打开的文件中:extension=mongo.so 

重启apache sudo /etc/init.d/apache2 restart