https://github.com/timgws/domain-manager
Automate all scaffolding for getting a bunch of PHP sites up and running in isolated containers quickly
https://github.com/timgws/domain-manager
control-panel docker golang hosting mysql nginx percona
Last synced: 4 months ago
JSON representation
Automate all scaffolding for getting a bunch of PHP sites up and running in isolated containers quickly
- Host: GitHub
- URL: https://github.com/timgws/domain-manager
- Owner: timgws
- Created: 2025-06-10T05:35:20.000Z (4 months ago)
- Default Branch: development
- Last Pushed: 2025-06-10T05:43:31.000Z (4 months ago)
- Last Synced: 2025-06-10T06:29:46.264Z (4 months ago)
- Topics: control-panel, docker, golang, hosting, mysql, nginx, percona
- Language: Go
- Homepage:
- Size: 0 Bytes
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# domain-manager
**Domain Manager** is a lightweight CLI tool written in Go to help you self-host multiple PHP-based websites โ especially WordPress or Laravel โ using per-domain `php-fpm` containers, backed by Docker or Podman. It's designed for a simplified setup where nginx and MySQL run directly on the host, and each site gets its own isolated PHP runtime. The tool automates all scaffolding: directory layout, container config, MySQL database creation, and nginx integration. Ideal for developers who want to self-host multiple sites with minimal overhead, full control, and no panel bloat.
---
## Why Use domain-manager Instead of cPanel?
Traditional hosting panels are heavy, opinionated, and often come with licensing costs, background services, and bundled features you may never use. `domain-manager` is built for developers and sysadmins who want:
* ๐งฑ **Full control** โ No hidden automation or black-box behavior
* ๐ง **Linux-native** โ Works seamlessly with your system's users, files, and firewalls
* ๐ณ **Container-based isolation** โ Each site runs its own PHP-FPM container for clean separation
* ๐ **Transparent configuration** โ Every file (nginx, Docker, MySQL) is visible and editable
* ๐ฆ **DevOps-friendly** โ Easily integrates with GitOps, systemd, and shell automation`domain-manager` is ideal for minimal, scalable, modern PHP hosting โ no control panel bloat required.
---
## โจ Features
- ๐ง Per-domain `php-fpm` container generation (Docker/Podman)
- ๐ Mount WordPress files from `/data/websites/{domain}`
- ๐ง Creates isolated Unix system user per domain
- ๐ฌ MySQL database provisioning with namespaced DBs (e.g. `example_com_main`)
- ๐ Auto-generated secure MySQL passwords (displayed once)
- ๐ nginx configuration with FastCGI routing
- โ๏ธ Configurable via `config.yaml` (powered by `spf13/viper`)
- ๐ Domain and DB state tracking with `storm` (BoltDB wrapper)
- ๐งช Lifecycle commands: `add`, `list`, `info`, `delete`
- ๐ Supports `--runtime`, `--force`, `--no-up`, `--no-reload` flags---
## ๐ Requirements
- Go 1.20+
- Podman or Docker
- nginx installed and running on the host
- MySQL server running on the host
- Directory structure: `/data/websites/{domain}`---
## ๐ฌ Installing MySQL (Percona Server 8.4 LTS)
To keep your setup lean, Domain Manager assumes that **MySQL is running on the host**, not in a container. For maximum compatibility and long-term support, we recommend using Percona Server for [MySQL 8.4 LTS][https://www.percona.com/software/mysql-database/percona-server-for-mysql], a drop-in replacement for MySQL with extended support and observability features.Here's how to install it on RHEL-based systems (e.g. AlmaLinux, Rocky Linux):
```
dnf install https://repo.percona.com/yum/percona-release-latest.noarch.rpm
percona-release enable pdps-84-lts
dnf install percona-server-server percona-server-client# Disable telemetry
systemctl stop percona-telemetry-agent
systemctl mask percona-telemetry-agentsystemctl enable --now mysqld
```Make sure that you
```
CREATE USER 'root'@'127.0.0.1' IDENTIFIED BY ')AS8SDA(sgd89a98';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'127.0.0.1' WITH GRANT OPTION;
FLUSH PRIVILEGES;
```---
## Allowing users to SFTP files
Add the SFTP config from `system-config/sshd_config` to `/etc/sshd_config` to ensure that users are jailed to `jailhomes`.Either give users access to SFTP with a password using `passwd ` (not recommended) or set them up with an SSH key.
---
## ๐ฆ Install
```bash
git clone https://github.com/timgws/domain-manager.git
cd domain-manager
go build -o domain-manager .
```## ๐ Usage
```sh
# List all of the domains that we are managing
./domain-manager list# Add, find info, and delete domains
./domain-manager add example.com
./domain-manager info example.com
./domain-manager delete example.com# Manage MySQL databases
./domain-manager mysql create example.com example_db_name
./domain-manager mysql list example.com --stats
```### Flags
* `--runtime docker|podman` โ override container runtime
* `--force` โ recreate existing container (runs down before up)
* `--no-up` โ skip container startup
* `--no-reload` โ skip nginx reload## ๐งฑ Stack
* `nginx` serves static files and proxies `.php` requests to host-mapped container ports
* `PHP-FPM` runs per-site in containers
* MySQL is shared across all sites## ๐ Directory Structure
```
/opt/domain-manager/docker/example.com/
โโโ Dockerfile (from template)
โโโ docker-compose.yaml/etc/nginx/conf.d/example-com.conf
/data/websites/example.com/
```## ๐ License
MIT License โ use it, modify it, fork it.