Skip to content

Instantly share code, notes, and snippets.

@Mecanik
Created November 4, 2019 11:58
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save Mecanik/d2314fbc860b9c68eac4b101127b738e to your computer and use it in GitHub Desktop.
Save Mecanik/d2314fbc860b9c68eac4b101127b738e to your computer and use it in GitHub Desktop.
Install and configure PHP 7.3 ev/event PECL extension on Ubuntu Linux 18.04.3
# For phpize
apt install php7.3-dev
# Install extensions
pecl install ev
pecl install event
# Create configurations
sudo echo 'extension=ev.so' > /etc/php/7.3/mods-available/ev.ini
sudo echo 'extension=event.so' > /etc/php/7.3/mods-available/event.ini
# Create symlinks
sudo ln -s /etc/php/7.3/mods-available/ev.ini /etc/php/7.3/fpm/conf.d/20-ev.ini
sudo ln -s /etc/php/7.3/mods-available/ev.ini /etc/php/7.3/cli/conf.d/20-ev.ini
sudo ln -s /etc/php/7.3/mods-available/event.ini /etc/php/7.3/fpm/conf.d/20-event.ini
sudo ln -s /etc/php/7.3/mods-available/event.ini /etc/php/7.3/cli/conf.d/20-event.ini
# Optional - libevent
## WANRING! Segmentation fault on PHP 7.3.11-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Oct 24 2019 18:23:23) ( NTS ) ##
sudo echo 'extension=libevent.so' > /etc/php/7.3/mods-available/libevent.ini
sudo ln -s /etc/php/7.3/mods-available/libevent.ini /etc/php/7.3/fpm/conf.d/20-libevent.ini
sudo ln -s /etc/php/7.3/mods-available/libevent.ini /etc/php/7.3/cli/conf.d/20-libevent.ini
# Check modules loaded:
php -i | grep -i ev
php -i | grep -i event
# Optional - Restart FPM
sudo service php7.3-fpm restart
Enjoy!
@madbob
Copy link

madbob commented May 23, 2020

Also useful apt-get install pkg-config libevent-dev at the beginning.

@HenkPoley
Copy link

HenkPoley commented Jul 7, 2020

At the start you also want to run sudo apt install libevent-dev

And choose 'no' at the 'Include libevent OpenSSL support [yes] :' prompt. Since sudo apt install libssl1.0-dev (OpenSSL) will remove php7.3-dev, which is necessary for compilation.


In a lot of cases (on Ubuntu 18.04 & 20.04) you may afterwards want to reinstall sudo apt install libssl1.0-dev node-gyp nodejs-dev npm 🙈🤷‍♂️🤦‍♂️

When you use npm/node anywhere in your system.

https://bugs.launchpad.net/ubuntu/+source/nodejs/+bug/1794589


The proper syntax for the .ini file creation is with sudo tee (--append?):

# For phpize and libevent
sudo apt update
sudo apt install php7.3-dev libevent-dev
sudo update-alternatives --set php-config /usr/bin/php-config7.3
sudo update-alternatives --set phpize /usr/bin/phpize7.3
# sudo update-alternatives --set php /usr/bin/php7.3

# Install extensions
sudo pecl install ev
sudo pecl install event #  at the 'Include libevent OpenSSL support [yes] :' prompt type "no".

# Create configurations
echo 'extension=ev.so' | sudo tee /etc/php/7.3/mods-available/ev.ini
echo 'extension=event.so' | sudo tee /etc/php/7.3/mods-available/event.ini

# Create symlinks
sudo phpenmod -v 7.3 ev
sudo phpenmod -v 7.3 event

# Note: The libevent extension is unmaintained; consider to use the event extension instead.
# https://www.php.net/manual/en/intro.libevent.php

# Check modules are loaded
php -m | grep ev
# Note that for the webserver you need to check elsewhere as well.

# restore npm and node
sudo apt install libssl1.0-dev node-gyp nodejs-dev npm
sudo apt autoremove

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment