Làm cách nào để cài đặt trình điều khiển máy khách MongoDB của PHP?
Tôi đã làm điều này rồi:
$ sudo aptitude install php5-dev php5-cli php-pear make
Nhưng bước tiếp theo không thành công:
$ sudo pecl install mongo
No releases available for package "pecl.php.net/mongo"
install failed
Khi tôi xem tại //pecl.php.net/mongo , tôi thấy có nhiều phiên bản của trình điều khiển Mongo được liệt kê. Tôi có phải bao gồm số phiên bản hay thứ gì đó không? Tuy nhiên, tất cả các hướng dẫn cài đặt tôi đã tìm thấy chỉ nói rằng một cách sử dụng sudo pecl install mongo
và không có gì khác. - Làm cách nào để cài đặt trình điều
khiển Mongo?
Một số chi tiết:
Hệ điều hành: Linux Mint 16, dựa trên Ubuntu.
pecl list-channels
nói:Registered Channels: Channel Alias Summary doc.php.net phpdocs PHP Documentation Team pear.php.net pear PHP Extension and Application Repository pecl.php.net pecl PHP Extension Community Library __uri __uri Pseudo-channel for static packages
- php
- mongodb
- ubuntu
8 hữu ích 1 bình luận 15k xem chia sẻ
answer
2
Tôi không biết bạn bị khóa vào phương thức pecl như thế nào, nhưng gần đây tôi đã biên dịch trình điều khiển . Đây là trên máy chủ ubuntu. Nó cài đặt .so và tất cả những gì bạn phải làm chỉ là thêm "extension = mongo.so" vào các tệp php.ini.
2 hữu ích 2 bình luận chia sẻ
answer
0
Tôi đã gặp sự cố tương tự khi cố gắng tạo vùng chứa Docker đang hoạt động cho ứng dụng Laravel. Những điều sau đây đã làm việc cho tôi:
sudo pecl install mongodb
Tôi thấy điều này được tham chiếu trong các bình luận tài liệu PHP .
0 hữu ích 0 bình luận chia sẻ
answer
0
sudo apt-get install php-mongodb
Tất nhiên, giả sử rằng bạn đã cài đặt php, v.v. thông qua apt-get [hoặc synapic, v.v.]
0 hữu ích 0 bình luận chia sẻ
answer
0
Trong Ubuntu 20.04, php-mongodb đã lỗi thời và bạn sẽ cần phương pháp PECL để cài đặt phiên bản MongoDB mới nhất.
Đầu tiên, hãy cài đặt plugin php-lê và php-dev
sudo apt install php-dev php-pear
Sau đó
sudo pecl install mongodb
0 hữu ích 0 bình luận chia sẻ
Đăng nhập để trả lời câu hỏi
Có thể bạn quan tâm
Information for installing this PECL extension may be found in the manual chapter titled Installation of PECL extensions. Additional information such as new releases, downloads, source files, maintainer information, and a CHANGELOG, can be located here: » //pecl.php.net/package/mongodb
Linux, Unix, and macOS users may run the following command to install the driver:
$ sudo pecl install mongodb
If your system has multiple version of PHP installed [e.g. macOS default, Homebrew, » XAMPP], note that each version of PHP has its own pecl command and php.ini file[s]. Additionally, each PHP environments [e.g. CLI, web] may use separate php.ini files.
Installing the driver via PECL will use bundled versions of » libbson and » libmongoc and attempt to automatically configure them.
Note: If the build process fails to find an SSL library, check that the development packages [e.g.
libssl-dev
] and » pkg-config are both installed. If that does not resolve the problem, consider using the manual installation process.
Finally, add the following line to the php.ini file for each environment in which you intend to use the driver:
mohammadhoseinmazalahi at gmail dot com ¶
2 years ago
As of Ubuntu 20.04, php-mongodb in the database is outdated and you'll need the PECL method to install latest version of MongoDB.
To do this in Ubuntu, you'll need the php-pear plugin and php-dev:
sudo apt install php-dev php-pear
then you can run:
sudo pecl install mongodb
contact ? automatix : info ¶
6 years ago
An additional requirement might be pkg-config [on Ubuntu 14.04].
$ pecl install mongodb
...
configure: error: Cannot find OpenSSL's libraries
ERROR: `/tmp/pear/temp/mongodb/configure --with-php-config=/usr/bin/php-config' failed
But:
$ apt-get install pkg-config
...
Setting up pkg-config [0.26-1ubuntu4] ...
$ pecl install mongodb
...
Build process completed successfully
Installing '/usr/lib/php/20151012/mongodb.so'
install ok: channel://pecl.php.net/mongodb-1.1.7
configuration option "php_ini" is not set to php.ini location
You should add "extension=mongodb.so" to php.ini
rafael_xuvisco at yahoo dot com dot br ¶
5 years ago
Ubuntu 16.04
sudo apt-get install libcurl4-openssl-dev pkg-config libssl-dev libsslcommon2-dev
sudo pecl install mongodb
add extension=mongodb.so in fpm and cli:
sudo vim /etc/php/7.0/fpm/conf.d/30-mongodb.ini
sudo vim /etc/php/7.0/cli/conf.d/30-mongodb.ini
Restart service:
sudo systemctl restart php7.0-fpm
sudo systemctl reload nginx
asologor at gmail dot com ¶
5 years ago
On Ubuntu you can just do:
sudo apt-get install php-mongodb
or the same for specific PHP version:
sudo apt-get install php5.6-mongo
or
sudo apt-get install php7.0-mongodb
Anonymous ¶
5 years ago
I got an error "fatal error: pcre.h: No such file or directory" and had to also had to install another dependency
sudo apt-get install libpcre3-dev
Tim Greiser ¶
6 years ago
[Editor's note: fixed typo]
There are some additional requirements you need to build the pecl package.
sudo apt-get install libcurl4-openssl-dev pkg-config libssl-dev libsslcommon2-dev
Unmesh ¶
5 years ago
The following steps worked for me on Centos7
sudo yum install -y openssl-devel
sudo yum install pecl
sudo yum install gcc
sudo pecl install mongodb
maneesh dot singh at hof-university dot com ¶
5 years ago
Hi,
I am looking into installation of php mongo db driver.
I have checked with phpinfo it shows mongodb module have been loaded but when I use in my code it give error "Fatal error: Uncaught Error: Class 'MongoDB' not found "
i have another module for redis and it works perfectly . Initially I was getting same error but phpinfo was showing module is not loaded .
I guess there is some problem with driver. I have tried all the documents and website links which mention to include extenstion=mongodb.so which i have already done.
I am using open suse 42.2 leap with apache server.
Could you please investigate this issue.
If you need more info please let me know.
Thanks
Maneeshg
ovidius at email dot it ¶
5 years ago
after installed and added extension=mongodb to php.ini, when i run php -v i get this error:
bus error php -v
what could it be? the build process completed successfully.