*安装PHP的monGo扩展wget 'https://codeload.GitHub.com/mongoDB/mongo-php-driver/zip/master' -O /usr/local/src/
wget 'https://codeload.GitHub.com/mongoDB/mongo-php-driver/zip/master' -O /usr/local/src/mong_php.zip
cd /usr/local/src/
unzip mong_php.zip
cd mongo-php-driver-master/
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install
vi /usr/local/php/etc/php.ini //增加 extension = mongo.so
/usr/local/php/bin/php –m
重启apache,重新加载php
lnmp则重启php-fpm
*测试mongo扩展
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
参考 Http://www.runoob.com/mongodb/mongodb-php.html
--结束END--
本文标题: 3.7-php连接MongoDB
本文链接: https://lsjlt.com/news/38722.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0