3.0 KiB
3.0 KiB
🧰 Lenvi - Ansible-Powered Development Environment
Lenvi is a framework-agnostic development environment powered by Ansible. It installs and configures Nginx, multiple PHP versions, your choice of database, per-project databases, a global database user, and a smart Composer wrapper that automatically uses the correct PHP version for each project.
Features
- Framework Agnostic: By specifying a
document_root
for Nginx and aproject_root
for Composer, you can support Laravel, WordPress, legacy PHP apps, or even static HTML sites. - Robust Validation: Automatically checks that your configured directories and index files exist before attempting setup, preventing common Nginx errors.
- Per-Project Databases: Each site defined in
Lenvi.yaml
can have its own isolated database, created automatically. - Seamless Composer Workflow:
cd
into your project directory and runcomposer install
. Lenvi automatically uses the correct PHP version for that project. - Centralized Configuration: Manage your entire environment from a single, clean
Lenvi.yaml
file.
Prerequisites
- Ansible & Git: Must be installed.
sudo apt update && sudo apt install ansible git -y
- Sudo Access: Your user must have
sudo
privileges. - Debian-based OS: Required for
apt
(includes Ubuntu, WSL distributions, etc.).
How to Run
1. Get the Code
git clone https://git.marmattheo.com/marito/Lenvi.git lenvi-ansible && cd lenvi-ansible
2. Configure Lenvi
Open Lenvi.yaml
and define your sites. This is the key to Lenvi's flexibility:
project_root
: The base directory of your project. This is where you would rungit
orcomposer
commands.document_root
: The directory that Nginx will serve files from. For Laravel, this is thepublic
sub-directory. For many other projects, it might be the same as theproject_root
. ExampleLenvi.yaml
:
db_engine: "mariadb"
db_credentials: { user: "lenvi", password: "password" }
sites:
- domain: my-laravel-app.local
project_root: /home/user/projects/my-laravel-app
document_root: /home/user/projects/my-laravel-app/public
php_version: "8.2"
database: "laravel_db"
- domain: my-static-site.local
project_root: /home/user/projects/my-static-site
document_root: /home/user/projects/my-static-site
php_version: "8.2" # Required for Nginx config, can be any installed version
3. Execute the Playbook
ansible-playbook playbook.yml -i inventory --ask-become-pass
🚀 Post-Installation
Database Access
For each project, use the global user credentials with the project-specific database name from Lenvi.yaml
.
Update Your Hosts File
Map your domains to 127.0.0.1
.
On Linux
sudo nano /etc/hosts
On Windows (for WSL Users)
Open Notepad as Administrator and edit C:\Windows\System32\drivers\etc\hosts
.
Example entries:
127.0.0.1 my-laravel-app.local
127.0.0.1 my-static-site.local
✅ You're all set! Your flexible, multi-project environment is ready.