我已經在我的服務器上安裝了 MongoDB,我正在嘗試運行這個腳本:<?php$client = new MongoClient();$collection = $client->cryptnote->storedMessages;function insertDocument($collection, $id, $telegramuser, $message) { $doc = array( "id" => $id, "telegram" => $telegramuser, "encrypted" => $message, ); try { $collection->insert($doc); } catch(Exception $e) { echo "Error" . $e; }}function findDocument($collection, $id){ return $collection->findOne(["id" => $id]);}insertDocument($collection, "test123", "usertest", "message. test.");$query = findDocument($collection, "test123");echo "<pre>";var_dump($query);這是我得到的錯誤: Got error 'PHP message: PHP Fatal error: Uncaught Error: Class 'MongoClient' not found in /var/www/html/dbtest.php:5我的 Apache 服務器使用/etc/php/7.3/fpm/php.ini根據phpinfo();.添加extension=mongodb.so到php.ini文件是沒有用的。
1 回答

倚天杖
TA貢獻1828條經驗 獲得超3個贊
解決方案是重新啟動php-fpm
。
在我的例子中,我安裝了 PHP 7.3 版,所以我需要運行這個命令: sudo service php7.3-fpm restart
- 1 回答
- 0 關注
- 153 瀏覽
添加回答
舉報
0/150
提交
取消