How to Install and Configure PHP Event Extension with libevent on Linux
This guide introduces the PHP Event extension, outlines its libevent and OpenSSL dependencies, and provides detailed step‑by‑step commands to install libevent, compile and configure the PHP Event extension, modify php.ini, and verify the installation on a Linux server.
PHP Event is a PHP extension that enables event‑driven programming, allowing developers to create, listen to, and handle events for asynchronous servers, real‑time communication, and long‑running tasks.
Dependencies
libevent library : a lightweight, high‑performance, cross‑platform event notification library that abstracts OS‑specific I/O multiplexing mechanisms.
OpenSSL library : a full‑featured cryptographic toolkit used for secure communication.
Installation
Install libevent
Check whether libevent is already installed: ls -al /usr/lib | grep libevent Download the source package:
wget https://github.com/libevent/libevent/releases/download/release-2.1.12-stable/libevent-2.1.12-stable.tar.gzExtract the archive: tar -zxvf libevent-2.1.12-stable.tar.gz Configure the installation directory and compile:
./configure --prefix=/usr/local/libevent-2.1.12
make && make installVerify the installation:
ls -al /usr/local/ | grep libeventInstall PHP Event extension
Official PECL package: http://pecl.php.net/package/event
Download the latest release: wget http://pecl.php.net/get/event-3.1.0.tgz Extract the package: tar -zxvf event-3.1.0.tgz Prepare the build environment:
cd event-3.1.0.0
/usr/local/php-8.3.1/bin/phpizeConfigure the extension, linking it with the previously installed libevent:
./configure --with-php-config=/usr/local/php-8.3.1/bin/php-config \
--with-event-libevent-dir=/usr/local/libevent-2.1.12/Use --with-event-libevent-dir to specify the libevent directory.
Compile and install:
make
sudo make installAdd the extension to php.ini:
extension=event.sosudo vim /usr/local/php-8.3.1/etc/php.ini
Verify the installation from the command line:
/usr/local/php-8.3.1/bin/php -m | grep event
# output: eventConfirm the extension works in a browser by creating a PHP script that uses the Event functions (screenshot omitted).
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Open Source Tech Hub
Sharing cutting-edge internet technologies and practical AI resources.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
