How to Install and Configure Webman for High‑Performance PHP HTTP Services
This guide explains what Webman is, how to install it, run projects on Windows and Linux, configure a custom HTTP proxy handler, and set up Nginx reverse proxy with HTTPS, providing step‑by‑step commands and code examples for a high‑performance PHP backend.
Overview
Webman is a high‑performance HTTP service framework built on Workerman. It replaces the traditional php‑fpm architecture and can be used to develop websites, HTTP APIs, or micro‑services.
Installation
Environment requirements
PHP >= 7.2
Composer >= 2.0
Create the project
composer create-project workerman/webmanStart the server
Windows
Enter the project directory and double‑click windows.bat or run php windows.php to start.
Linux
Debug mode (development): php start.php start Daemon mode (production):
php start.php start -dTip: If an error occurs, a disabled PHP function may be the cause; check the disable_functions list and enable the required functions.
Access the application
Open a browser and visit http://your_server_ip:8787.
HTTP Proxy Server Configuration
1. Create a custom handler
File:
process/Proxy.php <?php
namespace process;
use Workerman\Connection\AsyncTcpConnection;
use Workerman\Connection\TcpConnection;
use Workerman\Protocols\Http\Request;
class Proxy
{
public function onMessage(TcpConnection $connection, Request $request)
{
$replace = [
'api.example.com' => 'api.ai.com',
'discord.example.com' => 'discord.com',
'cdn.example.com' => 'cdn.discordapp.com',
'gateway.example.com' => 'gateway.discord.gg',
];
$host = $request->host(true);
if (!isset($replace[$host])) {
return $connection->send(response('404 not found', 404));
}
$host = $replace[$host];
$buffer = (string)$request;
$con = new AsyncTcpConnection("tcp://$host:443", ['ssl' => ['verify_peer' => false]]);
$buffer = preg_replace("/Host: ?(.*?)
/", "Host: $host
", $buffer);
$con->transport = 'ssl';
$connection->protocol = null;
$con->send($buffer);
$con->pipe($connection);
$connection->pipe($con);
$con->connect();
}
}2. Register the proxy process
File:
config/process.php <?php
return [
// ... other configuration ...
// http proxy configuration
'proxy' => [
'handler' => \process\Proxy::class,
'listen' => 'http://0.0.0.0:8989',
'count' => cpu_count(),
'reloadable' => false,
],
];3. Restart Webman
php start.php restartNginx Reverse Proxy (HTTPS)
Example server block for api.example.com that forwards traffic to the Webman proxy listening on port 8989.
server {
server_name api.example.com;
listen 80;
root /home/www/webman/public;
# Important: disable buffering for proxy streams
proxy_buffering off;
# HTTPS configuration
listen 443 ssl;
ssl_certificate ssl/xxx.pem;
ssl_certificate_key ssl/xxx.key;
ssl_session_cache shared:le_nginx_SSL:1m;
ssl_session_timeout 1440m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers "ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS";
location ^~ / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_http_version 1.1;
proxy_set_header Connection "";
if (!-f $request_filename) {
proxy_pass http://127.0.0.1:8989;
}
}
}After updating the configuration, restart Nginx. Requests to https://api.example.com will be proxied to https://api.ai.com via the Webman proxy.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Open Source Tech Hub
Sharing cutting-edge internet technologies and practical AI resources.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
