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中的计划任务(crontab)使用方式

《Linux中的计划任务(crontab)使用方式》:本文主要介绍Linux中的计划任务(crontab)使用方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录一、前言1、linux的起源与发展2、什么是计划任务(crontab)二、crontab基础1、cro

微信公众号脚本-获取热搜自动新建草稿并发布文章

《微信公众号脚本-获取热搜自动新建草稿并发布文章》本来想写一个自动化发布微信公众号的小绿书的脚本,但是微信公众号官网没有小绿书的接口,那就写一个获取热搜微信普通文章的脚本吧,:本文主要介绍微信公众... 目录介绍思路前期准备环境要求获取接口token获取热搜获取热搜数据下载热搜图片给图片加上标题文字上传图片

Linux换行符的使用方法详解

《Linux换行符的使用方法详解》本文介绍了Linux中常用的换行符LF及其在文件中的表示,展示了如何使用sed命令替换换行符,并列举了与换行符处理相关的Linux命令,通过代码讲解的非常详细,需要的... 目录简介检测文件中的换行符使用 cat -A 查看换行符使用 od -c 检查字符换行符格式转换将

Python FastAPI+Celery+RabbitMQ实现分布式图片水印处理系统

《PythonFastAPI+Celery+RabbitMQ实现分布式图片水印处理系统》这篇文章主要为大家详细介绍了PythonFastAPI如何结合Celery以及RabbitMQ实现简单的分布式... 实现思路FastAPI 服务器Celery 任务队列RabbitMQ 作为消息代理定时任务处理完整

Linux系统配置NAT网络模式的详细步骤(附图文)

《Linux系统配置NAT网络模式的详细步骤(附图文)》本文详细指导如何在VMware环境下配置NAT网络模式,包括设置主机和虚拟机的IP地址、网关,以及针对Linux和Windows系统的具体步骤,... 目录一、配置NAT网络模式二、设置虚拟机交换机网关2.1 打开虚拟机2.2 管理员授权2.3 设置子

Linux系统中卸载与安装JDK的详细教程

《Linux系统中卸载与安装JDK的详细教程》本文详细介绍了如何在Linux系统中通过Xshell和Xftp工具连接与传输文件,然后进行JDK的安装与卸载,安装步骤包括连接Linux、传输JDK安装包... 目录1、卸载1.1 linux删除自带的JDK1.2 Linux上卸载自己安装的JDK2、安装2.1

Python基于wxPython和FFmpeg开发一个视频标签工具

《Python基于wxPython和FFmpeg开发一个视频标签工具》在当今数字媒体时代,视频内容的管理和标记变得越来越重要,无论是研究人员需要对实验视频进行时间点标记,还是个人用户希望对家庭视频进行... 目录引言1. 应用概述2. 技术栈分析2.1 核心库和模块2.2 wxpython作为GUI选择的优

Linux卸载自带jdk并安装新jdk版本的图文教程

《Linux卸载自带jdk并安装新jdk版本的图文教程》在Linux系统中,有时需要卸载预装的OpenJDK并安装特定版本的JDK,例如JDK1.8,所以本文给大家详细介绍了Linux卸载自带jdk并... 目录Ⅰ、卸载自带jdkⅡ、安装新版jdkⅠ、卸载自带jdk1、输入命令查看旧jdkrpm -qa

SpringKafka消息发布之KafkaTemplate与事务支持功能

《SpringKafka消息发布之KafkaTemplate与事务支持功能》通过本文介绍的基本用法、序列化选项、事务支持、错误处理和性能优化技术,开发者可以构建高效可靠的Kafka消息发布系统,事务支... 目录引言一、KafkaTemplate基础二、消息序列化三、事务支持机制四、错误处理与重试五、性能优

Linux samba共享慢的原因及解决方案

《Linuxsamba共享慢的原因及解决方案》:本文主要介绍Linuxsamba共享慢的原因及解决方案,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录linux samba共享慢原因及解决问题表现原因解决办法总结Linandroidux samba共享慢原因及解决