ansible+playbook 搭建lnmp环境
用三台机器 做ansible+playbook 搭建lnmp环境
IP分配
ansible 主机192.168.202.132
lnmp第一台主机 192.168.202.131
lnmp第一台主机 192.168.202.133
1.1 ansible主机安装ansible
[root@localhost ~]# yum -y install ansible
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.jdcloud.com
* extras: mirror.bit.edu.cn
1.2 ansible主机生成密钥设置免密码登录
[root@localhost ~]# ssh -keygen
Bad escape character 'ygen'.
[root@localhost ~]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_r
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_
Your public key has been saved in /root/.ssh/id_rsa.
The key fingerprint is:
SHA256:snafmBirD5A4bkRNfs/yraWQ7BqJf4SKpLd0UO5yZyA rhost
The key's randomart image is:
+---[RSA 2048]----+
| . |
| + |
| . o.. |
|.. +. o |
|o.E +..oS |
|oo.*oo+o. |
|+++o*+*..o |
|+oo+o*.=++ . |
| ..++++oo o |
+----[SHA256]-----+
[root@localhost ~]# ssh-copy-id root@192.168.202.131
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be i "/root/.ssh/id_rsa.pub"
The authenticity of host '192.168.202.131 (192.168.2can't be established.
ECDSA key fingerprint is SHA256:+YOuMKydPwvlPwXHq3Cgj6X6jdlupF1W3A.
ECDSA key fingerprint is MD5:33:f9:54:0f:ce:1e:53:96:96:29:e3:04:7c.
Are you sure you want to continue connecting (yes/no
/usr/bin/ssh-copy-id: INFO: attempting to log in wit key(s), to filter out any that are already installe
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be in- if you are prompted now it is to install the new k
root@192.168.202.131's password: Number of key(s) added: 1 Now try logging into the machine, with: "ssh 'root202.131'"
and check to make sure that only the key(s) you wantdded.
[root@localhost ~]# ssh-copy-id root@192.168.202.133
1.3 ansible主机配置
[root@localhost ~]# vim /etc/ansible/hosts [lnmp]
192.168.202.131
192.168.202.133
如图:

1.4 编写ansible的playbook
---
- hosts: lnmp
tasks:
- name: "安装需要的环境"
yum: name=gcc,gcc-c++,make,php,php-gd,php-mysql,php-fpm,pcre-devel,zlib-devel,mariadb,mariadb-server state=latest
- name: "导入nginx包"
unarchive: src=nginx-1.16.1.tar.gz dest=/root
- name: "编译安装"
shell: cd /root/nginx-1.16.1 && ./configure && make && make install
- name: "分发配置文件"
copy: src=nginx.conf dest=/usr/local/nginx/conf/nginx.conf
- name: "分发主界面"
copy: src=info.php dest=/var/www/html/info.php
- name: 启动nginx
shell: /usr/local/nginx/sbin/nginx
- name: "启动mysql"
shell: systemctl restart mariadb
- name: "启动php-fpm"
shell: systemctl restart php-fpm
- name : "关闭防火墙"
shell: systemctl stop firewalld
- name: "关闭selinux"
shell: setenforce 0
~
1.4.2 更改nginx的配置文件


1.4.3 分发一个php的测试界面

1.4.4 执行ansible-playbook


1.4.5 展示效果看看lnmp是否搭建成功

ansible+playbook 搭建lnmp环境的更多相关文章
- CentOS6.6搭建LNMP环境
CentOS6.6搭建LNMP环境 1.设置yum源,本地安装依赖包 1 yum -y install gcc gcc-c++ automake autoconf libtool make 2.下载依 ...
- Yum搭建LNMP环境(动、静、库分离)(week4_day5)--技术流ken
前言 本篇博客使用yum来搭建lnmp环境,将采用动态,静态以及数据库分开安装的方式即nginx,php,mysql.会被分开安装在不同的服务器之上,搭建出来一套lnmp环境,并部署wordpress ...
- [Linux] deepin15.8搭建LNMP环境
LAMP和LNMP LAMP==Linux+Apache+Mysql+PHP LNMP==Linux+Nginx+Mysql+PHP 安装nginx sudo apt install nginx 安装 ...
- CentOS 7 源码搭建LNMP环境
搭建 LNMP 环境 源码包版本 : CentOS Linux 7 nginx-1.15.1.tar.gz mysql-boost-5.7.21.tar.gz php-7.2.7.tar.gz ...
- Vmware搭建LNMP环境(Centos7+Nginx+Mysql+PHP7.1.8)
参考:1.Linux学习之CentOS(一)----在VMware虚拟机中安装CentOS 7(图文教程) 2.Centos7搭建LNMP环境 3.MySQL5.7修改默认root密码 4.CentO ...
- ubuntu通过apt-get方式搭建lnmp环境以及php扩展安装
v 一直是在用的lnmp的集成安装包搭建lnmp环境,因为工作需要需要安装ldap扩展,在网上怎么都找不到源码安装包,只能卸载掉原来的lnmp环境,用ubuntu的php5-ldap扩展, 在安装中遇 ...
- Mac下docker搭建lnmp环境 + redis + elasticsearch
之前在windows下一直使用vagrant做开发, 团队里面也是各种开发环境,几个人也没有统一环境,各种上线都是人肉,偶尔还会有因为开发.测试.生产环境由于软件版本或者配置不一致产生的问题, 今年准 ...
- WIN10 vagrant和virtualbox虚拟机和一键搭建lnmp环境配置thinkphp虚拟主机
版本:win10系统 virtualbox:5.1.26 vagrant :1.9.7 centos 7.0 xshell/git 首先下载好对应版本的软件 配置vagrant和virtualbox ...
- docker搭建lnmp环境(问题,资料,命令)
入门参考 http://www.runoob.com/docker/docker-install-nginx.html 十大常用命令玩转docker 1. #从官网拉取镜像 docker pull & ...
随机推荐
- Bootstrap响应式栅格系统设计
为了方便起见,我们通过1200px宽的屏幕来讲解bootstrap中container.row.col的css属性值为何这样设置的原理 在1200px屏幕中为何container的宽度设置为1170p ...
- Day 09 函数
目录 函数 函数的基本概念 为何使用函数 定义函数 什么是参数(形参,parameter) 定义函数的三种形式 无参函数 有参函数 空函数 函数的参数 形参和实参(parameter & ar ...
- Orleans[NET Core 3.1] 学习笔记(三)( 3 )服务端配置
服务端配置 Silo通过SiloHostBuilder和许多补充选项类以编程方式进行配置. Silo配置有几个关键方面: Orleans集群信息 集群提供程序(不知道咋翻译) Silo到Silo和Cl ...
- Eclipse Properties编辑
1.使用Eclipse插件编辑,这是本人推荐的方式 UPDATE地址:http://propedit.sourceforge.jp/eclipse/updates 2.使用JDK自带的工具native ...
- JS 判断移动端 ,跳转
function SetPlatForm() { var JumpUrl = ""; var sUserAgent = navigator.userAgent.toLowerCas ...
- 4个点让你彻底明白Redis的各项功能
前言 先看一下Redis是一个什么东西.官方简介解释到: Redis是一个基于BSD开源的项目,是一个把结构化的数据放在内存中的一个存储系统,你可以把它作为数据库,缓存和消息中间件来使用.同时支持st ...
- 关于eclipse码代码时光标自动消失要重新点击输入框的问题
前几天码代码时在两个电脑都出现了同样的问题,就是在输入的时候,输入法突然从程序框切换到某不可名状的位置,要重新点击输入框才能解决.(后发现不但是eclipse,任何带有输入框的都会出现此问题) 经排查 ...
- mysql数据库实战之优酷项目
管理员: 1.注册功能 客户端 1-1.选择每个功能之前都需要都需要需要连接上服务器,即需要一个socket对象,每个函数传一个client 1-2.密码在传递过程中不能是明文吧,需要加密,可选择ha ...
- 《Java练习题》进阶练习题(一)
编程合集: https://www.cnblogs.com/jssj/p/12002760.html 前言:不仅仅要实现,更要提升性能,精益求精,用尽量少的时间复杂度和空间复杂度解决问题. [程序48 ...
- js中正则表达式的易错点
文章目录 1. 匹配符部分匹配规则 2. 分组匹配规则: 3. 注意^的不同用法 4. 不要忘记转义 5. 正则表达式对象中lastIndex属性 6. exec VS match 1. 匹配符部分匹 ...