gcoop-libre.apache
Apache 2.x
This is an Ansible Role that installs Apache 2.x on various systems like RHEL/CentOS, Debian/Ubuntu, SLES, and Solaris.
Requirements
This role does not handle SSL/TLS certificate and key files.
If you want to use Apache with PHP, you can include PHP packages in the apache_packages
variable. Alternatively, you can use other roles like geerlingguy.php
or geerlingguy.apache-php-fpm
if you prefer using PHP with FPM.
Role Variables
Here are the available variables and their default values (see defaults/main.yml
):
apache_enablerepo: '' The repository for installing Apache (only for RHEL/CentOS). If you want newer versions of Apache, use a repository like EPEL.
apache_listen_ip: '*'
apache_listen_port: 80
apache_listen_port_ssl: 443 Set the IP address and ports for Apache to listen on. Change these if you have another service on the same ports.
apache_keepalive: true
apache_keepalive_requests: 500
apache_keepalive_timeout: 5 Enable HTTP persistent connections with customizable timeout and max requests.
apache_prefork_server_limit: 256
apache_prefork_start_servers: 5
apache_prefork_min_spare_servers: 5
apache_prefork_max_spare_servers: 10
apache_prefork_max_clients: 256
apache_prefork_max_requests_per_child: 0 Configure settings for the MPM Prefork and Worker modules.
apache_worker_server_limit: 16 (for Apache 2.4 on Debian)
apache_worker_start_servers: 3
apache_worker_min_spare_threads: 75
apache_worker_max_spare_threads: 250
apache_worker_max_clients: 400
apache_worker_max_requests_per_child: 0
apache_worker_thread_limit: 64
apache_worker_threads_per_child: 25
apache_event_server_limit: 16 (for Apache 2.4 on Debian)
apache_event_start_servers: 3
apache_event_min_spare_threads: 75
apache_event_max_spare_threads: 250
apache_event_max_clients: 400
apache_event_max_requests_per_child: 0
apache_event_thread_limit: 64
apache_event_threads_per_child: 25
apache_remove_default_aliases: True Remove default aliases from Apache's settings.
apache_base_dir: '/var/www' Base directory for web files.
apache_web_subdir: 'web'
apache_ssl_subdir: 'ssl'
apache_private_subdir: 'private' Define subdirectories for HTTP, HTTPS, and private files.
apache_create_vhosts: true
apache_vhosts_filename: 'vhosts.conf' Create a global virtual hosts configuration file if set to true.
apache_remove_default_vhost: false Remove the default virtual host on Debian/Ubuntu.
apache_global_vhost_settings: | DirectoryIndex index.php index.html
Additional settings can go here.
apache_global_vhost_access_log_format_combined: '%h %l %u %t "%r" %>s %O "%{Referer}i" "%{User-Agent}i"'
apache_global_vhost_access_log_format_proxy: '%{X-Forwarded-For}i %l %u %t "%r" %>s %O "%{Referer}i" "%{User-Agent}i"' Customize log formats.
apache_global_vhost_aliases:
- name: /images dest: /var/www/images Add global aliases for virtual hosts.
apache_global_vhost_custom_errors:
- code: error-code action: error-action Customize Apache error pages.
apache_vhosts:
- servername: 'local.dev'
serveralias:
- 'alias1.local'
- 'alias2.local' serveradmin: webmaster@localhost documentroot: '/var/www/html' enabled: true separate_logs: true ... (other properties)
Add properties for each virtual host, requiring at least a
servername
.- servername: 'local.dev'
serveralias:
apache_vhosts_ssl: [] Add SSL virtual hosts with similar properties to the regular vhosts.
apache_vhosts_ordered: False Control the loading order of virtual hosts.
apache_ssl_protocol: 'All -SSLv2 -SSLv3'
apache_ssl_cipher_suite: 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH' Set secure SSL protocols and ciphers.
apache_frame_options: SAMEORIGIN Control frame loading security policy.
apache_sts: true Enable HTTP Strict Transport Security.
apache_mods_enabled:
- rewrite
- ssl
apache_packages:
- [platform-specific] List of packages to install based on the platform.
apache_state: started Control the initial state of the Apache service.
apache_ignore_missing_ssl_certificate: true Control whether to create SSL vhosts only if certificates are present.
Dependencies
None.
Example Playbook
- hosts: webservers
vars_files:
- vars/main.yml
roles:
- gcoop-libre.apache
Inside vars/main.yml
:
apache_listen_port: 8080
apache_vhosts:
- servername: example.com
License
GPLv2
Author Information
This role was created in 2016 by gcoop Cooperativa de Software Libre.
Apache 2.x for RHEL/CentOS, Debian/Ubuntu, SLES and Solaris
ansible-galaxy install gcoop-libre.apache