php连接mongodb
时间:2021-07-01 10:21:17
帮助过:2人阅读
wget ‘https://codeload.github.com/mongodb/mongo-php-driver/zip/master‘ -O /usr/local/src/mong_php.zipcd /usr/local/src/unzip mong_php.zipcd mongo-php-driver-master//usr/local/php/bin/phpize./configure --with-php-config=/usr/local/php/bin/php-configmakemake installvi /usr/local/php/etc/php.ini //增加 extension = mongo.so/usr/local/php/bin/php -m重启apache,重新加载php测试:vi /usr/local/apache2/htdocs/1.php //增加<?php// 连接到mongodb$m = new MongoClient();echo "Connection to database successfully";// 选择一个数据库$db = $m->mydb;echo "Database mydb selected";?>访问 curl localhost/1.php 如果输出Connection to database successfullyDatabase mydb selected说明正确。更多测试访问http://www.runoob.com/mongodb/mongodb-php.html
扩展: mongodb分片 http://www.lanceyan.com/tech/arch/mongodb_shard1.html
php连接mongodb
标签:local