---
- hosts: webservers
tasks:
- name: "安装nginx依赖环境"
yum: name=gcc,gcc-c++,zlib-devel,pcre-devel,openssl-devel state=latest
- name: "推送nginx源码包"
copy: src=/usr/src/nginx-1.12.0.tar.gz dest=/root/
- name: "安装mysql和PHP"
yum: name=mysql,mysql-server,php,php-mysql,php-fpm,php-gd
- name: "解压nginx"
shell: tar zxf nginx-1.12.0.tar.gz
- name: "安装nginx"
shell: cd nginx-1.12.0 && ./configure --prefix=/usr/local/nginx && make && make install
- name: "分发nginx配置文件"
copy: src=/usr/src/nginx.conf dest=/usr/local/nginx/conf/nginx.conf
- name: "分发PHP测试页面"
copy: src=/usr/src/index.php dest=/opt/html/index.php
- name: "启动nginx"
shell: /usr/local/nginx/sbin/nginx
- name: "启动PHP"
shell: service php-fpm start
- name: "启动mysql"
shell: service mysqld start
notify: reload-nginx
tags: nginx-config
handlers:
- name: "reload-nginx"
shell: /usr/local/nginx/sbin/nginx -s reload
ansible+lnmp
最新推荐文章于 2024-05-08 15:54:09 发布