Ansible部署lamp架构

LAMP与LNMP架构的区别及其具体的选择说明

LAMP==Linux+Apache+Mysql+PHP
LNMP==Linux+Nginx+Mysql+PHP

以上两只架构是目前网站的主流架构
LAMP和LNMP最主要的区别在于:
一个使用的是Apache,一个使用的是Nginx。

我们就来说说Apache
Apache是世界是用排名第一的Web服务器软件,其几乎可以在所有广泛使用的计算机平台上运营,由于其跨平台和安全性被广泛使用,是最流行的Web服务端软件之一。

相比于nginx,apache有些臃肿,内存和CPU开销较大,性能上有损耗,nginx对于静态文件的响应能力远高apache。

Apache是负载PHP的最佳选择,如果流量很大的话,可以使用nginx来负载非PHP的Web请求。在整个IT界而言,70%的流量访问均来源于Apache。
LNMP是Linux+Nginx+Mysql+PHP的组合方式,其特点是利用Nginx的快速与轻量级,替代以前的LAMP(Linux+Apache+Mysql+PHP)的方式。由于安装方便,并且安装脚本也随时更新。

综上所述:
基于 LAMP 架构设计具有成本低廉、部署灵活、快速开发、安全稳定等特点,是 Web 网络应用和环境的优秀组合。若是服务器配置比较低的个人网站,当然首选 LNMP 架构。

准备四台服务器,一台安装ansible,进行管理与控制;一台安装apache(httpd);一台安装mysql,存放数据;最后安装php。

lamp平台软件安装次序:

  httpd --> mysql --> php
Redhat8.2 IP 运用
master 192.168.8.129 ansible运维工具
node1 192.168.8.132 apache(httpd)
node2 192.168.8.133 mysql数据库
node3 192.168.8.134 php

1.ansible安装

//yum源安装
[root@master ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  2595  100  2595    0     0  22964      0 --:--:-- --:--:-- --:--:-- 22964

[root@master ~]# dnf -y install epel-release

//安装ansible
[root@master ~]# dnf -y install ansible

//查看ansible版本
[root@master ~]#  ansible --version
ansible 2.9.23
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.6/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.6.8 (default, Dec  5 2019, 15:45:45) [GCC 8.3.1 20191121 (Red Hat 8.3.1-5)]
[root@master ~]# 

  • 构建 一个清单文件,移动到 /opt/project目录下方便管理
[root@master project]# ls
ansible.cfg  inventory
  • 将要配置httpd、mysql、php的被控主机的IP添加到ansible主机清单
[root@master project]# cat inventory 
[httpd]
192.168.8.132 ansible_user=root ansible_password=1

[mysql]
192.168.8.133 ansible_user=root ansible_password=1

[php]
192.168.8.134 ansible_user=root ansible_password=1

[root@master project]# 

  • 运用ping模块检查指定节点机器是否连接
[root@master project]# ansible all -m ping
192.168.8.134 | SUCCESS => {
   
    "ansible_facts": {
   
        "discovered_interpreter_python": "/usr/libexec/platform-python"
    },
    "changed": false,
    "ping": "pong"
}
192.168.8.132 | SUCCESS => {
   
    "ansible_facts": {
   
        "discovered_interpreter_python": "/usr/libexec/platform-python"
    },
    
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

彭宇栋

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值