ansible部署 lnmp+wordpress

如上,是项目的目录结构。
common: 获取阿里云的yum源
mysql: 二进制安装mysql
nginx: 编译安装nginx
php-fpm:编译安装php-fpm
wordpress: 获取wordpress源码,更改部分值。
1,首先查看入口文件。

---
- name: Install WordPress, MySQL, Nginx, and PHP-FPM
hosts: all
remote_user: root
# remote_user: user
# become: yes
# become_method: sudo roles:
- role: common
- role: mysql
tags: ["mysql"]
- role: nginx
tags: ["nginx"]
- role: php-fpm
tags: ["php-fpm"]
- role: wordpress
tags: ["wordpress"]
2,查看hosts

[wordpress]
192.168.1.137
3, 查看group_vars下的变量

---
# Mysql version
mysql_version: 5.5.60
basedir: /usr/local/mysql
datadir: /data/mysql #Nginx var
tarball_name: nginx-1.10.3.tar.gz
nginx_dir: nginx-1.10.3
http_port: 80
server_name: www.linsir.cn # Which version of WordPress to deploy
wp_version: 4.2.4
wp_sha256sum: 42ca594afc709cbef8528a6096f5a1efe96dcf3164e7ce321e87d57ae015cc82 # These are the WordPress database settings
wp_db_name: wordpress
wp_db_user: wordpress
wp_db_password: secret
# You shouldn't need to change this.
mysql_port: 3306 # This is used for the nginx server configuration, but access to the
# WordPress site is not restricted by a named host. # Disable All Updates
# By default automatic updates are enabled, set this value to true to disable all automatic updates
auto_up_disable: false #Define Core Update Level
#true = Development, minor, and major updates are all enabled
#false = Development, minor, and major updates are all disabled
#minor = Minor updates are enabled, development, and major updates are disabled
core_update_level: true
4,查看roles下的各个角色,根据site.yml文件中的顺序展开
1, common 主要是获取repo源用的

---
- name: Del repo for system
shell:
rm -f /etc/yum.repos.d/Cento-Base.repo && rm -f /etc/yum.repos.d/epel.repo - name: Get repo centos6 for alibaba
get_url:
url: http://mirrors.aliyun.com/repo/Centos-6.repo
dest: /etc/yum.repos.d/CentOS-Base.repo
when: (ansible_distribution == "CentOS" and ansible_distribution_major_version == "6") - name: Get repo centos7 for alibaba
get_url:
url: http://mirrors.aliyun.com/repo/Centos-7.repo
dest: /etc/yum.repos.d/CentOS-Base.repo
when: (ansible_distribution == "CentOS" and ansible_distribution_major_version == "7") - name: Get epel repo cenots6 for alibaba
get_url:
url: http://mirrors.aliyun.com/repo/epel-6.repo
dest: /etc/yum.repos.d/epel.repo
when: (ansible_distribution == "CentOS" and ansible_distribution_major_version == "6") - name: Get epel repo cenots7 for alibaba
get_url:
url: http://mirrors.aliyun.com/repo/epel-7.repo
dest: /etc/yum.repos.d/epel.repo
when: (ansible_distribution == "CentOS" and ansible_distribution_major_version == "7")
2,查看mysql角色
--- - name: Create mysql user
user:
name: mysql - name: Download mysql
get_url:
url: http://mirrors.163.com/mysql/Downloads/MySQL-5.5/mysql-{{mysql_version}}-linux-glibc2.12-x86_64.tar.gz
dest: /usr/local/src - name: Unzip mysql
unarchive:
src: /usr/local/src/mysql-{{mysql_version}}-linux-glibc2.12-x86_64.tar.gz
dest: /usr/local/src/
copy: no - name: Rename mysql
shell:
mv /usr/local/src/mysql-{{mysql_version}}-linux-glibc2.12-x86_64 /usr/local/mysql && chown -R mysql:mysql {{basedir}} - name: Create data storage
file:
path: /data/mysql
state: directory
owner: mysql
group: mysql - name: Init mysql
shell:
./scripts/mysql_install_db --user=mysql --basedir={{basedir}} --datadir={{datadir}}
args:
chdir: "{{basedir}}" - name: Create mysql script for centos6
shell:
cp "{{basedir}}/support-files/mysql.server" /etc/init.d/mysqld && chmod 755 /etc/init.d/mysqld
when: (ansible_distribution == "CentOS" and ansible_distribution_major_version == "6") - name: Create mysql script for centos7
copy:
src: mysqld.service
dest: /usr/lib/systemd/system/mysqld.service
when: (ansible_distribution == "CentOS" and ansible_distribution_major_version == "7")
notify:
- Reload service
- meta: flush_handlers - name: Copy mysql config
template:
src: my.cnf.j2
dest: /etc/my.cnf - name: Restart mysqld
service:
name: mysqld
state: restarted
register: result #根据服务器配置不同,mysql启动速度有所区别。
- name: sleep 10s
shell:
sleep 20 - name: Copy root password file
shell:
/usr/local/mysql/bin/mysqladmin -uroot password linlin
ansible部署 lnmp+wordpress的更多相关文章
- 使用 Docker 部署 LNMP 并搭建 wordpress
准备 系统版本:CentOS Linux release 7.4.1708 (Core) 内核版本:3.10.0-693.el7.x86_64 IP:192.168.31.43 可访问 ...
- Docker swarm 使用服务编排部署lnmp
一.简介 目的:在Docker Swarm集群中,使用stack服务编排搭建lnmp来部署WordPress 使用私有仓库的nginx和php镜像 mysql使用dockerhup最新镜像 使用nfs ...
- CentOS下搭建LNMP+WordPress+http2.0教程
此文是本人CentOS下搭建WordPress的一些笔记,环境搭建时间::将看过的几篇文章总结下来,形成一条龙长文.不用大家再找来找去. 本文大概分为此几部分: 一.基础命令更新: 二.服务器加速(非 ...
- 【超详细】vultr(CentOS7)+LNMP+WordPress 搭建个人博客
心血来潮想搭建个人博客,我的vps只用来搭ss未免太过浪费 在这里记录一下搭建个人博客的历程 0x00 写在前面 why vultr: 优点:便宜. 性能优良.按时间计费(不用包年 学生党的福音).稳 ...
- Docker Compose编排工具部署lnmp实践及理论(详细)
目录 一.理论概述 编排 部署 Compose原理 二.使用docker compose 部署lnmp 三.测试 四.总结 一.理论概述 Docker Compose是一个定义及运行多个Docker容 ...
- Docker部署lnmp 实战 (多注意配置文件,不管访问试试换个浏览器)
Docker部署LNMP环境 关闭防火墙,设置自定义网络 systemctl stop firewalld systemctl disable firewalld setenforce 0 docke ...
- 在ConoHa上Centos7环境下源码安装部署LNMP
本文记录了从源码,在Centos 7上手动部署LNMP环境的过程,为了方便以后对nginx和mariadb进行升级,这里采用yum的方式进行安装. 1.建立运行网站和数据库的用户和组 groupadd ...
- 001.Ansible部署RHCS存储集群
一 前期准备 1.1 前置条件 至少有三个不同的主机运行monitor (MON)节点: 至少三个直接存储(非外部SAN硬件)的OSD节点主: 至少两个不同的manager (MGR)节点: 如果使用 ...
- 【转载】Centos系统快速部署LNMP环境
PHP语言在Linux系统上运行的时候,需要在Linux系统上部署相应的Nginx.MySQL.PHP等环境,只有将这些环境参数都设置好,PHP相关应用程序才可正常运行,部署环境的方法有很多种,可手动 ...
随机推荐
- mysql 开发进阶篇系列 5 SQL 优化(表优化)
一. 使用sql提示 sql 提示(sql hint)是优化数据库的一个重要手段, 是在sql语句中加入一些人为的提示来达到优化操作的目的. 1.1 use index 在查询语句中表名的后面,添加u ...
- hashMap的hashCode() 和equal()的使用
hashMap的hashCode() 和equa()的使用 在java的集合中,判断两个对象是否相等的规则是: ,判断两个对象的hashCode是否相等 如果不相等,认为两个对象也不相等,完毕 如果相 ...
- leetcode — unique-paths-ii
/** * Source : https://oj.leetcode.com/problems/unique-paths-ii/ * * * Follow up for "Unique Pa ...
- LINUX负载均衡LVS-DR搭建
1.搭建前的规划工作 这里从lvs官方网站找了一个nat模型的图,如下: 我这里使用虚拟机模拟出了4台rhel6机器.一台服务器作为lvs调度器(和宿主机桥接),3台服务器作为具体的web服务器(使用 ...
- MySQL SQL语句执行顺序
MySQL的语句一共分为11步,如下图所标注的那样,最先执行的总是FROM操作,最后执行的是LIMIT操作.其中每一个操作都会产生一张虚拟的表,这个虚拟的表作为一个处理的输入,只是这些虚拟的表对用户来 ...
- Spring基础系列-容器启动流程(2)
原创作品,可以转载,但是请标注出处地址:https://www.cnblogs.com/V1haoge/p/9503210.html 一.概述 这里是Springboot项目启动大概流程,区别于SSM ...
- 翻译:ZooKeeper OverView
ZooKeeper系列文章:https://www.cnblogs.com/f-ck-need-u/p/7576137.html#zk ZooKeeper: 分布式协调服务 ZooKeeper是一个开 ...
- 翻译:update语句(已提交到MariaDB官方手册)
本文为mariadb官方手册:UPDATE的译文. 原文:https://mariadb.com/kb/en/update/ 我提交到MariaDB官方手册的译文:https://mariadb.co ...
- 解读经典-《C#高级编程》第七版-Chapter1-.Net体系结构-Page6-13
01 中间语言(IL) .Net中间语言(IL)的特性,很大程度上来自于要支持多语言互操作性.要支持多语言互操作性,是因为微软想搞一个大事情,将它的老产品线VB和VC++,VJ++都装入.Net架构中 ...
- YARN集群的mapreduce测试(二)
只有mapTask任务没有reduceTask的情况: 测试准备: 首先同步时间,然后 开启hdfs集群,开启yarn集群:在本地"/home/hadoop/test/"目录创建u ...