Warm tip: This article is reproduced from stackoverflow.com, please click
macos php-7 swoole

How to install swoole in mac-os

发布于 2020-04-05 23:35:20

Am trying to install swoole using PHP 7.0.2 in MAMP

$ pecl install swoole
Could not open input file:/app/MAMP/bin/php/php7.0.2/lib/php/peclcmd.php

Is there any alternate way to install it? Thanks.

Questioner
Sumithran
Viewed
102
ikandars 2018-07-30 11:20

I have no luck installing Swoole via home brew or pecl. So I installed it manually and works. So here my step:

Make sure you php installed on your osx

php -v

phpize -v

Go to temporary folder

cd /tmp/

Download the source code

wget "https://github.com/swoole/swoole-src/archive/v4.0.3.tar.gz" -O swoole.tar.gz

Extract the file

tar xvzf swoole.tar.gz

Go to source folder

cd swoole-src-4.0.3/

Prepare the build environment for a PHP extension

phpize

Add configuration paramaters as needed

./configure

Run make. This will take some time a successful result of make is module/swoole.so

make

create Swoole extension directory

mkdir -p /usr/local/opt/php71-swoole/

install the swoole into the PHP extensions directory

cp modules/swoole.so /usr/local/opt/php71-swoole/

Create config file for Swoole

touch /usr/local/etc/php/7.1/conf.d/ext-swoole.ini
echo "extension=/usr/local/opt/php71-swoole/swoole.so" > /usr/local/etc/php/7.1/conf.d/ext-swoole.ini

check if the swoole extension has been enabled php -m | grep swoole

If succeed, it will send you output something like "swoole"

PS: I run PHP 7.1 and Swoole 4.0.3. Adjust it with your own version.