SWOOLE Installation and Configuration

shiktocf

shiktocf

Jan 10, 20253 weeks ago11 min read
Share:
Latest version : pecl install openswoole - 4.11 . 1​​​​​

Note: Please make sure you have followed the requirements guide before attempting to install Open Swoole, this ensures you have a latest system and all the required packages and full third party libraries.

Here are installation instructions for different platforms:

Docker

Install via Open Swoole Docker

docker pull openswoole / swoole

Linux Systems

Installing via Open Swoole Ubuntu PPA

You can install the Open Swoole binary release via the official Open Swoole Ubuntu PPA . For example, on Ubuntu or Debian:

Install Open Swoole on Ubuntu 20.04 LTS (Focal Fossa)

apt updateapt install - y software - properties - common && add - apt - repository ppa : ondrej / php - yapt install - y software - properties - common && add - apt - repository ppa : openswoole / ppa - y # choose one PHP version: #apt install -y php7.4-openswoole #apt install -y php8.0-openswoole apt install - y php8 . 1 - openswoole

Install Open Swoole on Ubuntu 22.04 LTS (Jammy Jellyfish)

apt updateapt install - y software - properties - common && add - apt - repository ppa : openswoole / ppa - y # choose one PHP version: #apt install -y php7.4-openswoole #apt install -y php8.0-openswoole apt install - y php8 . 1 - openswoole

Install Open Swoole on CentOS

You can install the Open Swoole binary release via Remi's RPM repository .

Install Remin Rpo on RHEL CentOS, Fedora

Install Epel and Remi Repo in RHEL:

# On RHEL/CentOS 8 yum install http : //rpms.remirepo.net/enterprise/remi-release-8.rpmyum updateyum -- enablerepo = remi install package#On RHEL/CentOS 7 yum install http : //rpms.remirepo.net/enterprise/remi-release-7.rpmyum updateyum -- enablerepo = remi install package

Install Remi Repo in Fedora:

dnf install http : //rpms.remirepo.net/fedora/remi-release-35.rpm #[On Fedora 34] dnf install http : //rpms.remirepo.net/fedora/remi-release-34.rpm #[ On Fedora 34] dnf install http : //rpms.remirepo.net/fedora/remi-release-33.rpm #[On Fedora 33] dnf install http : //rpms.remirepo.net/fedora/remi-release-32.rpm #[On Fedora 32] yum -- enablerepo = remi install package

Install Open Swoole on RHEL CentOS, Fedora

# choose one PHP version: #yum install php74-php-openswoole #yum install php80-php-openswoole yum install php81 - php - openswoole

Installing via PHP PECL

Open Swoole is released as a PECL package and can be installed from the binary using the command line. This is the easiest and fastest way to work with Open Swoole.

#!/bin/bash# Make sure PECL is available... $ sudo apt install php - dev# Latest release of Open Swoole via PECL $ sudo pecl install openswoole

Or to install a specific version using PECL:

#!/bin/bash $ sudo pecl install openswoole - 4.9 . 1

Windows

Install Open Swoole on Windows

You should use Ubuntu on WSL to use Open Swoole on Windows.

You must be running Windows 10 version 2004 or later (Build 19041 or later) or Windows 11.

wsl --install

Install Open Swoole on WSL / WSL2 (Ubuntu)

apt updateapt install - y software - properties - common && add - apt - repository ppa : ondrej / php - yapt install - y software - properties - common && add - apt - repository ppa : openswoole / ppa - y # choose one PHP version: #apt install -y php7.4-openswoole #apt install -y php8.0-openswoole apt install - y php8 . 1 - openswoole

PECL Configuration Options for Open Swoole

When installing Open Swoole via PECL, during the installation it will ask you if you want to enable certain features, this can be provided before running the installation, this helps automate the installation of Swoole or when you don't want to install it. to stop and wait for input. Some options require third party libraries to be installed, see prerequisites.

Shorthand Configure Flag

#!/bin/bash$ pecl install -D 'enable-sockets="no" enable-openssl="yes" enable-http2="yes" enable-mysqlnd="yes" enable-swoole-json="no" enable-swoole-curl="yes" enable-cares="yes" with-postgres="yes"' openswoole

Longhand Configure Flag

#!/bin/bash $ pecl install -- configureoptions 'enable-sockets="no" enable-openssl="yes" enable-http2="yes" enable-mysqlnd="yes" enable-swoole-json="no" enable-swoole-curl="yes"enable-cares="yes" with-postgres="yes"' openswoole

Note:Open Swoole PECL releases are later than GitHub releases.

MacOS Systems

Install Open Swoole with Brew and PECL

#!/bin/bash# If you haven't got PHP installed$ brew install php$ pecl install openswoole

Install Open Swoole with MacPorts

sudo port install php - openswoole

Building Open Swoole from source

Make sure you have completed the prerequisites before compiling Swoole.

To compile and install the Swoole extension for PHP, we can clone the repository from GitHub where Swoole is developed, check out the version you want to compile and install it manually.

Download the source package from GitHub Releases or clone from the git repository.

#!/bin/bash# Install git to access the source code from GitHub$ sudo apt install git$ cd /tmp && git clone https://github.com/openswoole/swoole-src.git && \ cd swoole-src && \ git checkout v4.9.1 && \ phpize && \ ./configure --enable-openssl \ --enable-mysqlnd \ --enable-sockets \ --enable-http2 \ --enable-swoole-curl \ --enable-swoole-json \ --with-postgres \ --enable-cares && \ sudo make && sudo make install

Enable Open Swoole extension in PHP

Enjoying the article?

Create a free account to unlock unlimited access to all articles, bookmark your favorites, and join our growing community of readers.

or
47 views
shiktocf

shiktocf

Want to Share Your Knowledge?

Join our community of writers and help others learn from your experience. Start writing today.

Get Started