Here’s how to install yaz on Ubuntu 20.04 with PHP 7.4:
sudo apt install yaz libyaz4-dev php-dev php-pear sudo pecl install yaz
The libyaz4-dev package is the important, and oft-overlooked part.
Then add the following line to /etc/php/7.4/apache2/php.ini:
And restart apache:
sudo systemctl restart apache2
Original post from 4 years ago follows.
Numerous sites on the internet have answered the basic question of “how do I install yaz for PHP on Ubuntu”. Which basically boils down to some flavor of:
sudo apt-get install yaz sudo apt-get install pecl # Ubuntu pre-16.04 sudo apt-get install php-pear # Ubuntu 16.04 and later sudo pecl install yaz
Then add the following line to /etc/php5/apache2/php.ini:
sudo apt-get install yaz sudo apt-get install php7.0-dev php7.0-pear # might just be php-dev and php-pear on your OS (eg: Ubuntu 16.04) sudo pecl install yaz
Then add the following line to /etc/php/7.0/apache2/php.ini:
But wait, that fails
Sadly, the pecl install will fail with the error:
checking for yaz-config... NONE configure: error: YAZ not found (missing NONE) ERROR: `/tmp/pear/temp/yaz/configure --with-yaz' failed
All the search results for this error solve it by downloading the yaz source code and compiling and installing it outside the package manager, which is non-ideal.
The missing piece is that yaz-config is included with the libyaz4-dev package:
sudo apt-get install libyaz4-dev
Interestingly, this yaz install blog post does explicitly calls out the need for the -dev packages, but doesn’t include the error when you don’t have it. Hopefully this blog post will tie the two bits together for future people perplexed by this.
- 2018-06-03: include PHP 7.0 instructions for Ubuntu 16.04.
- 2020-12-05: include PHP 7.4 instructions for Ubuntu 20.04.