• nginx+php 完成 kod云搭建(ansible使用变量)


    nginx+php 完成 kod云搭建(ansible使用变量)

    [root@m01 project1]# vim kod.yml
    - hosts: web
    #1.卸载php低版本
    #2.安装nginx1.12 php5.4
      tasks:
        - name: Installed Nginx
          yum: name=nginx,php,php-fpm,php-pdo,php-gd,php-mbstring state=present
    #4.创建组和用户 www
        - name: Create Group {{ web_user }}
          group: name={{ web_user }} gid=666 state=present
    
        - name: Create User {{ web_user }}
          user: name={{ web_user }} uid=666 group=666 shell=/sbin/nologin state=present
    
    #5.配置nginx -->nginx.conf  指定运行的用户身份www
    #6.配置nginx.conf.d/kod.conf 虚拟主机
        - name: Configure Virtual {{ nginx_virt }}
          template: src=./kod.conf.j2 dest={{ nginx_virt }}/kod.conf backup=yes
    
    #7.根据虚拟主机的配置创建存放代码的目录
        - name: Create Kod {{ nginx_code }} Directory
          file: path={{ nginx_code }} state=directory
    
    #8.拷贝kod云的代码.解压
        - name: Unzip Kod {{ nginx_code }} Directory
          unarchive: src=./backup/kodexplorer4.40.zip dest={{ nginx_code }}
        
    #9.授权目录的权限
        - name: Chown Kod Data {{ web_user }}
          file: path={{ nginx_code }} owner={{ web_user }} group={{ web_user }} recurse=yes mode=0777
    
    #7.配置php-fpm 管理php的用户身份
        - name: Configure PHP-FPM {{ php_fpm_conf }}
          template: src=./php_www.conf.j2 dest={{ php_fpm_conf }}
    
    #8.配置php程序,php.ini 调整可道云上传的大小
        - name: Configure PHP Server {{ php_ini_conf }}
          template: src=./php.ini.j2 dest={{ php_ini_conf }}
    
    #9.测试nginx 和php的配置文件是否正确,正确则启动
        - name: Service Nginx Server
          service: name=nginx state=started enabled=yes
    
        - name: Service PHP-FPM Server
          service: name=php-fpm state=started enabled=yes
    
    
    [root@web01 conf.d]# mkdir /ansible_code
    [root@web01 ~]# scp /etc/nginx/nginx.conf root@172.16.1.61:/root/project1
    root@172.16.1.61's password: 
    nginx.conf                                                     100%  642   309.8KB/s   00:00    
    [root@m01 project1]# mv nginx.conf nginx.conf.j2
    
    [root@web01 ~]# scp /etc/php.ini root@172.16.1.61:/root/project1/php.ini.j2
    root@172.16.1.61's password: 
    php.ini                                                        100%   61KB   8.8MB/s   00:00    
    [root@web01 ~]# scp /etc/php-fpm.d/www.conf root@172.16.1.61:/root/project1/php_www.conf.j2
    root@172.16.1.61's password: 
    www.conf                                                       100%   18KB   3.1MB/s   00:00    
    [root@m01 project1]# vim group_vars/all
    web_user: www
    nginx_conf: /etc/nginx/nginx.conf
    nginx_virt: /etc/nginx/conf.d
    nginx_code: /ansible_code
    php_fpm_conf: /etc/php-fpm.d/www.conf
    php_ini_conf: /etc/php.ini
    php_ini_max_uploads: 200M
    
    [root@m01 project1]# vim kod.conf.j2 
    
    server {
            listen 80;
            server_name kod.oldboy.com;
            root /ansible_code;
    
            location / {
                index index.php index.html;
            }
            location ~ .php$ {
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_param HTTPS on;
                include fastcgi_params;
            }
    }
    
    ##执行kod.yml
    [root@m01 project1]# ansible-playbook kod.yml -i hosts
    
    PLAY [web] ***********************************************************************************************
    
    TASK [Gathering Facts] ***********************************************************************************
    ok: [172.16.1.7]
    ok: [172.16.1.8]
    
    TASK [installed nginx] ***********************************************************************************
    ok: [172.16.1.7]
    ok: [172.16.1.8]
    
    TASK [create group] **************************************************************************************
    ok: [172.16.1.7]
    ok: [172.16.1.8]
    
    TASK [create user] ***************************************************************************************
    ok: [172.16.1.7]
    ok: [172.16.1.8]
    
    TASK [configure nginx /etc/nginx/nginx.conf] *************************************************************
    ok: [172.16.1.8]
    ok: [172.16.1.7]
    
    TASK [configure virtual /etc/nginx/conf.d] ***************************************************************
    ok: [172.16.1.8]
    ok: [172.16.1.7]
    
    TASK [Create Kod /ansible_code Directory] ****************************************************************
    ok: [172.16.1.7]
    ok: [172.16.1.8]
    
    TASK [Unzip Kod /ansible_code Directory] *****************************************************************
    changed: [172.16.1.7]
    changed: [172.16.1.8]
    
    TASK [chown kod data www] ********************************************************************************
    changed: [172.16.1.7]
    changed: [172.16.1.8]
    
    TASK [configure php-fpm /etc/php-fpm.d/www.conf] *********************************************************
    changed: [172.16.1.8]
    changed: [172.16.1.7]
    
    TASK [configure php server /etc/php.ini] *****************************************************************
    ok: [172.16.1.7]
    changed: [172.16.1.8]
    
    TASK [service nginx server] ******************************************************************************
    ok: [172.16.1.7]
    ok: [172.16.1.8]
    
    TASK [service php-fpm server] ****************************************************************************
    ok: [172.16.1.7]
    changed: [172.16.1.8]
    
    PLAY RECAP ***********************************************************************************************
    172.16.1.7                 : ok=13   changed=3    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
    172.16.1.8                 : ok=13   changed=5    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
      
      
    
  • 相关阅读:
    C和C++的不同点
    音频质量评价指标
    常用函数整理
    Subband Decomposition
    Stability Analysis of Algorithms
    Time Frequency (T-F) Masking Technique
    雅克比(Jacobi)方法
    寒假3
    寒假作业二
    寒假 2
  • 原文地址:https://www.cnblogs.com/longren/p/11051984.html
Copyright © 2020-2023  润新知