-
Ansible: nginx + wordpress공부합시다!/Ansible 2023. 6. 14. 17:31728x90
nginx + wordpress
1. code
--- - 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-sample.php -> 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-opcache - 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: | # babo index index.php; 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: systemd: name: "{{ item }}" state: started enabled: yes loop: - php-fpm - nginx - name: firewalld: port: 80/tcp state: enabled permanent: yes immediate: yes
2. 작성코드
728x90'공부합시다! > Ansible' 카테고리의 다른 글
Ansible: apache + nginx + mysql + haproxy + dns (0) 2023.09.05 Ansible: HAPROXY + Apache + Wordpress (0) 2023.06.14 Ansible: RDS 배포 및 구성, 2023년 03월 17일 Test (0) 2023.03.17 Ansible: DHCP, VSFTPD, Nginx, DNS Infra 자동화 (0) 2023.03.17 Ansible : Nginx Install, Configuration (0) 2023.03.16