title: How to install php extension using pecl for specific php version, when several php versions installed in system?
body: <p>I have installed both php5.6 and php7.0 from PPA on Ubuntu according to this manual</p>
  
  <p><a href="http://lornajane.net/posts/2016/php-7-0-and-5-6-on-ubuntu" rel="noreferrer">http://lornajane.net/posts/2016/php-7-0-and-5-6-on-ubuntu</a></p>
  
  <p>But I didn't get how to install extensions using <code>pecl</code> for php5.6 or php7.0.</p>
  
  <p>For example I have already installed version of <code>libevent</code> or <code>amqp</code> in php5.6.</p>
  
  <p>Now when I type <code>pecl install libevent</code> and my active php version is php7.0 (using <code>update-alternatives --set php /usr/bin/php7.0),</code>pecl<code>returns message that</code>libevent` already installed.</p>
  
  <p>But it was installed only for php5.6 (when this version was active) and now I want to do it for php7.0.</p>
  
  <p>Which commands could help me?</p>
  
  <p><strong>UPD</strong></p>
  
  <p>I have found this commands for switch pecl to php7.0 and packet them to executable bash scripts:</p>
  
  <pre><code>#!/bin/bash
  
  sudo update-alternatives --set php /usr/bin/php7.0
  
  sudo pecl config-set php_ini /etc/php/7.0/cli/php.ini
  sudo pecl config-set ext_dir /usr/lib/php/20151012/
  sudo pecl config-set bin_dir /usr/bin/
  sudo pecl config-set php_bin /usr/bin/php7.0
  sudo pecl config-set php_suffix 7.0
  </code></pre>
  
  <p>and for php5.6</p>
  
  <pre><code>#!/bin/bash
  
  sudo update-alternatives --set php /usr/bin/php5.6
  
  sudo pecl config-set php_ini /etc/php/5.6/cli/php.ini
  sudo pecl config-set ext_dir /usr/lib/php/20131226/
  sudo pecl config-set bin_dir /usr/bin/
  sudo pecl config-set php_bin /usr/bin/php5.6
  sudo pecl config-set php_suffix 5.6
  </code></pre>
  
  <p>But they are not help, pecl still gives me <code>list</code> of already installed extensions to php5.6, even if I switched to php7.</p>
  
  <pre><code>pecl list
  Installed packages, channel pecl.php.net:
  =========================================
  Package  Version State
  amqp     1.7.1   stable
  libevent 0.1.0   beta
  stats    1.0.3   stable
  </code></pre>
  
  <p>It should be empty for php7.0 !</p>
  
  <p>How to solve the problem?</p>
  
  <p><strong>UPD</strong></p>
  
  <p>For amqp I have just installed php-amqp package without using pecl.</p>
  
  <pre><code>apt-get install php-amqp
  </code></pre>
  
  <p>And libevent still not exists for php7.
  But I hadn't found a way to switch pecl installation between 5.6 and 7 version, so question is still open.</p>