我们曾经使用PECL来安装PHP的Redis扩展。 但似乎PECL已经放弃了对PHP版本低于7.0的支持。 没有PECL的最好的方法是什么? 我们在运行PHP 5.6的Ubuntu 14.x上
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
我不知道最后两行是我失踪了吗? 它是否告诉我,我需要采取额外的步骤来“启用模块redis”?
CircleCI从它自己的位置加载和configurationPHP: /opt/circleci/php/{version} 。 我们通过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最近又开始运行,用php -n运行Composer,它拒绝为PHP加载一个configuration文件,从而忽略了上述改变。 但是你可以用自己的设置覆盖Composer命令。 我们将此添加到circle.yml :
dependencies: override: # CircleCI's new method of running composer breaks our php-redis setup below. - composer install --no-interaction