Install ZMQ and php-zmq extension on Debian or Ubuntu

All the required steps to make ZeroMQ 4 work with php7 on Debian or Ubuntu.

This documentation has been strongly inspired from (May 2012) which installs ZeroMQ 2 on Ubuntu 11.10 and php 5.3.

Note added on October 2017: Obviously, installing php ZMQ extension on PHP 7 and a recent install of Ubuntu can be achieved with only:

sudo apt-get install php-zmq

So try this before, and if you’re lucky, you won’t need to follow this procedure.


Make sure you have all the packages:

sudo apt-get install build-essential libtool autoconf uuid-dev pkg-config git libsodium

## and PHP depending on your version, one of these set of packages:
sudo apt-get install php7.0 php7.0-dev
sudo apt-get install php5 php5-dev
sudo apt-get install php php-dev

Note: If libsodium is not found, try libsodium-dev. Check Jonathan Prass Martins’ gist to see how to install it.

Install ZeroMQ

wget # Latest tarball on 07/08/2016
tar -xvzf zeromq-4.1.4.tar.gz
cd zeromq-4.1.4
sudo make install
sudo ldconfig

Note: Check the lastest tarball release here:

Installing the PHP binding

git clone git://
cd php-zmq
phpize && ./configure
sudo make install

Then add the line in either:

  • your php.ini files (apache2 and cli ones)
  • or in file /etc/php/7.0/mods-available/zmq.ini, then run sudo phpenmod zmq

Finally do:

sudo service apache2 restart

Check that it’s well installed

Just create a php file in your www/ folder and add this:



And run the file with

php my-file.php

you should see bool(true) from your browser.

You can also check the installed ZMQ version from phpinfo().