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 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.
Update 2018-06-03: Updated to include PHP 7.0 instructions for Ubuntu 16.04 and later.