How to Install and Use Swoole‑Cli: Fast PHP Binary for Linux, macOS, and Windows

This guide explains what Swoole‑Cli is, the operating systems it supports, how to download and install the binary, configure the environment, manage PHP‑FPM, run a simple Swoole HTTP server, and start a Webman application, all with concrete commands and examples.

Open Source Tech Hub
Open Source Tech Hub
Open Source Tech Hub
How to Install and Use Swoole‑Cli: Fast PHP Binary for Linux, macOS, and Windows

Introduction

Swoole‑Cli is a binary distribution of PHP that bundles Swoole, the PHP core, php‑cli, php‑fpm, and many common extensions. It is fully statically compiled, does not depend on any OS‑specific so libraries, and can be copied between Linux systems and run immediately after download.

Swoole will be offered to users as an independent program similar to node.js , rather than as a PHP extension.

Operating System Support

Swoole‑Cli provides binary packages for three platforms: Linux, macOS, and Windows (via Cygwin).

Installation

Download

wget https://github.com/swoole/swoole-cli/releases/download/v5.1.3.0/swoole-cli-v5.1.3-linux-x64.tar.xz
https://github.com/swoole/swoole-cli/releases/download/v5.1.3.0/swoole-cli-v5.1.3-cygwin-x64.zip

Configure Environment

tar -xf swoole-cli-v5.1.3-linux-x64.tar.xz
chmod u+x swoole-cli
sudo mv swoole-cli /usr/bin/swoole-cli

Check the installed version: swoole-cli -v List the extensions that were compiled into the binary:

swoole-cli -m

Configuration File

Swoole‑Cli does not load any php.ini by default. You can pass PHP options with -d or specify a custom php.ini with -c:

swoole-cli -d swoole.use_shortname=off bin/hyperf.php start
swoole-cli -c /tmp/php.ini -v

Start PHP‑FPM

The binary includes an embedded PHP‑FPM. Use the -P flag to launch it:

# Show help
swoole-cli -P -h
# Run FPM
swoole-cli -P --fpm-config /opt/php-8.1/etc/php-fpm.conf -p /opt/php-8.1/var
# Run as daemon
swoole-cli -P --fpm-config /opt/php-8.1/etc/php-fpm.conf -p /opt/php-8.1/var -F
# Run as root
swoole-cli -P --fpm-config /opt/php-8.1/etc/php-fpm.conf -p /opt/php-8.1/var -F -R

Start Swoole Server

Create a server.php file with a minimal HTTP server:

<?php
$http = new Swoole\Http\Server('127.0.0.1', 9501);
$http->on('start', function ($server) {
    echo "Swoole http server is started at http://127.0.0.1:9501
";
});
$http->on('request', function ($request, $response) {
    $response->header('Content-Type', 'text/plain');
    $response->end('Hello 开源技术小栈!');
});
$http->start();

Run the server with the CLI: swoole-cli server.php Test it using curl:

curl http://127.0.0.1:9501
Hello 开源技术小栈!

Start Webman

To launch a Webman application with Swoole‑Cli:

cd webman.tinywan.com
swoole-cli start.php start

The command starts the Workerman workers and shows the process list, confirming that the server is running in DEBUG mode.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Swoole
Open Source Tech Hub
Written by

Open Source Tech Hub

Sharing cutting-edge internet technologies and practical AI resources.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.