An open API service indexing awesome lists of open source software.

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

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-agent

systemctl 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.