当前位置: 首页 > news >正文

ansible安装lnmp(集中式)

文章目录

  • 一、安装nginx
  • 二、安装mysql
  • 三、安装php
  • 测试:

一、安装nginx

- name: the nginx playhosts: webserversremote_user: roottasks:- name: stop firewalld                 #关闭防火墙service: name=firewalld state=stopped enabled=no- name: selinux stopcommand: '/usr/sbin/setenforce 0'- name: mount dev                      #挂载光盘mount: src=/dev/sr0 path=/mnt state=mounted fstype=iso9660ignore_errors: true- name: copy nginx.repo                #nginx源copy: src=/etc/yum.repos.d/nginx.repo dest=/etc/yum.repos.d- name: install nginxyum: name=nginx state=latestignore_errors: true- name: restart nginxservice: name=nginx state=started enabled=yesignore_errors: true
vim /etc/yum.repos.d
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1

在这里插入图片描述

在这里插入图片描述

二、安装mysql

- name: the mysql play#hosts: webserversremote_user: roottasks:- name: copy mysql filecopy: src=/etc/yum.repos.d/mysql57-community-release-el7-11.noarch.rpm dest=/etc/yum.repos.d/- name: yum mysqlshell: 'cd /etc/yum.repos.d&&rpm -ivh mysql57-community-release-el7-11.noarch.rpm'ignore_errors: true- name: replacereplace: path=/etc/yum.repos.d/mysql-community.repo regexp="gpgcheck=1" replace="gpgcheck=0"- name: yum mysql-serveryum: name=mysql-server state=installedignore_errors: true- name: start mysqlservice: name=mysqld.service state=restarted enabled=yes- name: mysql.shscript: /opt/mysql.shignore_errors: true
vim /opt/mysql.sh
passd=$(grep "A temporary password is generated for root@localhost:" /var/log/mysqld.log | awk '{print $NF}')
mysql -uroot -p"$passd" --connect-expired-password -e "ALTER USER 'root'@'localhost' IDENTIFIED BY 'Admin@123';"
mysql -uroot -pAdmin@123 -e "grant all privileges on *.* to root@'%' identified by 'Admin@123' with grant option;"

在这里插入图片描述

在这里插入图片描述

三、安装php

- name: the php playgather_facts: falsehosts: webserversremote_user: roottasks:- name: copy phpcopy: src=/etc/yum.repos.d/epel.repo dest=/etc/yum.repos.d/- name: copy php1copy: src=/etc/yum.repos.d/epel-testing.repo dest=/etc/yum.repos.d/- name: copy php2copy: src=/etc/yum.repos.d/webtatic-archive.repo dest=/etc/yum.repos.d/- name: copy php3copy: src=/etc/yum.repos.d/webtatic.repo dest=/etc/yum.repos.d/- name: copy php4copy: src=/etc/yum.repos.d/webtatic-testing.repo dest=/etc/yum.repos.d/- name: yum phpshell: yum -y install php72w php72w-cli php72w-common php72w-devel php72w-embedded php72w-gd php72w-mbstring php72w-pdo php72w-xml php72w-fpm php72w-mysqlnd php72w-opcacheignore_errors: true- name: start phpservice: name=php-fpm state=started- name: copy nginx.confcopy: src=/etc/nginx/conf.d/default.conf dest=/etc/nginx/conf.d/- name: start nginxservice: name=nginx state=restarted- name: copy index.phpcopy: src=/usr/share/nginx/html/index.php dest=/usr/share/nginx/html/

在这里插入图片描述

测试:

在这里插入图片描述

http://www.lryc.cn/news/103330.html

相关文章:

  • Tomcat的基本使用,如何用Maven创建Web项目、开发完成部署的Web项目
  • 微信小程序测试要点
  • TCP网络通信编程之netstat
  • Stable Diffusion:网页版 体验 / AI 绘图
  • 一文了解JavaScript 与 TypeScript的区别
  • 从更广阔的角度看待产业互联网,它展现的是一次重构的过程
  • 【PHP】简记问题:使用strtotime(‘-1 month‘, time)获取上个月第一天时间戳出错
  • 舌体分割的初步展示应用——依托Streamlit搭建demo
  • 从Vue层面 - 解析发布订阅模式和观察者模式区别
  • 面向对象之_多态_1
  • Spring学习笔记之spring概述
  • 旧项目导入Eclipse时文件夹看起来乱七八糟,无从下手的解决办法(无main或webapp等文件夹)
  • Reinforcement Learning with Code 【Code 2. Tabular Sarsa】
  • 服务调用---------Ribbon和Feign
  • app自动化测试之Appium问题分析及定位
  • 婚庆服务小程序app开发方案详解
  • 集合简述
  • 常见的软件测试面试题汇总
  • 学习笔记|大模型优质Prompt开发与应用课(二)|第二节:超高产文本生成机,传媒营销人必备神器
  • Linux基础-4
  • oracle-创建函数
  • 【Ansible 的脚本 --- playbook 剧本】
  • ubuntu释放缓存
  • 实用调试技巧(1)
  • uniapp:H5定位当前省市区街道信息
  • 自然语言处理从入门到应用——LangChain:提示(Prompts)-[提示模板:部分填充的提示模板和提示合成]
  • 论文笔记--GloVe: Global Vectors for Word Representation
  • day57|● 647. 回文子串 ● 516.最长回文子序列
  • docker compose.yml学习
  • 【业务功能篇55】Springboot+easyPOI 导入导出