How noamanahmed/lemp works
Project type and purpose
• This is a CLI-based automation toolkit (bash scripts) for provisioning and managing a LEMP (Linux, Nginx, MySQL, PHP) server and its ecosystem (Python, NodeJS, Redis, Kafka, etc.).
• The README confirms it’s not a web application but an ops-focused installer/orchestrator for Ubuntu servers.
File structure
• Top-level “bin/” directory: dozens of command scripts (create-site-*, enable-*, disable-*, list-*, etc.).
• “installers/”: idempotent .sh modules that install/configure each service (nginx.sh, php.sh, mysql.sh, redis.sh, etc.).
• “templates/”: Jinja-style (bash-templated) configuration snippets grouped by service (nginx vhosts, supervisord conf, systemd units, etc.).
• “includes/helpers.sh”: shared functions and utilities.
• “install.sh”: the entry-point orchestrator that sources helpers, reads parameters, and invoks installer modules.
• “updates/”: scripts for versioned updates.
• “tests/”: terraform and shell tests for validating deployments.
README for additional insights
• The tool is designed to run on Ubuntu 20.04+ under root.
• It interacts with external APIs: Slack (webhooks), Uptime Robot.
• It manages services locally (systemd, supervisord, jailkit, UFW, etc.).
Main components and their interactions
a. CLI layer (“bin/” scripts and “install.sh”)
• User runs install.sh or a bin/* command.
• The CLI script parses arguments, sources helpers, then dispatches to the right installer.
b. Shared utilities (“includes/helpers.sh”)
• Logging, error handling, templating functions, environment variable parsing.
• Called by both installers and bin scripts.
c. Installer modules (“installers/*.sh”)
• Each service has its own installer script that:
1. Checks prerequisites.
2. Installs packages (apt, pip, npm, etc.).
3. Copies and renders templates.
4. Restarts/reloads services (systemctl, supervisorctl).
d. Template repository (“templates/…”)
• Holds boilerplate config for Nginx, PHP-FPM, MySQL, Postgres, Redis, etc.
• Rendered at runtime with environment‐specific parameters.
e. System services & targets (the provisioned VPS)
• Nginx, PHP-FPM, MySQL, Redis, Docker, fail2ban, UFW, jailkit, etc.
• Slack/UptimeRobot webhooks called via curl in scripts.
f. Update mechanism (“updates/100/update.sh”)
• Applies incremental updates to the tooling itself.
g. Tests (“tests/”)
• Validates infrastructure via Terraform and bash unit/integration tests.
Architectural patterns and design principles
• Modular scripting: one installer per service keeps concerns separated.
• Template-based configuration: promotes DRY, easy customization.
• CLI-driven dispatch: all commands live in “bin/” for discoverability.
• Incremental updates: versioned “updates/” folder.
• Shared library: “includes/helpers.sh” for cross‐cutting needs.
• Clear component labels (e.g., “bin/create-site-php”, “installers/php.sh”).
• User → CLI
• CLI → Helpers / Installers
• Installers → Templates → Services
• Scripts → External APIs