Centos – Installing ext-libevent, ext-libev, ext-event for php

centoscentos6PHP

I installed reactphp on my LAMP environment (CentOS 6.4). After the installation was successful, I got this message:

react/react suggests installing ext-libevent (Allows for use of a more performant event-loop implementation.)

react/react suggests installing ext-libev (Allows for use of a more performant event-loop implementation.)

react/react suggests installing ext-event (Allows for use of a more performant event-loop implementation.)

How can I install ext-libevent, ext-libev and ext-event? Thanks!

Best Answer

After doing some digging around, it looks like this is a PECL package. There are some RPMs available but doesn't look like they're in any of the major third-party repos that are tested as safe to install and not cause dependency problems.

So, first step on CentOS would be setup PECL;

yum groupinstall "development tools"
yum install pecl-event php-devel libevent-devel
pecl channel-update pecl.php.net

Next, you would normally just try to install it (pecl install libevent), however, it is going to complain that your PHP is too old and to use the direct path.

pecl install channel://pecl.php.net/libevent-0.1.0

Finally, we have to tell PHP that this was installed. On 64bit CentOS, the extensions' shared libraries default to /usr/lib64/php/modules; you can use the following command to verify that.

php --info | grep extension_dir

Make sure the "so" file exists (looking for libevent.so)

ls -lah /usr/lib64/php/modules

If it is there, now you can safely create the appropriate configuration file for it:

touch /etc/php.d/libevent.ini
vim /etc/php.d/libevent.ini
; Enable libevent PECL extension
extension=libevent.so

Be warned that you will need to be vigilent when you do updates to your system as some circumstances can break the PHP extensions. Just do a pecl uninstall and pecl install to resolve it. Restart your webserver to apply the new PHP configuration and give it a spin!

Related Topic