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 |