3.yum安装分布式LNMP--剧本

chatgpt/2023/10/4 8:58:57

文章目录

    • 修改hosts
    • 创建剧本文件

修改hosts

vim /etc/ansible/hosts[webservers]
192.168.242.67[dbservers]
192.168.242.68[phpservers]
192.168.242.69

创建剧本文件

vim lnmp.yaml
- name: nginx playhosts: webserversremote_user: rootvars:- http_port: 192.168.242.67:80- http_hostname: www.ggl.com- root_dir: /usr/share/nginx/html- http_remote: 192.168.242.69:9000- service: nginxtasks:- name: disable firewalldservice: name=firewalld  state=stopped  enabled=no- name: disable selinuxshell: "/usr/sbin/setenforce 0"ignore_errors: true- name: copy nginx.repocopy: src=nginx.repo dest=/etc/yum.repos.d/- name: install nginxyum: name={{service}} state=latest- name: copy index.phpcopy: src=index.php dest={{root_dir}}- name: copy nginx.conftemplate: src=default.conf.j2 dest=/etc/nginx/conf.d/default.confnotify: reload nginx- name: start nginxservice: name={{service}} state=started enabled=yeshandlers:- name: reload nginxservice: name={{service}} state=reloaded- name: mysql playhosts: dbserversremote_user: roottasks:- name: disable firewalldservice: name=firewalld  state=stopped  enabled=no- name: disable selinuxshell: "/usr/sbin/setenforce 0"ignore_errors: true- name: yum remove mariadbyum: name=mariadb* state=absent- name: install rpmshell: wget -P /etc/yum.repos.d/ http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpmignore_errors: true- name: install noarch.rpmshell: yum -y install /etc/yum.repos.d/mysql57-community-release-el7-10.noarch.rpmignore_errors: true- name: replace wprdreplace: path=/etc/yum.repos.d/mysql-community.repo regexp='gpgcheck=1' replace='gpgcheck=0'ignore_errors: true- name: install mysqlyum: name="mysql-server"- name: start mysqldservice: name=mysqld state=started enabled=yes- name: login mysqlshell: mysql -uroot -p"$(grep "password" /var/log/mysqld.log | awk 'NR==1 {print $NF}')" --connect-expired-password -e "ALTER USER 'root'@'localhost' IDENTIFIED BY 'Admin@123';"- name: grantmysqlshell: mysql -uroot -pAdmin@123 -e "grant all privileges on *.* to root@'%' identified by 'Admin@123' with grant option;"- name: php playhosts: phpserversremote_user: roottasks:vars: - service: php-fpm- timezone: Asia/Shanghai- user_name: php- http_port: 192.168.242.69:9000- remote_addr: 192.168.242.67- root_dir: /usr/share/nginx/html- mysql_dir: /var/lib/mysql/mysql.socktasks:- name: disable firewalldservice: name=firewalld  state=stopped  enabled=no- name: disable selinuxshell: "/usr/sbin/setenforce 0"ignore_errors: true- name: install yum reposhell: "rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm && rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm"ignore_errors: true- name: install phpwith_items:- php72w- php72w-cli- php72w-common- php72w-devel- php72w-embedded- php72w-gd- php72w-mbstring- php72w-pdo- php72w-xml- php72w-fpm- php72w-mysqlnd- php72w-opcacheyum: name={{item}}- name: create php useruser: name={{user_name}}- name: create php groupgroup: name={{user_name}}- name: create web dirfile: name={{root_dir}} state=directory- name: copy index.phpcopy: src=index.php dest={{root_dir}}- name: modify php.initemplate: src=php.ini.j2 dest=/etc/php.ininotify: reload php- name: copy www.confcopy: src=www.conf dest=/etc/php-fpm.d/www.conf- name: start phpservice: name={{service}} state=started enabled=yeshandlers:- name: reload phpservice: name={{service}} state=reloaded
##在剧本的当前目录中,需要准备需要的文件index.php
nginx.repo
default.conf.j2www.conf
php.ini.j2
###  index.php<?php
phpinfo();
?>
#  nginx.repo[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
###修改www.conf文件##主要修改几行配置文件user = php
group = php
listen = 192.168.242.69:9000
listen.allowed_clients = 192.168.242.67
##  php.ini.j2  配置文件模板###修改几行1097行
mysqli.default_socket = {{mysql_dir}}877行
date.timezone = {{timezone}}
##templates目录  中存放  nginx 的  j2  的配置文件模板##修改几行listen       {{http_port}};
server_name  {{http_hostname}};root   {{root_dir}};location ~ \.php$ {root           {{root_dir}};fastcgi_pass   {{http_remote}};fastcgi_index  index.php;fastcgi_param  SCRIPT_FILENAME  {{root_dir}}$fastcgi_script_name;include        fastcgi_params;}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.exyb.cn/news/show-5314217.html

如若内容造成侵权/违法违规/事实不符,请联系郑州代理记账网进行投诉反馈,一经查实,立即删除!

相关文章

cid pid client_pid os id

To generate a trace file of the RFS process we need to implement the following: 1. In the alert log of a primary database, we find the ARC (archiver) process which was most recent to start the archivers heartbeat. For example: ... Using STANDBY_ARCHIVE_D

63 # commander 的配置

初始化配置文件 新建文件夹 63&#xff0c;执行 npm init -y 修改配置文件 {"name": "kaimo-http-server","version": "1.0.0","description": "","main": "index.js","keywords"…

SQL项目实战:银行客户分析

大家好&#xff0c;本文将与大家分享一个SQL项目&#xff0c;即根据从数据集收集到的信息分析银行客户流失的可能性。这些洞察来自个人信息&#xff0c;如年龄、性别、收入和人口统计信息、银行卡类型、产品、客户信用评分以及客户在银行的服务时间长短等。对于银行而言&#x…

day16 | 513.找树左下角的值 112.路径总和 106.从中序与后序遍历序列构造二叉树

文章目录 一、找树左下角的值二、路径总和三、从中序与后序遍历序列构造二叉树 一、找树左下角的值 513.找树左下角的值 暴力解法 class Solution { public:int findBottomLeftValue(TreeNode *root){// 第一眼想到的就是层序遍历&#xff0c;取最后一层的第一个值即可queue…

分享一个赛车动画

先看效果&#xff08;动画太大了放不上来&#xff0c;甘心去复制代码运行即可&#xff09;&#xff1a; 再看代码&#xff1a; <!DOCTYPE html> <html lang"en"> <head><meta charset"UTF-8"><title>赛车</title><…

云GPU商家集锦

诸神缄默不语-个人CSDN博文目录 如果有哪家关门了可以联系我删除。 colabKaggle飞桨AI Studio - 人工智能学习实训社区&#xff08;只能用飞桨&#xff09;AWS 云服务-专业的大数据和云计算服务以及云解决方案提供商腾讯云阿里云云计算服务 | Microsoft Azure矩池云闪电算力云…

CHI中的resp type

Rsp分为4大类&#xff1b; Completion response □ 除了PCrdReturn&#xff0c;PrefetchTgt&#xff0c;其他所有的trans都需要comp resp; □ 通常是一个trans的最后一个发送的message, 来自completer; 这个响应保证trans到达了POS/POC; □ 通常RN还会发送一个compack;Read an…

LeetCode经验总结

LeetCode经验总结 文本链接&#xff0c;点击这里↓ 题号题目方法(同类型题目)9回文数数学位运算、中间扩散、双指针13罗马数字转整数左减右加26删除有序数组中的重复项双指针(26、27)27移除元素双指针41缺失的第一个正数原地哈希136只出现一次的数异或法(136、268)268丢失的数…
推荐文章