mongodb php

2020-03-21 13:04 阅读 776 views 次 mongodb php已关闭评论

启动: bt 面板。 机器重启后续手动启动。

 

/www/server/php/72/bin/pecl install mongodb
如果失败:
[root@iZbp18kdbvbbeh71qqvazfZ tmp]# /www/server/php/72/bin/pecl install mongodb
No releases available for package "pecl.php.net/mongodb"
install failed
[root@iZbp18kdbvbbeh71qqvazfZ tmp]# wget https://pecl.php.net/get/mongodb-1.7.4.tgz
/www/server/php/72/bin/pecl install mongodb-1.7.4.tgz

php配置文件最后加:

extension=mongodb.so

 

composer config -g repo.packagist composer https://packagist.phpcomposer.com

https://www.runoob.com/mongodb/php7-mongdb-tutorial.html

php函数放行:

pcntl_signal  put_env  popen

 

最后提醒一下,在部署代码到生产环境的时候,别忘了优化一下自动加载:

composer dump-autoload --optimize

安装包的时候可以同样使用--optimize-autoloader。不加这一选项,你可能会发现20%到25%的性能损失

=============

看来不设置的话,默认会使用50% of (RAM - 1 GB)的内存。于是在配置文件设置了storage.wiredTiger.engineConfig.cacheSizeGB为0.5,也就是500M,再看测试结果:

vim /etc/mongod.conf

storage:
dbPath: /var/lib/mongodb
journal:
enabled: true
# engine:
# mmapv1:
wiredTiger:
engineConfig:
cacheSizeGB: 0.5

————————————————
版权声明:本文为CSDN博主「嫩草终结者」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qq_32523587/article/details/82219170

cmd:

mongo
use admin
db.createUser({user:"admin",pwd:"password",roles:["root"]})


require 'mongodb/vendor/autoload.php';
$begin = getMillisecond();
$collection = (new MongoDB\Client("mongodb://localhost:27017"))->test->users;
$insertManyResult = $collection->insertMany([
[
'_id' => 'fjj4j3jr94jH3',
'username' => 'admin',
'email' => 'admin@example.com',
'name' => 'Admin User',
],
[
'username' => 'test',
'email' => 'test@example.com',
'name' => 'Test User',
],
]);
printf("Inserted %d document(s)\n", $insertManyResult->getInsertedCount());
var_dump($insertManyResult->getInsertedIds());
$document = $collection->findOne(['_id' => 'fjj4j3jr94jH3']);
var_dump($document);
https://docs.mongodb.com/php-library/current/tutorial/crud/
版权声明:本文著作权归原作者所有,欢迎分享本文,谢谢支持!
转载请注明:mongodb php | 蚂蚁浏览器文档
分类:电脑技术 标签:

评论已关闭!