monteecristoo’s blog

https://twitter.com/irakaarozo

jenssegers/laravel-mongodb installation PHP7.1 on cloud9

jenssegers/laravel-mongodb installation PHP7.1 on cloud9

updated: 2017/12/14

下記に従ってmongoDBをインストール。

monteecristoo.hatenablog.com

  • composer require jenssegers/mongodb
→ error:
  Problem 1
    - jenssegers/mongodb v3.0.0 requires mongodb/mongodb ^1.0.0 -> satisfiable by mongodb/mongodb[1.0.0, 1.0.1, 1.0.2].
    - jenssegers/mongodb v3.0.1 requires mongodb/mongodb ^1.0.0 -> satisfiable by mongodb/mongodb[1.0.0, 1.0.1, 1.0.2].
    - jenssegers/mongodb v3.0.2 requires mongodb/mongodb ^1.0.0 -> satisfiable by mongodb/mongodb[1.0.0, 1.0.1, 1.0.2].
    - mongodb/mongodb 1.0.2 requires ext-mongodb ^1.1.0 -> the requested PHP extension mongodb is missing from your system.
    - mongodb/mongodb 1.0.1 requires ext-mongodb ^1.1.0 -> the requested PHP extension mongodb is missing from your system.
    - mongodb/mongodb 1.0.0 requires ext-mongodb ^1.1.0 -> the requested PHP extension mongodb is missing from your system.
    - Installation request for jenssegers/mongodb ^3.0 -> satisfiable by jenssegers/mongodb[v3.0.0, v3.0.1, v3.0.2].

  To enable extensions, verify that they are enabled in those .ini files:
    - /etc/php5/cli/php.ini
    - /etc/php5/cli/conf.d/05-opcache.ini
    - /etc/php5/cli/conf.d/10-mysqlnd.ini
    - /etc/php5/cli/conf.d/10-pdo.ini
    - /etc/php5/cli/conf.d/20-curl.ini
    - /etc/php5/cli/conf.d/20-gd.ini
    - /etc/php5/cli/conf.d/20-json.ini
    - /etc/php5/cli/conf.d/20-mcrypt.ini
    - /etc/php5/cli/conf.d/20-mongo.ini
    - /etc/php5/cli/conf.d/20-mysql.ini
    - /etc/php5/cli/conf.d/20-mysqli.ini
    - /etc/php5/cli/conf.d/20-pdo_mysql.ini
    - /etc/php5/cli/conf.d/20-pdo_pgsql.ini
    - /etc/php5/cli/conf.d/20-pgsql.ini
    - /etc/php5/cli/conf.d/20-readline.ini
  You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.

sudo pecl mongodb 

→ Parse error: syntax error, unexpected 'new' (T_NEW) in /usr/share/php/PEAR/Frontend.php on line 91

 

sudo apt-get install php7.1-xml

→ sudo pecl mongodb 

→ Package mongodb Version 1.3.4 does not have REST dependency information available install failed

 

Solution: 

mongoDB をアンインストールして先に sudo pecl mongodb で mongoDB PHP ドライバーを先にインストールしてから mongoDB をインストールする。

ここでmongoDBインストール時、dependencies の conflict が起こったら sudo apt-get install -y mongodb-org* だけでなく正規のインストール手続きを踏む。

 

  • composer require jenssegers/mongodb
→ error:
  Problem 1
    - jenssegers/mongodb v3.0.0 requires mongodb/mongodb ^1.0.0 -> satisfiable by mongodb/mongodb[1.0.0, 1.0.1, 1.0.2].
    - jenssegers/mongodb v3.0.1 requires mongodb/mongodb ^1.0.0 -> satisfiable by mongodb/mongodb[1.0.0, 1.0.1, 1.0.2].
    - jenssegers/mongodb v3.0.2 requires mongodb/mongodb ^1.0.0 -> satisfiable by mongodb/mongodb[1.0.0, 1.0.1, 1.0.2].
    - mongodb/mongodb 1.0.2 requires ext-mongodb ^1.1.0 -> the requested PHP extension mongodb is missing from your system.
    - mongodb/mongodb 1.0.1 requires ext-mongodb ^1.1.0 -> the requested PHP extension mongodb is missing from your system.
    - mongodb/mongodb 1.0.0 requires ext-mongodb ^1.1.0 -> the requested PHP extension mongodb is missing from your system.
    - Installation request for jenssegers/mongodb ^3.0 -> satisfiable by jenssegers/mongodb[v3.0.0, v3.0.1, v3.0.2].

  To enable extensions, verify that they are enabled in those .ini files:
    - /etc/php5/cli/php.ini
    - /etc/php5/cli/conf.d/05-opcache.ini
    - /etc/php5/cli/conf.d/10-mysqlnd.ini
    - /etc/php5/cli/conf.d/10-pdo.ini
    - /etc/php5/cli/conf.d/20-curl.ini
    - /etc/php5/cli/conf.d/20-gd.ini
    - /etc/php5/cli/conf.d/20-json.ini
    - /etc/php5/cli/conf.d/20-mcrypt.ini
    - /etc/php5/cli/conf.d/20-mongo.ini
    - /etc/php5/cli/conf.d/20-mysql.ini
    - /etc/php5/cli/conf.d/20-mysqli.ini
    - /etc/php5/cli/conf.d/20-pdo_mysql.ini
    - /etc/php5/cli/conf.d/20-pdo_pgsql.ini
    - /etc/php5/cli/conf.d/20-pgsql.ini
    - /etc/php5/cli/conf.d/20-readline.ini
  You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.

php -m で php にインストールされているモジュールを確認

おそらく mongodb が抜けている。(ただしmongodコマンドでmongoDBは起動できる) 

この場合、

sudo apt-get install php7.1-mongodb で extension_dir に mongodb.so が作成される。

 

→ composer require jenssegers/mongodb

→ Installed successfully

 

 

 

@workspace/php.ini

以下を加筆

    extensoin=mongodb.so

 

→ composer require jenssegers/mongodb

 

extention の問題関連

参考:

monteecristoo.hatenablog.com

 

f:id:monteecristoo:20171214235649p:plain