{"id":13655001,"url":"https://github.com/geerlingguy/ansible-role-apache","last_synced_at":"2025-05-15T00:10:58.678Z","repository":{"id":14585187,"uuid":"17301714","full_name":"geerlingguy/ansible-role-apache","owner":"geerlingguy","description":"Ansible Role - Apache 2.x.","archived":false,"fork":false,"pushed_at":"2025-01-31T03:24:52.000Z","size":199,"stargazers_count":420,"open_issues_count":6,"forks_count":500,"subscribers_count":24,"default_branch":"master","last_synced_at":"2025-03-30T16:08:07.353Z","etag":null,"topics":["ansible","apache","centos","debian","fedora","install","lamp","redhat","rhel","role","setup","ubuntu","webserver"],"latest_commit_sha":null,"homepage":"https://galaxy.ansible.com/geerlingguy/apache/","language":"Jinja","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/geerlingguy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"geerlingguy","patreon":"geerlingguy"}},"created_at":"2014-02-28T22:22:28.000Z","updated_at":"2025-03-02T16:50:44.000Z","dependencies_parsed_at":"2023-02-14T17:45:59.781Z","dependency_job_id":"ba8dddcf-ff7c-42bc-969d-33d05fc1a431","html_url":"https://github.com/geerlingguy/ansible-role-apache","commit_stats":{"total_commits":224,"total_committers":28,"mean_commits":8.0,"dds":0.2767857142857143,"last_synced_commit":"1899aa047e3c3f739a9aa8cf0eefd360950df942"},"previous_names":[],"tags_count":50,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geerlingguy%2Fansible-role-apache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geerlingguy%2Fansible-role-apache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geerlingguy%2Fansible-role-apache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geerlingguy%2Fansible-role-apache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/geerlingguy","download_url":"https://codeload.github.com/geerlingguy/ansible-role-apache/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247517905,"owners_count":20951718,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["ansible","apache","centos","debian","fedora","install","lamp","redhat","rhel","role","setup","ubuntu","webserver"],"created_at":"2024-08-02T03:00:54.588Z","updated_at":"2025-04-06T17:08:18.935Z","avatar_url":"https://github.com/geerlingguy.png","language":"Jinja","funding_links":["https://github.com/sponsors/geerlingguy","https://patreon.com/geerlingguy"],"categories":["webserver","Ansible roles"],"sub_categories":["Webservers"],"readme":"# Ansible Role: Apache 2.x\n\n[![CI](https://github.com/geerlingguy/ansible-role-apache/actions/workflows/ci.yml/badge.svg)](https://github.com/geerlingguy/ansible-role-apache/actions/workflows/ci.yml)\n\nAn Ansible Role that installs Apache 2.x on RHEL/CentOS, Debian/Ubuntu, SLES and Solaris.\n\n## Requirements\n\nIf you are using SSL/TLS, you will need to provide your own certificate and key files. You can generate a self-signed certificate with a command like `openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout example.key -out example.crt`.\n\nIf you are using Apache with PHP, I recommend using the `geerlingguy.php` role to install PHP, and you can either use mod_php (by adding the proper package, e.g. `libapache2-mod-php5` for Ubuntu, to `php_packages`), or by also using `geerlingguy.apache-php-fpm` to connect Apache to PHP via FPM. See that role's README for more info.\n\n## Role Variables\n\nAvailable variables are listed below, along with default values (see `defaults/main.yml`):\n\n```yaml\napache_enablerepo: \"\"\n```\n\nThe repository to use when installing Apache (only used on RHEL/CentOS systems). If you'd like later versions of Apache than are available in the OS's core repositories, use a repository like EPEL (which can be installed with the `geerlingguy.repo-epel` role).\n\n```yaml\napache_listen_ip: \"*\"\napache_listen_port: 80\napache_listen_port_ssl: 443\n```\n\nThe IP address and ports on which apache should be listening. Useful if you have another service (like a reverse proxy) listening on port 80 or 443 and need to change the defaults.\n\n```yaml\napache_create_vhosts: true\napache_vhosts_filename: \"vhosts.conf\"\napache_vhosts_template: \"vhosts.conf.j2\"\n```\n\nIf set to true, a vhosts file, managed by this role's variables (see below), will be created and placed in the Apache configuration folder. If set to false, you can place your own vhosts file into Apache's configuration folder and skip the convenient (but more basic) one added by this role. You can also override the template used and set a path to your own template, if you need to further customize the layout of your VirtualHosts.\n\n```yaml\napache_remove_default_vhost: false\n```\n\nOn Debian/Ubuntu, a default virtualhost is included in Apache's configuration. Set this to `true` to remove that default virtualhost configuration file.\n\n```yaml\napache_global_vhost_settings: |\n  DirectoryIndex index.php index.html\n  # Add other global settings on subsequent lines.\n```\n\nYou can add or override global Apache configuration settings in the role-provided vhosts file (assuming `apache_create_vhosts` is true) using this variable. By default it only sets the DirectoryIndex configuration.\n\n```yaml\napache_vhosts:\n  # Additional optional properties: 'serveradmin, serveralias, extra_parameters'.\n  - servername: \"local.dev\"\n    documentroot: \"/var/www/html\"\n```\n\nAdd a set of properties per virtualhost, including `servername` (required), `documentroot` (required), `allow_override` (optional: defaults to the value of `apache_allow_override`), `options` (optional: defaults to the value of `apache_options`), `serveradmin` (optional), `serveralias` (optional) and `extra_parameters` (optional: you can add whatever additional configuration lines you'd like in here).\n\nHere's an example using `extra_parameters` to add a RewriteRule to redirect all requests to the `www.` site:\n\n```yaml\n- servername: \"www.local.dev\"\n  serveralias: \"local.dev\"\n  documentroot: \"/var/www/html\"\n  extra_parameters: |\n    RewriteCond %{HTTP_HOST} !^www\\. [NC]\n    RewriteRule ^(.*)$ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]\n```\n\nThe `|` denotes a multiline scalar block in YAML, so newlines are preserved in the resulting configuration file output.\n\n```yaml\napache_vhosts_ssl: []\n```\n\nNo SSL vhosts are configured by default, but you can add them using the same pattern as `apache_vhosts`, with a few additional directives, like the following example:\n\n```yaml\napache_vhosts_ssl:\n  - servername: \"local.dev\"\n    documentroot: \"/var/www/html\"\n    certificate_file: \"/home/vagrant/example.crt\"\n    certificate_key_file: \"/home/vagrant/example.key\"\n    certificate_chain_file: \"/path/to/certificate_chain.crt\"\n    extra_parameters: |\n      RewriteCond %{HTTP_HOST} !^www\\. [NC]\n      RewriteRule ^(.*)$ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]\n```\n\nOther SSL directives can be managed with other SSL-related role variables.\n\n```yaml\napache_ssl_no_log: true\n```\n\nWhether to print SSL-related task output to the console when running the playbook.\n\n```yaml\napache_ssl_protocol: \"All -SSLv2 -SSLv3\"\napache_ssl_cipher_suite: \"AES256+EECDH:AES256+EDH\"\n```\n\nThe SSL protocols and cipher suites that are used/allowed when clients make secure connections to your server. These are secure/sane defaults, but for maximum security, performand, and/or compatibility, you may need to adjust these settings.\n\n```yaml\napache_allow_override: \"All\"\napache_options: \"-Indexes +FollowSymLinks\"\n```\n\nThe default values for the `AllowOverride` and `Options` directives for the `documentroot` directory of each vhost.  A vhost can overwrite these values by specifying `allow_override` or `options`.\n\n```yaml\napache_mods_enabled:\n  - rewrite\n  - ssl\napache_mods_disabled: []\n```\n\nWhich Apache mods to enable or disable (these will be symlinked into the appropriate location). See the `mods-available` directory inside the apache configuration directory (`/etc/apache2/mods-available` on Debian/Ubuntu) for all the available mods.\n\n```yaml\napache_packages:\n  - [platform-specific]\n```\n\nThe list of packages to be installed. This defaults to a set of platform-specific packages for RedHat or Debian-based systems (see `vars/RedHat.yml` and `vars/Debian.yml` for the default values).\n\n```yaml\napache_state: started\n```\n\nSet initial Apache daemon state to be enforced when this role is run. This should generally remain `started`, but you can set it to `stopped` if you need to fix the Apache config during a playbook run or otherwise would not like Apache started at the time this role is run.\n\n```yaml\napache_enabled: yes\n```\n\nSet the Apache service boot time status. This should generally remain `yes`, but you can set it to `no` if you need to run Ansible while leaving the service disabled.\n\n```yaml\napache_packages_state: present\n```\n\nIf you have enabled any additional repositories such as _ondrej/apache2_, [geerlingguy.repo-epel](https://github.com/geerlingguy/ansible-role-repo-epel), or [geerlingguy.repo-remi](https://github.com/geerlingguy/ansible-role-repo-remi), you may want an easy way to upgrade versions. You can set this to `latest` (combined with `apache_enablerepo` on RHEL) and can directly upgrade to a different Apache version from a different repo (instead of uninstalling and reinstalling Apache).\n\n```yaml\napache_ignore_missing_ssl_certificate: true\n```\n\nIf you would like to only create SSL vhosts when the vhost certificate is present (e.g. when using Let’s Encrypt), set `apache_ignore_missing_ssl_certificate` to `false`. When doing this, you might need to run your playbook more than once so all the vhosts are configured (if another part of the playbook generates the SSL certificates).\n\n## .htaccess-based Basic Authorization\n\nIf you require Basic Auth support, you can add it either through a custom template, or by adding `extra_parameters` to a VirtualHost configuration, like so:\n\n```yaml\n    extra_parameters: |\n      \u003cDirectory \"/var/www/password-protected-directory\"\u003e\n        Require valid-user\n        AuthType Basic\n        AuthName \"Please authenticate\"\n        AuthUserFile /var/www/password-protected-directory/.htpasswd\n      \u003c/Directory\u003e\n```\n\nTo password protect everything within a VirtualHost directive, use the `Location` block instead of `Directory`:\n\n```\n\u003cLocation \"/\"\u003e\n  Require valid-user\n  ....\n\u003c/Location\u003e\n```\n\nYou would need to generate/upload your own `.htpasswd` file in your own playbook. There may be other roles that support this functionality in a more integrated way.\n\n## Dependencies\n\nNone.\n\n## Example Playbook\n\n```yaml\n- hosts: webservers\n  vars_files:\n    - vars/main.yml\n  roles:\n    - { role: geerlingguy.apache }\n```\n\n*Inside `vars/main.yml`*:\n\n```yaml\napache_listen_port: 8080\napache_vhosts:\n  - {servername: \"example.com\", documentroot: \"/var/www/vhosts/example_com\"}\n```\n\n## License\n\nMIT / BSD\n\n## Author Information\n\nThis role was created in 2014 by [Jeff Geerling](https://www.jeffgeerling.com/), author of [Ansible for DevOps](https://www.ansiblefordevops.com/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeerlingguy%2Fansible-role-apache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgeerlingguy%2Fansible-role-apache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeerlingguy%2Fansible-role-apache/lists"}