handle multiple PHP versions and their modules

This commit is contained in:
Ludovic Cartier
2025-09-24 11:13:12 +02:00
parent f654335684
commit 5d1878f9db
5 changed files with 90 additions and 19 deletions

View File

@@ -1,2 +1,59 @@
# php
# PHP Ansible Role
This Ansible role installs and configures PHP with support for multiple versions and custom modules for each version.
## Features
- Install multiple PHP versions simultaneously (e.g., PHP 8.3 and 8.4)
- Install single PHP version (just provide one version in the list)
- Configure different module lists for each PHP version
- Support for PHP-FPM
- Automatic repository setup (Sury repository for latest PHP versions)
## Requirements
- Ubuntu/Debian-based systems
- Ansible 2.9+
- sudo/root privileges
## Role Variables
### Configuration
```yaml
php_versions:
- version: "8.3"
modules:
- mysql
- gd
- xml
- mbstring
- zip
- version: "8.4"
modules:
- -mysql
- gd
- xml
- redis
- ip
```
## Installed Packages
For each PHP version, the following base packages are automatically installed:
- `php{version}-common`
- `php{version}-cli`
Additional modules are installed based on the `modules` list for each version.
## Notes
- The role uses the Sury repository to provide the latest PHP versions
- Each PHP version runs its own FPM service on different sockets/ports
- Module names should include the PHP version prefix (e.g., `php8.3-mysql`)
- For single version installations, just provide one entry in the `php_versions` list
## License
MIT