web-dev-qa-db-ja.com

Ubuntu14にPHP 5.6redis拡張機能をインストールする方法

以前は、PECLを使用してPHPのRedis拡張機能をインストールしていました。しかし、PECLはPHPバージョン7.0未満のサポートを終了したようです。PECLなしでこれを行うための最良の方法は何ですか?私たちはUbuntu14.xでPHP 5.6

ubuntu@box776:~$ pecl help version
PEAR Version: 1.10.1
PHP Version: 5.6.18
Zend Engine Version: 2.6.0
Running on: Linux box776.localdomain 3.13.0-86-generic #131-Ubuntu SMP Thu May 12 23:33:13 UTC 2016 x86_64

更新1

$ Sudo apt-get install php5-redis

Reading package lists... 0%
Reading package lists... 0%
Reading package lists... 0%
Reading package lists... 0%
Reading package lists... 0%
Reading package lists... 0%
Reading package lists... 41%
Reading package lists... Done


Building dependency tree... 50%
Building dependency tree       


Reading state information... Done

The following package was automatically installed and is no longer required:
  os-prober
Use 'apt-get autoremove' to remove it.
The following NEW packages will be installed:
  php5-redis
0 upgraded, 1 newly installed, 0 to remove and 59 not upgraded.
Need to get 105 kB of archives.
After this operation, 359 kB of additional disk space will be used.


0% [Working]Get:1 http://archive.ubuntu.com/ubuntu/ trusty/universe php5-redis AMD64 2.2.4-1build2 [105 kB]

13% [1 php5-redis 14.2 kB/105 kB 13%]Fetched 105 kB in 0s (264 kB/s)
Selecting previously unselected package php5-redis.
(Reading database ... 
(Reading database ... 10%
(Reading database ... 25%
(Reading database ... 40%
(Reading database ... 303857 files and directories currently installed.)
Preparing to unpack .../php5-redis_2.2.4-1build2_AMD64.deb ...
Unpacking php5-redis (2.2.4-1build2) ...
Setting up php5-redis (2.2.4-1build2) ...
php5_invoke: Enable module redis for Apache2 SAPI
php5_invoke: Enable module redis for cli SAPI

これはすべて泳ぎに行くようですが、その後composer installさんのコメント:

$ composer install --no-interaction

You are running composer with xdebug enabled. This has a major impact on runtime performance. See https://getcomposer.org/xdebug
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - The requested PHP extension ext-redis * is missing from your system. Install or enable PHP's redis extension.


composer install --no-interaction returned exit code 2

Action failed: composer install

アップデート2

ボックスにSSHで接続し、同じコマンドを実行しました...

ubuntu@box776:~$ apt-get install php5-redis
E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
ubuntu@box776:~$ Sudo apt-get install php5-redis
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following package was automatically installed and is no longer required:
  os-prober
Use 'apt-get autoremove' to remove it.
The following NEW packages will be installed:
  php5-redis
0 upgraded, 1 newly installed, 0 to remove and 59 not upgraded.
Need to get 105 kB of archives.
After this operation, 359 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu/ trusty/universe php5-redis AMD64 2.2.4-1build2 [105 kB]
Fetched 105 kB in 0s (274 kB/s)
Selecting previously unselected package php5-redis.
(Reading database ... 303857 files and directories currently installed.)
Preparing to unpack .../php5-redis_2.2.4-1build2_AMD64.deb ...
Unpacking php5-redis (2.2.4-1build2) ...
Setting up php5-redis (2.2.4-1build2) ...
php5_invoke: Enable module redis for Apache2 SAPI
php5_invoke: Enable module redis for cli SAPI

これらの最後の2行が私が欠けているものであるかどうか疑問に思いますか? 「モジュールredisを有効にする」ために追加の手順を実行する必要があることを教えてくれますか?

1
emersonthis

CircleCIは、独自の場所/opt/circleci/php/{version}からPHPをロードして構成します。 APTを介してphp-redisをインストールし、CircleCIのバージョンのPHPをAPTがインストールされたファイルに接続することで、投稿された問題を解決しました。 circle.ymlファイルでは次のようになります。

dependencies:
  pre:
    # Set up php-redis.
    # The PHPAPI version (20131226) needs to match.
    # If we start using a different version of PHP this section may need to be updated.
    - Sudo apt-add-repository -y ppa:ondrej/php
    - Sudo apt-get update
    - Sudo apt-get install php-redis
    - echo 'extension=/usr/lib/php/20131226/redis.so' | Sudo tee /opt/circleci/php/5.6.17/etc/conf.d/redis.ini
    - echo 'extension=/usr/lib/php/20131226/igbinary.so' | Sudo tee /opt/circleci/php/5.6.17/etc/conf.d/igbinary.ini

これは最近、CircleCIがComposerをphp -nで実行し始めたときに再び壊れました。これは、PHPの構成ファイルのロードを拒否するため、上記の変更を無視します。ただし、Composerコマンドを独自のものでオーバーライドできます。これをcircle.ymlに追加しました:

dependencies:
  override:
    # CircleCI's new method of running composer breaks our php-redis setup below.
    - composer install --no-interaction
3
Ethan