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 & ...
随机推荐
- 前端表单提交,提交有图片出现的问题,及解决方案 兼容ie9
更新一下我的小园子,主要说的是jq文件上传的过程中,如果出现上传的文件里有图片问题 其实文件上传有图片的情况下,不是什么大问题,对于前端来说,但是,如果需要兼容ie9的时候,就需要处理一下 文件上传如 ...
- Linux内核构建过程
构建内核 # shell 执行如下指令make zImage 全局变量 srctree := $(if $(KBUILD_SRC),$(KBUILD_SRC),$(CURDIR))objtree ...
- fineuploader php服务端
新版本的fineuploader项目中已经没有现成的php server端,需要额外使用composer进行安装,折腾好久才下下来,在此分享出来给大家. 下载地址: http://files.cnbl ...
- Ubuntu虚拟机安装VMware Tools
前言 在用VMware安装好Linux虚拟机后,发现在虚拟机下安装的Ubuntu16.04 64位无法进入全屏模式,同时存在物理机和虚拟机之间无法实现文件传输的问题,通过安装VMware Tools得 ...
- So Easy - 在Linux服务器上部署 .NET Core App
.NET Core 是微软提供的免费.跨平台和开源的开发框架,可以构建桌面应用程序.移动端应用程序.网络应用程序.物联网应用程序和游戏应用程序等.如果你是 Windows 平台下的 dotnet 开发 ...
- python的memory_profiler模块使用
本文主要介绍了python内存分析工具: memory_profiler,可以展示每一行代码执行所增加的内存,方便做内存调优和排除bug memory_profiler是第三方模块,需要安装才能使用 ...
- 设备数据通过Azure Functions 推送到 Power BI 数据大屏进行展示(1.准备工作)
本案例适用于开发者入门理解Azure Functions/ IoT Hub / Service Bus / Power BI等几款产品. 主要实战的内容为: 将设备遥测数据上传到物联网中心, 将遥测数 ...
- 【转载】Opening Robot Framework log failed
问题: 两种方法可以解决: 1.临时解决方案 jenkins系统管理—>运行命令行,在文本里输入 System.setProperty("hudson.model.DirectoryB ...
- GIS面试小知识点
1.什么是地理信息系统?简述其基本功能 它是随着地理科学.计算机技术.遥感技术和信息科学的发展而产生的一门科学.就应用而言,是对空间数据进行 组织.管理.分析.显示 的系统.其实本质上它探讨的就是 ...
- Java面试必看之Integer.parseInt()与Integer.valueOf()
Integer.parseInt()和Integer.valueOf()都是将成为String转换为Int,但是为什么Java会提供两个这样的方法呢,他们如果是同样的操作,岂不是多此一举? 我们来深挖 ...