Swoole is available as a PECL compatible package
#!/bin/bash pecl install swoole
After March 2018, swoole extension only can be installed with pecl on MacOS.
#!/bin/bash brew install php # if you haven't got PHP installed pecl install swoole
You are recommended to download the latest stable version of swoole. You can download the source code from one of the following the links.
The process of compile and install the swoole extension for PHP:
Download the source packages from Releases or clone from git repo:
git clone https://github.com/swoole/swoole-src.git && \ cd swoole-src && \ git checkout v4.x.x
Compile and install at the source folder:
phpize && \ ./configure && \ make && make install
After installing the swoole extension to the PHP extensions directory, you will need to edit php.ini and add an extension=swoole.so line before you can use the swoole extension.
php -i | grep php.ini # check the php.ini file location sudo echo "extension=swoole.so" >> php.ini # add the extension=swoole.so to the end of php.ini php -m | grep swoole # check if the swoole extension has been enabled
These configurations are used for enabling some features.
Enable the debug logs of swoole. Don't enable this configuration in production environment.
Enable sockets support. It depends on the PHP sockets extension. If this configuration has been enabled, the function swoole_event_add() could add the connection created by the sockets extension to the event loop of swoole. And the function getSocket() depends on this configuration.
Enable openssl support. It depends on the libssl.so library given by operating system.
Set the path of openssl library, for example:
Enable the support of HTTP2. It depends on nghttp2 library.
Enable the support of mysqlnd, for example
You have to include openssl library in your path:
export LDFLAGS="-L/usr/local/opt/openssl/lib" export CPPFLAGS="-I/usr/local/opt/openssl/include"
You can follow the instruction about how to debug the segment fault errors.