CentOS6.3 install MongoDB2.2 and install PHP MongoDB client

Source: Internet
Author: User
Tags create mongodb install php install mongodb mkdir mongodb mongodb client php mongodb

Download Source: (Put in the/USR/LOCAL/SRC directory)
To the official website http://www.mongodb.org/downloads Download source code
HTTPS://FASTDL.MONGODB.ORG/LINUX/MONGODB-LINUX-X86_64-2.2.7.TGZ (64-bit)
Https://fastdl.mongodb.org/linux/mongodb-linux-i686-2.2.7.tgz (32-bit)
Note: 32-bit system installation 32-bit, 64-bit system installed 64-bit!


Install MongoDB

The code is as follows Copy Code

#创建mongodb安装目录
Mkdir-pv/usr/local/mongodb
Mkdir-pv/usr/local/mongodb/data
mkdir-pv/usr/local/mongodb/logs
mv./bi N/usr/local/mongodb
 
#将解压包内的bin文件夹移动到安装目录

cd/usr/local/src/
TAR-XZVF./ Mongodb-linux-i686-2.2.7.tgz
CD./mongodb-linux-i686-2.2.7
mv./bin/usr/local/mongodb
 
# Create MongoDB user and MongoDB user group

Groupadd MongoDB
useradd-g mongodb-s/usr/sbin/nologin mongodb
Chown-r mongodb:m Ongodb/usr/local/mongodb
 
#设置开机启动

Echo/usr/local/mongodb/bin/mongod--dbpath=/usr/local/ Mongodb/data--logpath=/usr/local/mongodb/logs/mongodb.log--fork ">>/etc/rc.local
 
#启动mongodb

/usr/local/mongodb/bin/mongod--dbpath=/usr/local/mongodb/data--logpath/usr/local/mongodb/logs/ Mongodb.log--fork


#将27017端口加入防火墙 (Reference: CentOS6.3 compile installation memcached)
Note: The database port and the Web port, 27017 and 28017 respectively, open http://localhost:28017 in the browser, and you can see some relevant information.

The code is as follows Copy Code
Service iptables restart//reboot firewall



Problems that may arise:

Question one:
-bash:/usr/local/bin/mongo:/lib/ld-linux.so.2:bad ELF interpreter: Without that file or directory
Solution:

The code is as follows Copy Code
Yum Install ld-linux.so.2

Question two:
mongo:error while loading shared libraries:libstdc++.so.6:cannot open Shared object File:no such file or director Y

Solution:

The code is as follows Copy Code

Yum Whatprovides libstdc++.so.6

Yum Install llibstdc++.so.6



Install the PHP MongoDB client

The code is as follows Copy Code

Cd/usr/local/src
Wget-c http://pecl.php.net/get/mongo-1.4.4.tgz
TAR-XZVF./mongo-1.4.4.tgz
CD./mongo-1.4.4
/usr/local/php/bin/phpize # Use PHP's phpize command to install extensions
./configure--with-php-config=/usr/local/php/bin/php-config
Make && make install

When you are finished, edit your php.ini file to add one line.

  code is as follows copy code
extension= mongo.so
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.