{"id":19806020,"url":"https://github.com/cycloidio/ansible-php","last_synced_at":"2026-03-19T11:48:12.254Z","repository":{"id":29464416,"uuid":"59465832","full_name":"cycloidio/ansible-php","owner":"cycloidio","description":null,"archived":false,"fork":false,"pushed_at":"2022-08-05T08:30:48.000Z","size":68,"stargazers_count":1,"open_issues_count":1,"forks_count":1,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-02-28T17:54:40.583Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Jinja","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cycloidio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-05-23T08:33:54.000Z","updated_at":"2022-09-01T04:24:31.000Z","dependencies_parsed_at":"2022-07-27T20:19:40.125Z","dependency_job_id":null,"html_url":"https://github.com/cycloidio/ansible-php","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/cycloidio/ansible-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cycloidio%2Fansible-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cycloidio%2Fansible-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cycloidio%2Fansible-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cycloidio%2Fansible-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cycloidio","download_url":"https://codeload.github.com/cycloidio/ansible-php/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cycloidio%2Fansible-php/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30111779,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-05T03:40:26.266Z","status":"ssl_error","status_checked_at":"2026-03-05T03:39:15.902Z","response_time":93,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-12T09:06:10.403Z","updated_at":"2026-03-05T06:02:28.541Z","avatar_url":"https://github.com/cycloidio.png","language":"Jinja","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ansible Role: PHP\n\n[![Build Status](https://travis-ci.org/geerlingguy/ansible-role-php.svg?branch=master)](https://travis-ci.org/geerlingguy/ansible-role-php)\n\nInstalls PHP on RedHat/CentOS and Debian/Ubuntu servers.\n\n## Requirements\n\nMust be running a separate web server, such as Nginx or Apache.\n\n## Role Variables\n\nAvailable variables are listed below, along with default values (see `defaults/main.yml`):\n\n    php_packages: []\n\nA list of the PHP packages to install (OS-specific by default). You'll likely want to install common packages like `php`, `php-cli`, `php-devel` and `php-pdo`, and you can add in whatever other packages you'd like (for example, `php-gd` for image manipulation, or `php-ldap` if you need to connect to an LDAP server for authentication).\n\n    php_enable_webserver: true\n\nIf your usage of PHP is tied to a web server (e.g. Apache or Nginx), leave this default value. If you are using PHP server-side or to run some small application, set this value to `false` so this role doesn't attempt to interact with a web server.\n\n    php_webserver_daemon: \"httpd\"\n\nThe default values for the HTTP server deamon are `httpd` (used by Apache) for RedHat/CentOS, or `apache2` (also used by Apache) for Debian/Ubuntu. If you are running another webserver (for example, `nginx`), change this value to the name of the daemon under which the webserver runs.\n\n    php_enablerepo: \"\"\n\n(RedHat/CentOS only) If you have enabled any additional repositories (might I suggest geerlingguy.repo-epel or geerlingguy.repo-remi), those repositories can be listed under this variable (e.g. `remi,epel`). This can be handy, as an example, if you want to install the latest version of PHP 5.4, which is in the Remi repository.\n\n    php_executable: \"php\"\n\nThe executable to run when calling PHP from the command line. You should only change this if running `php` on your server doesn't target the correct executable, or if you're using software collections on RHEL/CentOS and need to target a different version of PHP.\n\n### PHP-FPM\n\nPHP-FPM is a simple and robust FastCGI Process Manager for PHP. It can dramatically ease scaling of PHP apps and is the normal way of running PHP-based sites and apps when using a webserver like Nginx (though it can be used with other webservers just as easily).\n\nWhen using this role with PHP running as `php-fpm` instead of as a process inside a webserver (e.g. Apache's `mod_php`), you need to set the following variable to `true`:\n\n    php_enable_php_fpm: false\n\nYou will also need to override the default `php_packages` list and add `php-fpm` (RedHat/CentOS) or `php5-fpm` (Debian/Ubuntu) to the list.\n\nThis role does not manage fpm-specific www pool configuration (found in `/etc/php-fpm.d/www.conf` on RedHat/CentOS and `/etc/php5/fpm/pool.d/www.conf` on Debian/Ubuntu), but rather allows you to manage those files on your own. If you change that file, remember to notify the `restart php-fpm` handler so PHP picks up the new settings once in place. Settings like `pm.max_children` and other `pm.*` settings can have a dramatic impact on server performance, and should be tuned specifically for each application and server configuration.\n\nYou can also chose to specify if php-fpm service should be `reloaded` or `restarted` using the variable with the corresponding state:\n\n    php_fpm_state: restarted\n\n### php.ini settings\n\n    php_use_managed_ini: true\n\nBy default, all the extra defaults below are applied through the php.ini included with this role. You can self-manage your php.ini file (if you need more flexility in its configuration) by setting this to `false` (in which case all the below variables will be ignored).\n\n    php_memory_limit: \"256M\"\n    php_max_execution_time: \"60\"\n    php_max_input_time: \"60\"\n    php_max_input_vars: \"1000\"\n    php_realpath_cache_size: \"32K\"\n    php_upload_max_filesize: \"64M\"\n    php_post_max_size: \"32M\"\n    php_auto_prepend_file: \"\"\n    php_date_timezone: \"America/Chicago\"\n    php_sendmail_path: \"/usr/sbin/sendmail -t -i\"\n    php_short_open_tag: false\n    php_disable_functions: \"\"\n    php_error_reporting: \"E_ALL \u0026 ~E_DEPRECATED \u0026 ~E_STRICT\"\n    php_display_errors: \"Off\"\n    php_display_startup_errors: \"On\"\n    php_expose_php: \"On\"\n\nVarious defaults for PHP. Only used if `php_use_managed_ini` is set to `true`.\n\n### OpCache-related Variables\n\nThe OpCache is included in PHP starting in version 5.5, and the following variables will only take effect if the version of PHP you have installed is 5.5 or greater.\n\n    php_opcache_enabled_in_ini: false\n\nWhen installing Opcache, depending on the system and whether running PHP as a webserver module or standalone via `php-fpm`, you might need the line `extension=opcache.so` in `opcache.ini`. If you need that line added (e.g. you're running `php-fpm`), set this variable to true.\n\n    php_opcache_enable: \"1\"\n    php_opcache_enable_cli: \"0\"\n    php_opcache_memory_consumption: \"96\"\n    php_opcache_interned_strings_buffer: \"16\"\n    php_opcache_max_accelerated_files: \"4096\"\n    php_opcache_max_wasted_percentage: \"5\"\n    php_opcache_validate_timestamps: \"1\"\n    php_opcache_revalidate_freq: \"2\"\n    php_opcache_max_file_size: \"0\"\n\nOpCache ini directives that are often customized on a system. Make sure you have enough memory and file slots allocated in the OpCache (`php_opcache_memory_consumption`, in MB, and `php_opcache_max_accelerated_files`) to contain all the PHP code you are running. If not, you may get less-than-optimal performance!\n\n### APC-related Variables\n\n    php_enable_apc: true\n\nWhether to enable APC. Other APC variables will be ineffective if this is set to false.\n\n    php_apc_enabled_in_ini: false\n\nWhen installing APC, depending on the system and whether running PHP as a webserver module or standalone via `php-fpm`, you might need the line `extension=apc.so` in `apc.ini`. If you need that line added (e.g. you're running `php-fpm`), set this variable to true.\n\n    php_apc_cache_by_default: \"1\"\n    php_apc_shm_size: \"96M\"\n    php_apc_stat: \"1\"\n    php_apc_enable_cli: \"0\"\n\nAPC ini directives that are often customized on a system. Set `php_apc_cache_by_default` to 0 to disable APC by default (so you could just enable it for one codebase if you have a *lot* of code on a server). Set the `php_apc_shm_size` so it will hold all your application code in memory with a little overhead (fragmentation or APC running out of memory will slow down PHP *dramatically*).\n\n#### Ensuring APC is installed\n\nIf you use APC, you will need to make sure APC is installed (it is installed by default, but if you customize the `php_packages` list, you need to include APC in the list):\n\n  - *On RHEL/CentOS systems*: Make sure `php-pecl-apc` is in the list of `php_packages`.\n  - *On Debian/Ubuntu systems*: Make sure `php-apc` is in the list of `php_packages`.\n\nYou can also install APC via `pecl`, but it's simpler to manage the installation with the system's package manager.\n\n### Installing from Source\n\nIf you need a specific version of PHP, or would like to test the latest (e.g. master) version of PHP, there's a good chance there's no suitable package already available in your platform's package manager. In these cases, you may choose to install PHP from source by compiling it directly.\n\nNote that source compilation takes *much* longer than installing from packages (PHP HEAD takes 5+ minutes to compile on a modern quad-core computer, just as a point of reference).\n\n    php_install_from_source: false\n\nSet this to `true` to install PHP from source instead of installing from packages.\n\n    php_source_version: \"master\"\n\nThe version of PHP to install from source (a git branch, tag, or commit hash).\n\n    php_source_clone_dir: \"~/php-src\"\n    php_source_install_path: \"/opt/php\"\n\nLocation where source will be cloned and installed, respectively.\n\n    php_source_make_command: \"make\"\n\nSet the `make` command to `make --jobs=X` where `X` is the number of cores present on the server where PHP is being compiled. Will speed up compilation times dramatically if you have multiple cores.\n\n    php_source_configure_command: \u003e\n      [...]\n\nThe `./configure` command that will build the Makefile to be used for PHP compilation. Add in all the options you need for your particular environment. Using a folded scalar (`\u003e`) allows you to define the variable over multiple lines, which is extremely helpful for legibility and source control!\n\nA few other notes/caveats for specific configurations:\n\n  - **Apache with `mpm_prefork`**: If you're using Apache with prefork as a webserver for PHP, you will need to make sure `apxs2` is available on your system (e.g. by installing `apache2-prefork-dev` in Ubuntu), and you will need to make sure the option `--with-apxs2` is defined in `php_source_configure_command`. Finally, you will need to make sure the `mpm_prefork` module is loaded instead of `mpm_worker` or `mpm_event`, and likely add a `phpX.conf` (where `X` is the major version of PHP) configuration file to the Apache module config folder with contents like [`php7.conf`](https://gist.github.com/geerlingguy/5ae5445f28e71264e8c1).\n  - **Apache with `mpm_event` or `mpm_worker`**: If you're using Apache with event or worker as a webserver for PHP, you will need to compile PHP with FPM. Make sure the option `--enable-fpm` is defined in `php_source_configure_command`. You'll also need to make sure Apache's support for CGI and event is installed (e.g. by installing `apache2-mpm-event` and `libapache2-mod-fastcgi`) and the `mpm_event` module is loaded.\n  - **Nginx**: If you're using Nginx as a webserver for PHP, you will need to compile PHP with FPM. Make sure the option `--enable-fpm` is defined in `php_source_configure_command`.\n\n## Dependencies\n\nNone.\n\n## Example Playbook\n\n    - hosts: webservers\n      vars_files:\n        - vars/main.yml\n      roles:\n        - { role: geerlingguy.php }\n\n*Inside `vars/main.yml`*:\n\n    php_memory_limit: \"128M\"\n    php_max_execution_time: \"90\"\n    php_upload_max_filesize: \"256M\"\n    php_packages:\n      - php\n      - php-cli\n      - php-common\n      - php-devel\n      - php-gd\n      - php-mbstring\n      - php-pdo\n      - php-pecl-apc\n      - php-xml\n      ...\n\n## License\n\nMIT / BSD\n\n## Author Information\n\nThis role was created in 2014 by [Jeff Geerling](http://jeffgeerling.com/), author of [Ansible for DevOps](http://ansiblefordevops.com/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcycloidio%2Fansible-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcycloidio%2Fansible-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcycloidio%2Fansible-php/lists"}