我已经在 Ubuntu 16.04 LTS 服务器上安装了 LAMPP,并且安装了 Mongo DB。现在,我正在尝试将 MongoDB 驱动程序安装到 PHP。
sudo /opt/lampp/bin/pecl install mongo
它向我抛出了以下显示错误
WARNING: "pecl/mongo" is deprecated in favor of "channel:///mongodb" downloading mongo-1.6.14.tgz ...
Starting to download mongo-1.6.14.tgz (210,095 bytes)
.............................................done: 210,095 bytes
118 source files, building
running: phpize
Configuring for:
PHP Api Version: 20131106
Zend Module Api No: 20131226
Zend Extension Api No: 220131226
Build with Cyrus SASL (MongoDB Enterprise Authentication) support? [no]:
building in /tmp/pear/temp/pear-build-rootL9IHAe/mongo-1.6.14
running: /tmp/pear/temp/mongo/configure --with-php-config=/opt/lampp
/bin/php-config --with-mongo-sasl=no
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
checking for cc... cc
checking whether the C compiler works... no
configure: error: in `/tmp/pear/temp/pear-build-rootL9IHAe/mongo-1.6.14':
configure: error: C compiler cannot create executables
See `config.log' for more details
ERROR: `/tmp/pear/temp/mongo/configure --with-php-config=/opt/lampp
/bin/php-config --with-mongo-sasl=no' failed
但同样的命令在 Ubuntu 16.04 LTS 客户端上有效。谷歌搜索了很多次还是无法解决这个问题。正在寻找解决方案!
答案1
我通过安装 Autoconf、devssl 和 gcc 编译器解决了这个问题。我的服务器已成功运行。
sudo apt install gcc
sudo apt-get install autoconf
sudo apt-get update && apt-get install -y libssl-dev && rm -rf /var/lib/apt/lists/*
sudo apt-get install libssl-dev
sudo apt-get install build-essential
然后我尝试安装 mongo 扩展到 PHP
sudo /opt/lampp/bin/pecl install mongo
已成功编译并安装。后来我将 mongo 扩展添加到 php.ini
echo 'extension=mongo.so' >> /opt/lampp/etc/php.ini
成功完成。
答案2
我正在使用sudo pecl install mongodb
,它对我有用。如果你使用 php 版本 5.6,并且你检查这个包sudo apt-get install -y autoconf g++ make openssl libssl-dev libcurl4-openssl-dev pkg-config libsasl2-dev libpcre3-dev