http_apache.yml 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. ---
  2. - name: "[APACHE] - enable APC for php CLI"
  3. ansible.builtin.lineinfile:
  4. dest: "{{ php_dir }}/cli/php.ini"
  5. line: "apc.enable_cli = 1"
  6. insertbefore: "^; End:$"
  7. state: present
  8. # validate: "/usr/sbin/{{ php_bin }} -t #%s"
  9. - name: "[APACHE] - enable PHP OPcache for php.ini"
  10. ansible.builtin.lineinfile:
  11. dest: "{{ php_dir }}/apache2/php.ini"
  12. state: present
  13. regexp: "{{ item.regexp }}"
  14. line: "{{ item.line }}"
  15. backrefs: true
  16. with_items:
  17. - {regexp: 'opcache.enable=0', line: 'opcache.enable=1'}
  18. - {regexp: 'opcache.enable_cli', line: 'opcache.enable_cli=1'}
  19. - {regexp: 'opcache.interned_strings_buffer', line: 'opcache.interned_strings_buffer=8'}
  20. - {regexp: 'opcache.max_accelerated_files', line: 'opcache.max_accelerated_files=10000'}
  21. - {regexp: 'opcache.memory_consumption', line: 'opcache.memory_consumption=128'}
  22. - {regexp: 'opcache.save_comments', line: 'opcache.save_comments=1'}
  23. - {regexp: 'opcache.revalidate_freq', line: 'opcache.revalidate_freq=1'}
  24. - {regexp: 'memory_limit', line: 'memory_limit={{ php_memory_limit }}'}
  25. # validate: "/usr/sbin/{{ php_bin }} -t #%s"
  26. notify: reload http
  27. - name: "[APACHE] - Required Apache2 modules are enabled"
  28. apache2_module:
  29. name: "{{ item }}"
  30. state: present
  31. with_items:
  32. - rewrite
  33. - headers
  34. - env
  35. - dir
  36. - mime
  37. notify: restart http
  38. - name: "[APACHE] - Ssl Apache2 module is enabled"
  39. apache2_module:
  40. state: present
  41. name: "{{ item }}"
  42. with_items:
  43. - ssl
  44. when: (nextcloud_install_tls | bool)
  45. notify: restart http
  46. - name: "[APACHE] - generate Nextcloud configuration for apache"
  47. ansible.builtin.template:
  48. dest: /etc/apache2/sites-available/nc_{{ nextcloud_instance_name }}.conf
  49. src: "{{ nextcloud_websrv_template }}"
  50. mode: 0640
  51. notify: reload http
  52. - name: "[APACHE] - Enable Nextcloud site in apache conf"
  53. ansible.builtin.file:
  54. path: /etc/apache2/sites-enabled/nc_{{ nextcloud_instance_name }}.conf
  55. src: /etc/apache2/sites-available/nc_{{ nextcloud_instance_name }}.conf
  56. state: link
  57. notify: reload http
  58. - name: "[APACHE] - Disable apache default site"
  59. ansible.builtin.file:
  60. path: /etc/apache2/sites-enabled/000-default.conf
  61. state: absent
  62. when: nextcloud_disable_websrv_default_site | bool
  63. notify: reload http