nginx + wordpress
2023. 6. 18. 03:00ㆍAnsible_ad-hoc
728x90
반응형
---
- name: nginx & wordpress & php-fpm
hosts: nginx
tasks:
- name: package install
yum:
name:
- wget
- yum-utils
- epel-release
state: present
ignore_errors: yes
- name: nginx package install
yum:
name: nginx
state: present
ignore_errors: yes
- name: url download wordpress
get_url:
url: https://ko.wordpress.org/wordpress-5.8.6-ko.KR.tar.gz
dest: ./
- name: archive & unzip
unarchive:
src: wordpress-5.8.6.-ko_KR.tar.gz
dest: ./
remote_src: yes
- name: copy wordpress file
copy:
src: ./wordpress/
dest: /usr/share/nginx/html/
remote_src: yes
- name: wp-config.php
copy:
src: /usr/share/nginx/html/wp-config-sample.php
dest: /usr/share/nginx/html/wp-config.php
remote_src: yes
- name: php repository install
yum:
name: http://rpms.remirepo.net/enterprise/remi-release-7.rpm
state: present
ignore_errors: yes
- name: enable php7.4
shell: yum-config-manager --enable remi-php74
- name: php7.4 install
yum:
name:
- php
- php-cli
- php-curl
- php-mcrypt
- php-common
- php-mysqlnd
- php-gd
- php-fpm
state: present
- name: www.conf fixed
lineinfile:
path /etc/php-fpm.d/www.conf
regexp: "{{ item.src }}"
line: " {{ item.dest }}"
loop:
-{ src: 'user = apache', dest: 'user = nginx' }
-{ src: 'group = apache', dest: 'group = nginx' }
-{ src: 'listen.owner = nobody', dest: 'listen.owner = nginx' }
-{ src: 'listen.group = nobody', dest: 'listen.group = nginx' }
-{ src: 'listen = 127.0.0.1:9000', dest: 'listen = /run/php-fpm/www.sock' }
- name: nginx.conf fixed
blockinfile:
path: /etc/nginx/nginx.conf
insertbefore: '^(\s+error_page+\s)404 /404.html;'
block: |
##
location ~ \.php$ {
try_files $uri=404;
fastcgi_pass unix:/run/php-fpm/www.sock;
fastcgi_index index.php;
fastcgi_param SCrIpt_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
- name: wp-config.php fixed
replace:
path: /usr/share/nginx/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: start php-fpm, nginx
systemd:
name: "{{ item }}"
state: started
enabled: yes
loop:
- php-fpm
- nginx
- name: port 80 open
firewalld:
port: 80/tcp
state: enabled
permanent: yes
immediate: yes
참고 사이트:
반응형
'Ansible_ad-hoc' 카테고리의 다른 글
DHCP, VSFTPD, Nginx. DNS, Infra 자동화 (0) | 2023.06.17 |
---|---|
ssh key 자동배포 (0) | 2023.06.17 |
Ad-hoc & Inventory (1) | 2023.06.17 |
CentOS7 - Wordpress + MySQL5.7 + PHP7.3 Install (1) | 2023.06.17 |
RDS 배포 및 구성-yml 파일 (0) | 2023.06.17 |