Install php-libevent on OS X [solved]

I’m experimenting with Ratchet, a websocket server written in PHP. I wanted to install lib-event for PHP because according to this thread it works better than PHP’s choose_stream function. It ended up being a pain: port install libevent worked but when I ran pecl install channel://pecl.php.net/libevent-0.0.5 it could not find the libevent headers even when I pointed it to /opt/local/lib/, which is where port contents libevent said it was installed.

I ended up following this tutorial on compiling it from source and then pointing the pecl installer to that library and it worked. Mostly. Compiling it from source put it in /usr/local/lib, which the pecl installer liked better. Then it was a question of enabling it in PHP.

OS X’s php.ini installed here:

/etc/apache2/php.ini

MacPort’s PHP is installed here:

/opt/local/etc/php5/php.ini

Unless you change your default setup, apache will serve pages with OS X’s PHP, while the command line will serve pages with MacPort’s PHP.

Most of my OS X PHP extensions are installed here:

/usr/lib/php/extensions/no-debug-non-zts-20090626

Most of my Mac Port PHP extensions are installed here:

/opt/local/lib/php/extensions/no-debug-non-zts-20090626

I had to copy libevent.so from my mac’s extension directory to the macports extension directory, and add extension=libevent.so to both php.ini files.

One Response to “Install php-libevent on OS X [solved]”

  1. on 26 Jul 2013 at 9:02 am Henri

    Wouldn’t it be easier to just symlink one extensions directory to the other one so that you do not have to copy shared libraries around ?

Trackback this Post | Feed on comments to this Post

Leave a Reply

You must be logged in to post a comment.