Haproxy, Apache, Wordpress
2023. 6. 17. 14:11ㆍ카테고리 없음
728x90
반응형
Haproxy, apache web server 동일 node에 구성
Haproxy 80, Web Server 8080 port 사용
---
- name: Wordpress download & install, php7.4 install
hosts: was 1
tasks:
- name wget, httpd, php repository, php7.4 repo install
yum:
name: "{{ item }}"
state: present
loop:
- wget
- httpd
- yum-utils
- epel-release
- http://rpms.remirepo.net/enterprise/remi-release-7.rpm
- haproxy
- name: yum-config-manager config
shell: yum-config-manager --enable remi-php74
- name: php7.4 install
yum:
name: "{{ packages }}"
vars:
packages:
- php
- php-common
- php-opcache
- php-mcrypt
- php-cli
- php-gd
- php-curl
- php-mysqlnd
- name: url use file download
get_url:
url: htpps://ko.wordpress.org/wordpress-5.8.6-ko_KR.tar.gz
dest: ./
- name: unarcive
unarchive:
src: wordpress-5.8.6-ko_KR.tar.gz
dest: ./
remote_src: yes
- name index.htmlchange index.php
lineinfile:
path: /etc/httpd/conf/httpd.conf
regexp: "{{ item.src }}"
line: "{{ item.dest }}"
loop:
- { src: 'DirectoryIndex index.html', dest: 'DirectoryIndex index.php }
- { src: 'Listen 80', dest: 'Listen 8080' }
- name: wordpress directoryall file copy to /var/www/html
copy:
src: "{{ item.src }}"
dest: "{{ itemdest }}"
remote_src: yes
loop:
- { src: './wordpress/', dest: '/var/www/html/' }
- { src: '/var/www/html/wp-config-sample.php', dest: '/var/www/html/wp-config.php' }
- name: wp-config file change
replace:
path /var/www/html/wp-config.php
regexp: "{{ item.src }}"
replace "{{ item.dest }}"
loop:
- {src: 'database_name_here", dest: 'wordpress' }
- {src: 'username_here", dest: 'root' }
- {src: 'password_here', dest: 'It12345@' }
- {src: 'localhost', dest: '10.0.0.4' }
- name: haproxy.cfg line delete
lineinfile:
path: /tec/haproxy/haproxy.cfg
regexp: "{{ item.src }}"
line: "{{ item.dest }}"
loop:
- {src: '127.0.0.1:5003', dest:'#'}
- {src: '127.0.0.1:5004', dest:'#'}
- name: httpd service start
service:
name: "{{ item }}"
state: started
loop:
- httpd
- haproxy
- name: httpd firewall open
firewalld:
port: "{{ item }}"
state: enabled
loop:
- 80/tcp
- 8080/tcp
참조사이트
https://virtualtech.tistory.com/563
Ansible: HAPROXY + Apache + Wordpress
Haproxy와 apache web server를 동일 node에 구성하는 예제입니다. haproxy는 80 port를 web server는 8080 port를 사용합니다. 1. code --- - name: wordpress download & install, php7.4 install hosts: was1 tasks: - name: wget, httpd, php repo
virtualtech.tistory.com
반응형