solution abr
This commit is contained in:
71
apache.yml
Normal file
71
apache.yml
Normal file
@@ -0,0 +1,71 @@
|
||||
---
|
||||
- name: install apache via ansible playbook
|
||||
hosts: centos
|
||||
handlers:
|
||||
- name: restart apache
|
||||
service:
|
||||
name: httpd
|
||||
state: restarted
|
||||
|
||||
tasks:
|
||||
- name: install apache
|
||||
yum:
|
||||
name: httpd
|
||||
state: latest
|
||||
|
||||
- name: conf httpd
|
||||
template:
|
||||
src: vhost.conf
|
||||
dest: /etc/httpd/conf.d/vhost.conf
|
||||
mode: 0640
|
||||
owner: root
|
||||
group: apache
|
||||
notify: restart apache
|
||||
|
||||
- name: call handlers, if needed
|
||||
ansible.builtin.meta: flush_handlers
|
||||
|
||||
- name: activate apache
|
||||
service:
|
||||
name: httpd
|
||||
enabled: yes
|
||||
state: started
|
||||
|
||||
- name: open firewall port
|
||||
firewalld:
|
||||
service: http
|
||||
permanent: yes
|
||||
immediate: yes
|
||||
state: enabled
|
||||
ignore_errors: yes
|
||||
|
||||
- name: create documentroot
|
||||
file:
|
||||
name: /var/www/html/example.org
|
||||
state: directory
|
||||
|
||||
- name: create index file
|
||||
copy:
|
||||
src: index.txt
|
||||
dest: /var/www/html/example.org/index.html
|
||||
mode: 0644
|
||||
|
||||
- name: install php
|
||||
block:
|
||||
- name: php install
|
||||
package:
|
||||
name: php-fpm
|
||||
state: present
|
||||
|
||||
- name: php service
|
||||
service:
|
||||
name: php-fpm
|
||||
state: started
|
||||
enabled: true
|
||||
|
||||
- name: php config
|
||||
copy:
|
||||
src: php-fpm.conf
|
||||
dest: /etc/httpd/conf.d/
|
||||
notify: restart apache
|
||||
when: apache_use_php| default( false )
|
||||
1
index.txt
Normal file
1
index.txt
Normal file
@@ -0,0 +1 @@
|
||||
<span style="text-align: center;background-color: #FD5401; font-size: 42px;">Hello World</span>
|
||||
3
php-fpm.conf
Normal file
3
php-fpm.conf
Normal file
@@ -0,0 +1,3 @@
|
||||
<FilesMatch \.php$>
|
||||
SetHandler proxy:fcgi://localhost:9000
|
||||
</FilesMatch>
|
||||
16
vhost.conf
Normal file
16
vhost.conf
Normal file
@@ -0,0 +1,16 @@
|
||||
<VirtualHost *:80>
|
||||
ServerName example.org
|
||||
ServerAlias www.example.org
|
||||
DocumentRoot /var/www/html/example.org/
|
||||
CustomLog /var/log/httpd/example.org_access.log combined
|
||||
ErrorLog /var/log/httpd/example.org_error.log
|
||||
<Directory />
|
||||
Options none
|
||||
Allowoverride none
|
||||
Require all denied
|
||||
</Directory>
|
||||
|
||||
<Directory /var/www/html/example.org>
|
||||
Require all granted
|
||||
</Directory>
|
||||
</VirtualHost>
|
||||
Reference in New Issue
Block a user