Skip to content

PDlib Installation

matiasdelellis edited this page May 11, 2022 · 2 revisions

We are aware that installing this dependency is difficult for many users. To simplify this, we try to maintain a repository of precompiled packages and write good documentation about it.

Easy way

Ideally, you will want to use precompiled libraries. We prepared PDLib PHP library for some systems. If you have one, proceed. If you don't have it, take a look how to compile it yourself below. So, you will need to add this repo to your sources and just install it.

Note that these packages only work with the php versions that officially accompany these distributions. If you use any external repository to have updated versions of php, you will not be able to use these packages and you must compile PDLib on your own. See Relative eassily.

Ubuntu Jammy

echo "deb https://repo.delellis.com.ar jammy jammy" > /etc/apt/sources.list.d/20-pdlib.list
wget -qO - https://repo.delellis.com.ar/repo.gpg.key | sudo apt-key add -
apt update
apt install php8.1-pdlib

Ubuntu Focal

echo "deb https://repo.delellis.com.ar focal focal" > /etc/apt/sources.list.d/20-pdlib.list
wget -qO - https://repo.delellis.com.ar/repo.gpg.key | sudo apt-key add -
apt update
apt install php7.4-pdlib

Debian Bullseye

echo "deb https://repo.delellis.com.ar bullseye bullseye" > /etc/apt/sources.list.d/20-pdlib.list
wget -qO - https://repo.delellis.com.ar/repo.gpg.key | sudo apt-key add -
apt update
apt install php7.4-pdlib

Fedora 28 onwards...

dnf copr enable matias/dlib
dnf install pdlib

RHEL/CentOS/Alma/Rocky and other clones...

You can use the Remi's RPM repository which is always up to date.

Relatively easily

Nextcloud increased the PHP requirements leaving out very popular distributions. Since there are still people who use third party repository to get updated versions of PHP, at least we keep the Dlib packages updated and only having to compile PDlib.

Ubuntu Bionic

echo "deb https://repo.delellis.com.ar bionic bionic" > /etc/apt/sources.list.d/20-pdlib.list
wget -qO - https://repo.delellis.com.ar/repo.gpg.key | sudo apt-key add -
apt update
apt install libdlib-dev

Debian Buster

echo "deb https://repo.delellis.com.ar buster buster" > /etc/apt/sources.list.d/20-pdlib.list
wget -qO - https://repo.delellis.com.ar/repo.gpg.key | sudo apt-key add -
apt update
apt install libdlib-dev

Ubuntu Xenial

echo "deb https://repo.delellis.com.ar xenial xenial" > /etc/apt/sources.list.d/20-pdlib.list
wget -qO - https://repo.delellis.com.ar/repo.gpg.key | sudo apt-key add -
apt update
apt install libdlib-dev

Debian stretch

echo "deb https://repo.delellis.com.ar stretch stretch" > /etc/apt/sources.list.d/20-pdlib.list
wget -qO - https://repo.delellis.com.ar/repo.gpg.key | sudo apt-key add -
apt update
apt install libdlib-dev

NOTE: You can use real test of these components using the following tool. If this test passes correctly, you can continue with the installation of the application knowing that you really meet the requirements.

Hard way.

First you need to install DLib library. If you are not lucky enough to have a distribution that has the dlib packaged (Also check [Relatively easily]), you should compile it from scratch. If you have the dlib package installed, you can skip to the next step.

Install DLib

You can follow procedure for your system, but here is quick overview if you are in hurry (taken from here). First, you need to have decent system, with:

  • support for C++11,
  • libx11-dev (on Ubuntu, install it with sudo apt-get install libx11-dev)
  • BLAS library (If no BLAS library is found, DLib's built-in BLAS will be used. However, if you install an optimized BLAS such as OpenBLAS or the Intel MKL your code will run faster. On Ubuntu you can install OpenBLAS by executing sudo apt-get install libopenblas-dev liblapack-dev)

After that, remember to install DLib as shared library:

git clone https://github.com/davisking/dlib.git
cd dlib/dlib
mkdir build
cd build
cmake -DBUILD_SHARED_LIBS=ON ..
make
sudo make install

Install PDLib

You will have to have PHP dev libraries. On Ubuntu, they can be obtained with sudo apt-get install php7.x-dev.

Installing PDLib boils down to:

git clone https://github.com/goodspb/pdlib.git
cd pdlib
phpize
./configure
make
sudo make install

PDlib configuration.

Now you need to configure your PHP installation to know for pdlib. Edit your php.ini and append content below to it:

[pdlib]
extension="pdlib.so"

Note that you can have 2 php.ini files, one for FPM, one for CLI. You need to change both of them! On Ubuntu, you can generally find them in /etc/php/7.x/cli/php.ini and /etc/php/7.x/fpm/php.ini.

If everything is working, you will see one line after you execute this:

$ php -m | grep pdlib
pdlib

NOTE: You can use real test of these components using the following tool. If this test passes correctly, you can continue with the installation of the application knowing that you really meet the requirements.