linux系统ansible工具的剧本发布workpress剧本编写

2024-02-02 12:52

本文主要是介绍linux系统ansible工具的剧本发布workpress剧本编写,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

workpress剧本编写

发布workpress

整体剧本编写
准备环境
上传workpress压缩包到/root目录编写/root/nginx.conf文件,下面代码写入http模块的server中
vim /root/nginx.conflocation / {root   /usr/share/nginx/html/wordpress/;index  index.php index.html index.htm;}
location ~ \.php$ {root           html;fastcgi_pass   127.0.0.1:9000;fastcgi_index  index.php;fastcgi_param  SCRIPT_FILENAME  /usr/share/nginx/html/wordpress/$fastcgi_script_name;include        fastcgi_params;}
剧本编写
vim workpress.yaml---
- hosts: 10.12.153.110remote_user: rootvars:tasks:- name: 安装数据库yum: name=mariadb-server,mariadb state=present- name: 安装phpyum: name=http://rpms.remirepo.net/enterprise/remi-release-7.rpm state=present - name: 安装phpyum: name=php80-php-xsl,php80-php,php80-php-cli,php80-php-devel,php80-php-gd,php80-php-pdo,php80-php-mysql,php80-php-fpm state=present- name: 安装nginxyum: name=epel-release,nginx state=present- name: 启动环境service: name=nginx state=started enabled=yes- name: 启动环境service: name=php80-php-fpm state=started enabled=yes- name: 启动数据库service: name=mariadb state=started enabled=yes- name: 创建用户并授权shell: mysql -e "create database wordpress;grant all on wordpress.* to 'wordpress'@'localhost' identified by '0';grant all on wordpress.* to 'wordpress'@'%' identified by '0';flush privileges"- name: 拷贝nginx配置文件template: src=/root/nginx.conf dest=/etc/nginx/nginx.conf backup=yes- name: 安装解压工具yum: name=unzip state=present- name: 上传wordpress源码包unarchive: src=wordpress-6.2.2-zh_CN.tar.gz dest=/usr/share/nginx/html  mode=777 owner=nginx group=nginx- name: 重启nginxservice: name=nginx state=restarted
浏览器安装workpress
数据库名字:workpress
用户名字:workpress
用户密码:0
数据库地址:数据库安装的服务器ip
角色剧本编写
ansible-galaxy init php
ansible-galaxy init mariadb
ansible-galaxy init nginx
ansible-galaxy init wordpress
touch roles.yaml
roles.yaml
vim roles.yaml---
- hosts: ipremote_user: rootroles:- nginx- php- mariadb- wordpress#如果需要数据库和web分离可以这样写
#---
#- hosts: web端ip
#  remote_user: root
#  roles:
#    - nginx
#    - php
#    - wordpress
#- hosts: db端ip
#  remote_user: root
#  roles:
#    - mariadb
php目录
vim php/tasks/main.yml ---
# tasks file for php
- name: 卸载phpyum: name=php80-php-xsl,php80-php,php80-php-cli,php80-php-devel,php80-php-gd,php80-php-pdo,php80-php-mysql,php80-php-fpm state=absent- name: 安装php源yum: name=http://rpms.remirepo.net/enterprise/remi-release-7.rpm state=present- name: 安装phpyum: name=php80-php-xsl,php80-php,php80-php-cli,php80-php-devel,php80-php-gd,php80-php-pdo,php80-php-mysql,php80-php-fpm state=present- name: 启动环境service: name=php80-php-fpm state=started enabled=yes
nginx目录
vim nginx/template/nginx.comfworker_processes  1;events {worker_connections  1024;
}http {include       mime.types;default_type  application/octet-stream;sendfile        on;keepalive_timeout  65;server {listen       80;server_name  localhost;location / {root   /usr/share/nginx/html/wordpress/;index  index.php index.html index.htm;}error_page   500 502 503 504  /50x.html;location = /50x.html {root   html;}location ~ \.php$ {root           html;fastcgi_pass   127.0.0.1:9000;fastcgi_index  index.php;fastcgi_param  SCRIPT_FILENAME  /usr/share/nginx/html/wordpress/$fastcgi_script_name;include        fastcgi_params;}}
}
vim nginx/tasks/main.yml ---
# tasks file for nginx
- name: 卸载nginxyum: name=nginx state=absent
- name: 安装nginxyum: name=epel-release,nginx state=present
- name: 拷贝nginx.conf文件template: src=nginx.conf dest=/etc/nginx/nginx.conf backup=yes
- name: 启动nginxservice: name=nginx state=started
mariadb目录
vim mariadb/tasks/main.yml ---
# tasks file for mariadb
- name: 卸载数据库yum: name=mariadb-server,mariadb state=absent
- name: 安装数据库yum: name=mariadb-server,mariadb state=present
- name: 启动数据库service: name=mariadb state=started enabled=yes
- name: 删除数据库shell:  mysql -e "drop database wordpress;"
- name: 创建用户并授权shell: mysql -e "create database wordpress;grant all on wordpress.* to 'wordpress'@'localhost' identified by '0';grant all on wordpress.* to 'wordpress'@'%' identified by '0';flush privileges"
wordpress目录
上传wordpress压缩包到wordpress/files/
vim wordpress/tasks/main.yml ---
# tasks file for wordpress
- name: 安装工具yum: name=unzip state=present
- name: 上传wordpress源码包unarchive: src=wordpress-6.2.2-zh_CN.tar.gz dest=/usr/share/nginx/html  mode=777 owner=nginx group=nginx
浏览器安装workpress
数据库名字:workpress
用户名字:workpress
用户密码:0
数据库地址:数据库安装的服务器ip

这篇关于linux系统ansible工具的剧本发布workpress剧本编写的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/670766

相关文章

Linux进程CPU绑定优化与实践过程

《Linux进程CPU绑定优化与实践过程》Linux支持进程绑定至特定CPU核心,通过sched_setaffinity系统调用和taskset工具实现,优化缓存效率与上下文切换,提升多核计算性能,适... 目录1. 多核处理器及并行计算概念1.1 多核处理器架构概述1.2 并行计算的含义及重要性1.3 并

Linux线程之线程的创建、属性、回收、退出、取消方式

《Linux线程之线程的创建、属性、回收、退出、取消方式》文章总结了线程管理核心知识:线程号唯一、创建方式、属性设置(如分离状态与栈大小)、回收机制(join/detach)、退出方法(返回/pthr... 目录1. 线程号2. 线程的创建3. 线程属性4. 线程的回收5. 线程的退出6. 线程的取消7.

Linux下进程的CPU配置与线程绑定过程

《Linux下进程的CPU配置与线程绑定过程》本文介绍Linux系统中基于进程和线程的CPU配置方法,通过taskset命令和pthread库调整亲和力,将进程/线程绑定到特定CPU核心以优化资源分配... 目录1 基于进程的CPU配置1.1 对CPU亲和力的配置1.2 绑定进程到指定CPU核上运行2 基于

golang程序打包成脚本部署到Linux系统方式

《golang程序打包成脚本部署到Linux系统方式》Golang程序通过本地编译(设置GOOS为linux生成无后缀二进制文件),上传至Linux服务器后赋权执行,使用nohup命令实现后台运行,完... 目录本地编译golang程序上传Golang二进制文件到linux服务器总结本地编译Golang程序

Linux下删除乱码文件和目录的实现方式

《Linux下删除乱码文件和目录的实现方式》:本文主要介绍Linux下删除乱码文件和目录的实现方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录linux下删除乱码文件和目录方法1方法2总结Linux下删除乱码文件和目录方法1使用ls -i命令找到文件或目录

Linux在线解压jar包的实现方式

《Linux在线解压jar包的实现方式》:本文主要介绍Linux在线解压jar包的实现方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录linux在线解压jar包解压 jar包的步骤总结Linux在线解压jar包在 Centos 中解压 jar 包可以使用 u

linux解压缩 xxx.jar文件进行内部操作过程

《linux解压缩xxx.jar文件进行内部操作过程》:本文主要介绍linux解压缩xxx.jar文件进行内部操作,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录一、解压文件二、压缩文件总结一、解压文件1、把 xxx.jar 文件放在服务器上,并进入当前目录#

Linux系统性能检测命令详解

《Linux系统性能检测命令详解》本文介绍了Linux系统常用的监控命令(如top、vmstat、iostat、htop等)及其参数功能,涵盖进程状态、内存使用、磁盘I/O、系统负载等多维度资源监控,... 目录toppsuptimevmstatIOStatiotopslabtophtopdstatnmon

Python办公自动化实战之打造智能邮件发送工具

《Python办公自动化实战之打造智能邮件发送工具》在数字化办公场景中,邮件自动化是提升工作效率的关键技能,本文将演示如何使用Python的smtplib和email库构建一个支持图文混排,多附件,多... 目录前言一、基础配置:搭建邮件发送框架1.1 邮箱服务准备1.2 核心库导入1.3 基础发送函数二、

基于Python实现一个图片拆分工具

《基于Python实现一个图片拆分工具》这篇文章主要为大家详细介绍了如何基于Python实现一个图片拆分工具,可以根据需要的行数和列数进行拆分,感兴趣的小伙伴可以跟随小编一起学习一下... 简单介绍先自己选择输入的图片,默认是输出到项目文件夹中,可以自己选择其他的文件夹,选择需要拆分的行数和列数,可以通过