How to Deploy Webman PHP Framework with Docker in One Click
Learn step‑by‑step how to set up Docker and Docker Compose on Linux, macOS, and Windows, install optional Composer, initialize a Webman project, and use the built‑in docker‑compose.yml to perform one‑click development or production deployments, including custom service configuration and troubleshooting tips.
Overview
Webman is a high‑performance, extensible PHP framework built on Workerman, supporting HTTP, WebSocket, TCP, UDP and other protocols. Since version 2.0 it includes Docker support for one‑click deployment.
Environment preparation
Docker and Docker Compose
Linux (CentOS/Ubuntu)
Update packages:
sudo yum update -y # CentOS
sudo apt update && sudo apt upgrade -y # UbuntuInstall Docker:
sudo yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y # CentOS
sudo apt install docker.io -y # UbuntuStart and enable Docker service:
sudo systemctl start docker
sudo systemctl enable dockerVerify installation:
sudo docker --version
docker compose versionAdd your user to the docker group to avoid sudo for each command and restart the terminal.
macOS
Download and install Docker Desktop from https://www.docker.com/products/docker-desktop.
Verify with docker --version.
Windows
Download and install Docker Desktop from https://www.docker.com/products/docker-desktop and enable WSL 2 if required.
Verify with docker --version in PowerShell.
Ensure Docker Compose v2+ is available (use the docker compose command).
Composer (optional)
curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
composer --versionProject initialization
Create a new Webman project:
composer create-project workerman/webman webman-docker-demo
cd webman-docker-demoThis generates the standard structure, including a pre‑configured docker-compose.yml file.
Check environment compatibility: php start.php check Make sure required extensions such as pcntl and posix are enabled.
One‑click deployment
Debug (development) mode
docker compose upPulls the Webman image (PHP 8.1+).
Shows container logs for debugging.
Open http://localhost:8787 to see the welcome page.
Production mode
docker compose up -dRuns services detached.
View logs with docker compose logs -f.
Stop services with docker compose down.
Custom configuration
Edit docker-compose.yml to add additional services, e.g., MySQL:
services:
webman:
image: workerman/webman:latest
ports:
- "8787:8787"
volumes:
- .:/app
mysql:
image: mysql:8.0
environment:
MYSQL_ROOT_PASSWORD: root
ports:
- "3306:3306"After editing, re‑run docker compose up -d to apply changes.
Accessing the application
Open a browser and navigate to http://<server-IP>:8787 (or http://localhost:8787 for local setups) to view the default Webman homepage.
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.
