How to install php extension using pecl for specific php version, when several php versions installed in system?

后端 未结 4 1683
攒了一身酷
攒了一身酷 2021-01-30 08:37

I have installed both php5.6 and php7.0 from PPA on Ubuntu according to this manual

http://lornajane.net/posts/2016/php-7-0-and-5-6-on-ubuntu

But I didn\'t get h

4条回答
  •  感动是毒
    2021-01-30 09:33

    Here's what worked best for me when trying to script this (in case anyone else comes across this like I did):

    $ pecl -d php_suffix=5.6 install 
    $ pecl uninstall -r 
    
    $ pecl -d php_suffix=7.0 install 
    $ pecl uninstall -r 
    
    $ pecl -d php_suffix=7.1 install 
    $ pecl uninstall -r 
    

    The -d php_suffix= piece allows you to set config values at run time vs pre-setting them with pecl config-set. The uninstall -r bit does not actually uninstall it (from the docs):

    vagrant@homestead:~$ pecl help uninstall
    pecl uninstall [options] [channel/] ...
    Uninstalls one or more PEAR packages.  More than one package may be
    specified at once.  Prefix with channel name to uninstall from a
    channel not in your default channel (pecl.php.net)
    
    Options:
      ...
      -r, --register-only
            do not remove files, only register the packages as not installed
      ...
    

    The uninstall line is necessary otherwise installing it will remove any previously installed version, even if it was for a different PHP version (ex: Installing an extension for PHP 7.0 would remove the 5.6 version if the package was still registered as installed).

提交回复
热议问题