wiki:FAQ/PHP Bindings Package

What happened to the PHP bindings packages?

The GPL (which Xapian is currently licensed under) and the PHP licence (which PHP is licensed under) are incompatible due to the latter's naming restrictions on derived works. See ticket#191 for more discussion of this.

The result of this is that distributing binary packages isn't legal. Our understanding is that distributing the source code is OK, and building binary packages is also OK.

If you're using Debian or Ubuntu, it's not hard to build your own binary package for the PHP bindings. First, make sure you have deb-src entries in /etc/apt/sources.list (and/or the files in /etc/apt/sources.list.d/ - if not add them so apt-get source knows where to get sources from. They should look like the corresponding deb entries, except the lines start deb-src instead of deb.

PHP7

To build PHP7 bindings for Xapian 1.4.5-1 and later the following should work:

# Change this to the PHP 7.x version you want to build for.
v=7.2
sudo apt-get update
sudo apt-get build-dep xapian-bindings
sudo apt-get install devscripts php$v-dev php$v-cli
apt-get source xapian-bindings
cd xapian-bindings-1.4.*
echo php7 > debian/bindings-to-package
debian/rules maint PHP7_VERSIONS=$v
debuild -e PHP7_VERSIONS=$v -us -uc 
cd ..

This runs the testsuite as part of the build, which we recommend as it helps to ensure you get a build that actually works. But if you want you can skip running the testsuite by changing the penultimate command above to:

env DEB_BUILD_OPTIONS=nocheck debuild -e PHP7_VERSIONS=$v -us -uc 

Then you can install the built package:

sudo dpkg -i php7-xapian_*.deb

Installing the package should enable the module automatically.

PHP5

Then for Xapian 1.2.19 and later the following should work:

sudo apt-get update
sudo apt-get build-dep xapian-bindings
sudo apt-get install devscripts php5-dev php5-cli
apt-get source xapian-bindings
cd xapian-bindings-1.*.*
rm -f debian/control debian/*-stamp
echo php > debian/bindings-to-package
debian/rules maint PHP_VERSIONS=5
sed -i '/^X-Dummy:/d' debian/control
debuild -e PHP_VERSIONS=5 -us -uc 
cd ..

This runs the testsuite as part of the build, which we recommend as it helps to ensure you get a build that actually works. But if you want you can skip running the testsuite by changing the penultimate command above to:

env DEB_BUILD_OPTIONS=nocheck debuild -e PHP_VERSIONS=5 -us -uc 

Then you can install the built package:

sudo dpkg -i php5-xapian_*.deb

That will enable the module automatically unless you're using a very old Debian or Ubuntu version in which case you will need to enable it in your php5 configuration. Typically (but it depends on your configuration) the file is /etc/php5/apache2/conf.d/20-xapian.ini and should contain:

extension=xapian.so

and then restart Apache2 (or the corresponding PHP server) with something like sudo service apache2 restart

Solutions for some build problems

If you are building the package on a partition mounted with the noexec option (like /tmp sometimes is), you might get a debian/rules: Permission denied message. You need to build somewhere where executable files are allowed - e.g. use your home directory instead.

If you are having issues with the debuild command on Ubuntu Wily, you can try using the external PPA provided by Olly here: https://launchpad.net/~xapian-backports/+archive/ubuntu/ppa

FAQ Index

Last modified 8 months ago Last modified on 27/06/18 23:26:44