zoukankan      html  css  js  c++  java
  • ansible安装Nginx

    环境:Centos 7.x

    独立nginx.conf配置文件

    [root@master playbook]# tree nginx/
    nginx/
    ├── nginx.conf
    └── nginx.yml
    

    nginx.yml配置文件:

    - hosts: localhost
      vars:
        - nginx_version: 1.12.2
        - nginx_user: www
      tasks:
        - name: add nginx run user
          user: name={{ nginx_user }}
        - name: nginx dependence
          yum: name={{ item }} state=latest
          with_items:
            - openssl-devel
            - pcre-devel
            - zlib-devel
            - gcc-c++
            - wget
        - name: download nginx-{{ nginx_version }}.tar.gz
          get_url:
            url: http://nginx.org/download/nginx-{{ nginx_version }}.tar.gz
            dest: "{{ lookup('env','HOME') }}/nginx-{{ nginx_version }}.tar.gz"
        - name: install nginx
          shell: cd {{ lookup('env','HOME') }};tar -xf nginx-{{ nginx_version }}.tar.gz;cd nginx-{{ nginx_version }};./configure --user={{ nginx_user }} --group={{ nginx_user }} --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre --with-http_realip_module;make -j`grep processor /proc/cpuinfo |wc -l`&& make install
        - name: copy conf file nginx.conf
          template: src=nginx.conf dest=/usr/local/nginx/conf/nginx.conf
        - name: create vhosts dir
          file: path=/data/www state=directory
        - name: start nginx services
          shell: /usr/local/nginx/sbin/nginx
    

      

      

  • 相关阅读:
    数据汇总计算和分析的反思
    排名算法计算
    仿Spring读取配置文件实现方案
    xml 配置文件规范 校验
    批量插入数据(基于Mybatis的实现-Oracle)
    shallow copy 和 deep copy 的示例
    引用对象的使用和易产生bug的示例
    codis安装手册
    Redis安装手册
    map和list遍历基础
  • 原文地址:https://www.cnblogs.com/shansongxian/p/9989595.html
Copyright © 2011-2022 走看看