ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • Ansible: web server + php7.3 배포 및 구성
    공부합시다!/Ansible 2022. 7. 8. 10:05
    728x90

    항상 목표가 wordpress + db를 연동하는 것입니다.

    그 이후의 작업은 스스로 심도 있게 공부하셔야 합니다.

    오늘은 apache web server 설치와 php 7.2 구성입니다.

    이 부분 이전 Linux 작업 내용을 참조하시면 도움이 됩니다.

    왜 그리 열심히 스크립트를 작성했는지....

    2022.04.05 - [공부합시다!/LInux] - CenTOS7 : WordPress + MySQL5.7 + PHP7.3 Install

     

    ---
      - name: Wordpress Install & Configuration
        hosts: web
        gather_facts: false
        ignore_errors: true
      
        tasks:
        - name: yum install http
          yum:
            name: httpd
            state: present
      
        - name: enable php7.2
          yum: 
            name:
            - wget
            - epel-release
            - yum-utils
            - http://rpms.remirepo.net/enterprise/remi-release-7.rpm
          shell:
            cmd: 'yum-config-manager --enable remi-php73'
      
        - name: yum install php* mariadb
          yum:
            name:
              - php-cli
              - php-opcache
              - php-mcrypt
              - php-gd
              - php-mysqlnd
              - php-curl
              - php
              - php-common
            state: present
      
        - name: get_url wordpress
          get_url:
            url: 'https://ko.wordpress.org/wordpress-5.8.2-ko_KR.tar.gz'
            dest: './'
      
        - name: unarchive
          unarchive:
            src: './wordpress-5.8.2-ko_KR.tar.gz'
            dest: './'
            remote_src: yes
      
        - name: wordpress file copy dest /var/www/html
          copy:
            src: '/root/wordpress/'
            dest: '/var/www/html/'
            remote_src: yes
            #    shell: 'cp -a /root/wordpress/* /var/www/html/'
      
        - name: chown
          #    file:
          #      path: '/var/www/html/*'
          #      owner: apache
          #      group: apache
          shell:
            cmd: 'chown -R apache.apache /var/www/html/'
      
        - name: file copy wp-config.php
          copy:
            src: '/var/www/html/wp-config-sample.php'
            dest: '/var/www/html/wp-config.php'
            remote_src: yes
      
        - name: change syntax DirectoryIndex
          replace:
            path: '/etc/httpd/conf/httpd.conf'
            regexp: 'DirectoryIndex index.html'
            replace: 'DirectoryIndex index.php'
      
        - name: change syntax database_name_here
          replace:
            path: '/var/www/html/wp-config.php'
            regexp: 'database_name_here'
            replace: 'mydb'
      
        - name: change syntax username_here
          replace:
            path: '/var/www/html/wp-config.php'
            regexp: 'username_here'
            replace: 'admin'
      
        - name: change syntax password_here
          replace:
            path: '/var/www/html/wp-config.php'
            regexp: 'password_here'
            replace: 'It12345!'
      
        - name: change syntax localhost
          replace:
            path: '/var/www/html/wp-config.php'
            regexp: 'localhost'
            replace: 'mydb.cqep7uwq9udb.ap-northeast-2.rds.amazonaws.com'
      
        - name: make file
          file:
            path: '/var/www/html/health.html'
            state: touch
      
        - name: copy contents
          copy:
            content: |
              <html>
              <body>
              <h1>SDKIM_WEBSERVER-1</h1>
              </body>
              <html>
            dest: '/var/www/html/health.html'
      
        - name: systemctl start httpd & systemctl enable httpd
          systemd:
            name: httpd
            state: started
            enabled: yes

     

     

    잘 된거 같네요!

     

    Have a nice day!

     

    728x90
Designed by Tistory.