Add apache configuration tasks

This commit is contained in:
phil 2023-08-16 20:51:05 +02:00
parent 1dff8396d7
commit ba0a279b4f
4 changed files with 49 additions and 1 deletions

View file

@ -1,2 +1,5 @@
---
# handlers file for .
- name: Reload apache2
ansible.builtin.service:
name: apache2
state: reloaded

14
tasks/apache.yml Normal file
View file

@ -0,0 +1,14 @@
---
- name: "Apache | Copy virtualhost configuration"
ansible.builtin.template:
src: apache2.conf.j2
dest: "/etc/apache2/sites-available/{{ dmarcsrg_domain }}.conf"
mode: "0644"
notify: Reload apache2
- name: "Apache | Enable virtualhost configuration"
ansible.builtin.file:
src: "/etc/apache2/sites-available/{{ dmarcsrg_domain }}.conf"
dest: "/etc/apache2/sites-enabled/{{ dmarcsrg_domain }}.conf"
state: link
notify: Reload apache2

View file

@ -14,3 +14,7 @@
- name: Configure PHP-FPM
ansible.builtin.import_tasks: phpfpm.yml
tags: phpfpm
- name: Apache
ansible.builtin.import_tasks: apache.yml
tags: apache

27
templates/apache.conf.j2 Normal file
View file

@ -0,0 +1,27 @@
<VirtualHost *:80>
ServerName {{ dmarcsrg_domain }}
DocumentRoot {{ dmarcsrg_home }}/current
ErrorLog /var/log/apache2/{{ dmarcsrg_domain }}.error
<FilesMatch ".+\.ph(ar|p|tml)$">
SetHandler "proxy:unix:/run/php/php-fpm-{{ dmarcsrg_user}}.sock|fcgi://dmarcsrg"
</FilesMatch>
<FilesMatch ".+\.phps$">
Require all denied
</FilesMatch>
<FilesMatch "^\.ph(ar|p|ps|tml)$">
Require all denied
</FilesMatch>
<Directory {{ dmarcsrg_home }}/current>
DirectoryIndex index.php
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
<DirectoryMatch "^/{{ dmarcsrg_home }}/current/(classes|config|tests|utils)/*">
Options None
Require all denied
</DirectoryMatch>
</VirtualHost>