Added php to nginx-webserver
This commit is contained in:
parent
5108efea23
commit
ec0a1adc01
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
# handlers file for nginx-webserver
|
# handlers file for nginx-webserver
|
||||||
- name: restart nginx
|
- name: reload nginx
|
||||||
ansible.builtin.service:
|
ansible.builtin.service:
|
||||||
name: nginx
|
name: nginx
|
||||||
state: restarted
|
state: restarted
|
||||||
|
@ -1,13 +1,34 @@
|
|||||||
---
|
---
|
||||||
# tasks file for nginx-webserver
|
# tasks file for nginx-webserver
|
||||||
- name: Install nginx
|
- name: Install nginx and php
|
||||||
package:
|
package:
|
||||||
name: nginx
|
name:
|
||||||
|
- nginx
|
||||||
|
- php7.4
|
||||||
|
- php7.4-fpm
|
||||||
|
- php7.4-cli
|
||||||
state: present
|
state: present
|
||||||
update_cache: yes
|
update_cache: yes
|
||||||
become: true
|
become: true
|
||||||
notify: restart nginx
|
- name: Copy over nginx.conf
|
||||||
- name: Copy over index.html
|
ansible.builtin.template:
|
||||||
|
src: ./templates/nginx.cfg.j2
|
||||||
|
dest: /etc/nginx/sites-available/nginx.cfg
|
||||||
|
become: true
|
||||||
|
notify: reload nginx
|
||||||
|
- name: Enable nginx.conf
|
||||||
|
file:
|
||||||
|
src: /etc/nginx/sites-available/nginx.cfg
|
||||||
|
dest: /etc/nginx/sites-enabled/default
|
||||||
|
state: link
|
||||||
|
become: true
|
||||||
|
notify: reload nginx
|
||||||
|
- name: Remove nginx default crap
|
||||||
|
file:
|
||||||
|
state: absent
|
||||||
|
path: /var/www/html/*
|
||||||
|
become: true
|
||||||
|
- name: Copy over index.php
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
src: ./templates/index.php.j2
|
src: ./templates/index.php.j2
|
||||||
dest: /var/www/html/index.php
|
dest: /var/www/html/index.php
|
||||||
|
15
roles/nginx-webserver/templates/nginx.cfg.j2
Normal file
15
roles/nginx-webserver/templates/nginx.cfg.j2
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
|
||||||
|
root /var/www/html;
|
||||||
|
index index.php;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/ =404;
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~ \.php$ {
|
||||||
|
include snippets/fastcgi-php.conf;
|
||||||
|
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user