Hướng dẫn pecl php

Tôi đã gặp phải sự cố tương tự này khi cập nhật hộp Vagrant của mình với XHGui , vì XHGui yêu cầu mongodb. Tôi muốn có thể hỗ trợ lập hồ sơ trên cả PHP 5.6 và 7.0.

Tôi đã đào sâu vào mã nguồn pecl và thấy rằng có một metadata_dirtùy chọn cấu hình. Đó là một đường dẫn đến một thư mục chứa trạng thái hiện tại của các gói đã cài đặt. Thật không may, điều đó chưa được đặt tên cho mỗi phiên bản PHP. Nếu bạn thử và đặt nó bằng pecl config-set, bạn sẽ gặp lỗi 'không thành công' mờ đục. Nó chỉ ra rằng cài đặt không được liệt kê trong danh sách trắng vì có thể định cấu hình trong \PEAR_Configlớp:

/**
 * Configuration values that can be set for a channel
 *
 * All other configuration values can only have a global value
 * @var array
 * @access private
 */
var $_channelConfigInfo = array(
    'php_dir', 'ext_dir', 'doc_dir', 'bin_dir', 'data_dir', 'cfg_dir',
    'test_dir', 'www_dir', 'php_bin', 'php_prefix', 'php_suffix', 'username',
    'password', 'verbose', 'preferred_state', 'umask', 'preferred_mirror', 'php_ini'
    );

Trong thế giới của PECL, 'toàn cầu' có nghĩa là nó chỉ có thể được đặt tại thời điểm cài đặt chứ không phải sau đó.

Đã xảy ra sự cố trong trình theo dõi PPA tại github: https://github.com/oerdnj/deb.sury.org/issues/407

Đề xuất cuối cùng là xây dựng tiện ích mở rộng theo cách thủ công cho các phiên bản PHP thay thế. Tôi đã kết thúc bằng cách sử dụng pecl cho các phần mở rộng PHP 7 và các bản dựng thủ công cho phiên bản 5.6. Đảm bảo rằng bạn chạy update-alternativesphp-config và phpize chứ không chỉ php trước khi xây dựng:

update-alternatives --set php /usr/bin/php5.6
update-alternatives --set php-config /usr/bin/php-config5.6
update-alternatives --set phpize /usr/bin/phpize5.6

Sau đó, giải nén phần mở rộng và xây dựng nó. Các bước sau từ vấn đề trên đã hiệu quả với tôi với tiện ích mở rộng mongodb:

phpize5.6 && ./configure --with-php-config=php-config5.6 && make && sudo make install

7 hữu ích 1 bình luận chia sẻ

Tôi đang cố gắng cài đặt php_httptiện ích mở rộng PHP trên máy chủ CentOS của mình.

Tôi đã làm:

yum install php-pear

Nhưng nhận được:

No package php-pear available

Tuy nhiên, tôi có thể làm:

pear

Và nhận danh sách các lệnh từ Pear.

Tương tự cho yum install pecl. Tôi có thể làm peclnhưng pecl install pecl_httptrả lại:

No releases available for package "pecl.php.net/pecl_http"
install failed

Tuy nhiên, /usr/bin/peclkhông phải là một thư mục tồn tại. Cũng là một sudo pecl install pecl_httplợi nhuận sudo: pecl: command not found, mà tôi thấy khá kỳ quặc.

Tôi không hoàn toàn chắc chắn chuyện gì đang xảy ra ở đây / tôi đang làm gì sai.

chỉnh sửa: Tôi đang sử dụng các đại diện sau:

base                         CentOS-6 - Base
epel                         Extra Packages for Enterprise Linux 6 - x86_64
extras                       CentOS-6 - Extras
rpmforge                     RHEL 6 - RPMforge.net - dag
updates                      CentOS-6 - Updates
vz-base                      vz-base
vz-updates                   vz-updates                                                            

19 hữu ích 5 bình luận 90k xem chia sẻ

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 http://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 mongovà 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:

  1. Hệ điều hành: Linux Mint 16, dựa trên Ubuntu.

  2. 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: » https://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.