Changing Pecl Installation Directory

How do you change the default Pear/PECL build folder from /var/tmp?

Whoa, why are you installing PDO from PECL? PDO has been built in to PHP since 5.1. Are you running 5.0?

If you're running 5.1 or higher and are missing PDO, chances are that:

  1. Your copy of PHP was compiled without it, and must be recompiled; or
  2. Your copy of PHP was installed from your OS's repository without the PDO module

If 1, you'll need to either recompile PHP from scratch, or compile just the shared module and copy it to the correct location.

If 2, you'll just need to install your OS's PDO extension. Under RHEL and CentOS, try yum search php-pdo. I don't know the proper syntax for calling the package installer for other distros, but the package will almost certainly include the string "php-pdo". (Tip: If you got your PHP from your OS, they also might provide common PECL packages. Try searching for "pecl" in their repositories.)

Finally, if you're running 5.0... for the sake of all that is good in this world, upgrade! Read through the upgrade notes in the PHP manual first, just in case you're using old behavior by accident.

(Also, to reconfigure pecl, try pecl config-show to see what settings are available, followed by a pecl config-set ... to change a setting. Do not try to install the PDO extension for a version of PHP newer than 5.0.x, it will break. There's even a big fat box at the top of the PDO page on the PECL site.)

pecl installs for previous php version

The solution was pretty simple. I had to make modifications to my pecl config. It turned out that these two command did the trick:

sudo pear config-set php_ini /etc/php.ini
sudo pecl config-set bin_dir /usr/bin/

pecl used the wrong phpize. There were two versions of the phpize. The same counts for my php.ini file.

Where do PEAR packages normally get installed?

/usr/share/php/

is correct for Debian.

/usr/share/php/PEAR

itself contains classes for PEAR itself.

The reason for using /usr/share/php is that the pear CLI tool is an installer that installs libraries (or applications) for PHP - choosing php is thus correct.

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

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 <package>
$ pecl uninstall -r <package>

$ pecl -d php_suffix=7.0 install <package>
$ pecl uninstall -r <package>

$ pecl -d php_suffix=7.1 install <package>
$ pecl uninstall -r <package>

The -d php_suffix=<version> 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/]<package> ...
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).

pecl installing for incorrect version of PHP

As it turns out, another version of php-dev had been installed. Here's what I did to clean it up:

sudo pecl uninstall sync
sudo apt remove php-dev
sudo apt remove php7.3-dev
sudo apt autoremove # <<< VERY important!
sudo apt install php7.3-dev
sudo pecl
sudo pecl config-set php_ini /etc/php/7.3/cli/php.ini
sudo pecl config-set php_bin /usr/bin/php
sudo pecl install sync

Now, SyncEvent() is working great on this system!

Pecl install when using multiple php.ini files

No, there is no out-of-the-box solution. pecl (which is pear -c pecl.php.net) only can update a single php.ini file.

What you could do is create one ini file and symlink it into the conf directories of each php version. (See "Scan for additional .ini files in" in php --ini).



Related Topics



Leave a reply



Submit