---
- hosts: webservers
tasks:
- name: '配置班级源'
script: repo.sh
- name: '安装lnmp需要的插件'
yum: name=gcc,gcc-c++,unzip,pcre-devel,zlib-devel,php,php-mysql,php-gd,php-fpm,mysql,mysql-server state=latest
- name: '解压nginx'
unarchive: src=nginx-1.16.1.tar.gz dest=/root/
- name: '编译nginx'
shell: cd /root/nginx-1.16.1 && ./configure && make && make install
- name: '传输配置文件'
copy: src=nginx.conf dest=/usr/local/nginx/conf/nginx.conf
tags: change-nginx.conf
notify: reload-nginx
- name: '启动nginx'
shell: netstat -ntlp | grep -q nginx || /usr/local/nginx/sbin/nginx
- name: '启动php-fpm'
service: - name: '启动mysql'
service: name=mysqld state=started enabled=yes
- name: '关闭防火墙'
service: name=iptables state=stopped
- name: '关闭selinux'
shell: setenforce 0
- name: '上线电商'
unarchive: src=tinyshopV2.5_data.zip dest=/usr/local/nginx/html mode=777
- name: '给主界面目录权限'
shell: chmod -R 777 /usr/local/nginx/html/
- name: '创建用户'
user: name=tom createhome=no shell=/sbin/nologin
handlers:
- name: reload-nginx
shell: /usr/local/nginx/sbin/nginx -s reload