Skip to content

Instantly share code, notes, and snippets.

@RatserX
Last active November 16, 2023 16:40
Show Gist options
  • Save RatserX/5f5de411888f23c16a8711b36222e6e1 to your computer and use it in GitHub Desktop.
Save RatserX/5f5de411888f23c16a8711b36222e6e1 to your computer and use it in GitHub Desktop.
Setup PHP YAZ on Debian/Ubuntu using PECL

Setup PHP YAZ on Debian/Ubuntu using PECL

Prerequisites

Update the installed packages.

apt update

Install the Ondřej PHP repository.

apt install software-properties-commonsudo
add-apt-repository ppa:ondrej/php
apt update

Check that the repositories are correctly installed.

grep ^ /etc/apt/sources.list /etc/apt/sources.list.d/*

Step 1 - Install the PHP versions

In this case, PHP 7.0 and 7.1 will be installed

# PHP 7.0
apt-get install php7.0 php7.0-cli php7.0-dev php7.0-intl
# PHP 7.1
apt-get install php7.1 php7.1-cli php7.1-dev php7.0-intl

Step 2 - Install PEAR

yum install php-pear

Step 3 - Update PECL

pecl channel-update pecl.php.net

Step 4 - Install LibYAZ-Dev

apt-get install libyaz-dev

Step 5 - Setup the PHP version to be used by PEAR

Set which version to use when compiling the extensions.

# PHP 7.0
pear config-set php_bin "/usr/lib/cgi-bin/php7.0"
# PHP 7.1
pear config-set php_bin "/usr/lib/cgi-bin/php7.1"

Force an upgrade to save changes.

pear upgrade --force

Step 6 - Configure the Update Alternatives for PHP

Use the following command to choose the PHP version to be used as an alternative.

update-alternatives --config php-config

Step 7 - Install YAZ from PECL

pecl install yaz

Step 8 - Check the extension

Use the following command to find where the extension was installed.

pear config-show | grep ext_dir

If necessary, move the extension to the correct PHP extension folder and add the extension to the corresponding php.ini file.

extension=yaz.so

Step 9 - Restart Apache

/etc/init.d/apache2 reload

Troubleshooting


References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment