|
|
||
|---|---|---|
| .scripts | ||
| defaults | ||
| filter_plugins | ||
| handlers | ||
| meta | ||
| tasks | ||
| templates/etc/__php__ | ||
| tests | ||
| vars | ||
| .ansible-lint | ||
| .gitignore | ||
| .travis.yml | ||
| .yamllint.yml | ||
| LICENSE | ||
| README.md | ||
| Vagrantfile | ||
README.md
Ansible PHP (+FPM) role for Debian / Ubuntu / FreeBSD
Install PHP on Debian / Ubuntu / FreeBSD. Manage PHP-FPM, APCu, Opcache and Xdebug.
Managed OS / Versions
On all Debian versions, you can install all PHP versions (from PHP 5.6 to 8.1 beta) by using Sury's APT repository.
Other cases:
| OS | PHP 7.0 | PHP 7.1 | PHP 7.2 | PHP 7.3 | PHP >= 7.4 |
|---|---|---|---|---|---|
| Ubuntu Bionic (18.04) | ❌ | ❌ | ✔️ | ❌ | ❌ |
| FreeBSD 11 | ✔️ | ✔️ | ✔️ | ✔️ | Need tests... |
| FreeBSD 12 | ✔️ | ✔️ | ✔️ | ✔️ | Need tests... |
Links:
Requirements
- Ansible >= 2.11
- Collections: community.general
- If you need PHP-FPM, you must install a webserver with FastCGI support. You can use my nginx role.
FreeBSD limitations
- It doesn't split ini file for FPM/CLI. It's hardcoded as
/usr/local/etc/php.ini. - It can't manage multiple PHP versions at the time (like legacy Debian versions)
- You must explicitely set xdebug package name (use
pkg search xdebugto find the good one)
Role Variables
You should look at default vars.
Writable vars
php_version: 7.3, 7.4... depending OS (see above)php_install_fpm: boolean, install and manage php-fpm (default is true)php_install_xdebug: boolean, install Xdebugphp_extra_packages: additional php packages to install (default is an empty list).
php.ini
php_ini: global configuration shared beween FPM/CLIphp_ini_fpm: manage FPM php.ini (php-fpm)php_ini_cli: manage CLI php.ini (php-fpm)
Note:
- If you want exactly same configuration for CLI/FPM. You can put all your data in
php_ini. - Put specific configuration in
php_ini_fpm/php_ini_cli. - You can override with
php_ini_fpm/php_ini_cli, but it breaks idempotence.
OpCache settings
See Opcache doc
php_opcache_enablephp_opcache_enable_cliphp_opcache_memory_consumptionphp_opcache_interned_strings_bufferphp_opcache_max_accelerated_filesphp_opcache_max_wasted_percentagephp_opcache_validate_timestampsphp_opcache_revalidate_freqphp_opcache_max_file_size
APC/APCu settings
See apc doc
php_apc_enablephp_apc_enable_cliphp_apc_shm_sizephp_apc_num_files_hintphp_apc_user_entries_hintphp_apc_user_ttlphp_apc_ttlphp_apc_file_update_protectionphp_apc_slam_defensephp_apc_stat_ctime
Xdebug settings
See Xdebug doc
php_xdebug_auto_tracephp_xdebug_cli_colorphp_xdebug_collect_assignmentsphp_xdebug_collect_includesphp_xdebug_collect_paramsphp_xdebug_collect_returnphp_xdebug_collect_varsphp_xdebug_coverage_enablephp_xdebug_default_enablephp_xdebug_dump_globalsphp_xdebug_dump_oncephp_xdebug_dump_undefinedphp_xdebug_extended_infophp_xdebug_file_link_formatphp_xdebug_force_display_errorsphp_xdebug_force_error_reportingphp_xdebug_halt_levelphp_xdebug_idekeyphp_xdebug_manual_urlphp_xdebug_max_nesting_levelphp_xdebug_overload_var_dumpphp_xdebug_profiler_appendphp_xdebug_profiler_enablephp_xdebug_profiler_enable_triggerphp_xdebug_profiler_enable_trigger_valuephp_xdebug_profiler_output_dirphp_xdebug_profiler_output_namephp_xdebug_remote_autostartphp_xdebug_remote_connect_backphp_xdebug_remote_cookie_expire_timephp_xdebug_remote_enablephp_xdebug_remote_handlerphp_xdebug_remote_hostphp_xdebug_remote_logphp_xdebug_remote_modephp_xdebug_remote_portphp_xdebug_screamphp_xdebug_show_exception_tracephp_xdebug_show_local_varsphp_xdebug_show_mem_deltaphp_xdebug_trace_enable_triggerphp_xdebug_trace_enable_trigger_valuephp_xdebug_trace_formatphp_xdebug_trace_optionsphp_xdebug_trace_output_dirphp_xdebug_trace_output_namephp_xdebug_var_display_max_childrenphp_xdebug_var_display_max_dataphp_xdebug_var_display_max_depth
Read only vars
php_packages: minimal package list to installphp_extension_dir.stdout: get php extension dir (from task)php_version.stdout: get php version (from task)
Dependencies
None.
Example Playbook
Simple Playbook
- hosts: servers
roles:
- { role: hanxhx.php }
Debian Bullseye with PHP 8.0 CLI (no FPM)
- hosts: servers
roles:
- { role: HanXHX.sury }
- { role: hanxhx.php, php_version: '8.0', php_install_fpm: false }
License
GPLv2
Donation
If this code helped you, or if you’ve used them for your projects, feel free to buy me some 🍻
- Bitcoin:
1BQwhBeszzWbUTyK4aUyq3SRg7rBSHcEQn - Ethereum:
0x63abe6b2648fd892816d87a31e3d9d4365a737b5 - Litecoin:
LeNDw34zQLX84VvhCGADNvHMEgb5QyFXyD - Monero:
45wbf7VdQAZS5EWUrPhen7Wo4hy7Pa7c7ZBdaWQSRowtd3CZ5vpVw5nTPphTuqVQrnYZC72FXDYyfP31uJmfSQ6qRXFy3bQ
No crypto-currency? ⭐ the project is also a way of saying thank you! 😎
Author Information
- Twitter: @hanxhx_