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.

Open Source Tech Hub
Open Source Tech Hub
Open Source Tech Hub
How to Install and Configure PHP Event Extension with libevent on Linux

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.gz

Extract 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 install

Verify the installation:

ls -al /usr/local/ | grep libevent

Install 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/phpize

Configure 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 install

Add the extension to php.ini:

extension=event.so
sudo 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: event

Confirm the extension works in a browser by creating a PHP script that uses the Event functions (screenshot omitted).

PHP Event verification in browser
PHP Event verification in browser
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

LinuxPHPInstallationlibeventEvent Extension
Open Source Tech Hub
Written by

Open Source Tech Hub

Sharing cutting-edge internet technologies and practical AI resources.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.