您现在的位置是:首页 > cms教程 > WordPress教程WordPress教程
ansible部署lnmp和wordpress的步骤方法
尔岚2025-03-29WordPress教程已有人查阅
导读如上,是项目的目录结构。common: 获取阿里云的yum源mysql: 二进制安装mysqlnginx: 编译安装nginxphp-fpm:编译安装php-fpmwordpress: 获取wordpress源码,更改部分值。
如上,是项目的目录结构。
common: 获取阿里云的yum源
mysql: 二进制安装mysql
nginx: 编译安装nginx
php-fpm:编译安装php-fpm
wordpress: 获取wordpress源码,更改部分值。
1,首先查看入口文件。
[wordpress]
192.168.1.137
3, 查看group_vars下的变量
1, common主要是获取repo源用的
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:.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:
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
本文标签:
很赞哦! ()
下一篇:返回列表
相关教程
- LNMP安装discuz
- LNMP环境搭建discuz论坛的方法
- kubernetes部署LNMP环境运行Discuz的方法实例
- Ubuntu系统lnmp框架搭建WordPress的方法
- LNMP搭建wordpress安装及配置过程
- lnmp安装nginx搭建wordpress的方法
- CentOS8搭建LNMP+WordPress的步骤方法
- CentOS 8环境LNMP搭建WordPress
- lnmp环境下搭建wordpress的方法
- CentOS下搭建LNMP+WordPress+http2.0的步骤方法
- LNMP架构搭建wordpress网站的方法
- centos7系统yum搭建lnmp环境及配置wordpress
图文教程
centos7怎么安装wordpress
mysql安装可以参考我的博客园Centos构建Java环境:1.安装apache2.安装php3.安装phpmyadmin(补充说明:安装mysql教程不论是centos还是ubuntu,可以参考我的博客文章)
怎么判断WordPress网站是否被黑客攻击
WordPress网站被黑客攻击的5个迹象,现在很多站长都会选择美国主机通过WordPress建立站点,站点建立成功之后或多或少会被黑客攻击,WordPress网站被黑客攻击时
WordPress REST API开发微信小程序的方法
自从我发布并开源WordPress版微信小程序以来,很多WordPress网站的站长问有关程序开发的问题,其实在文章:《用微信小程序连接WordPress网站》讲述过一些基本的要点
WordPress设置独立关键词和描述的方法
你下载的WordPress主题提供的keywords和description这两个meta标签一般都做得很差,或者根本就不提供,这样不利于SEO。
相关源码
-
自适应容器设备机械行业通用pbootcms网站模板本模板是一款基于PbootCMS开源内核深度开发,为容器制造、容器设备、压力容器及相关行业量身打造的高品质响应式企业网站模板。查看源码 -
(带手机版)绿色生态农业种植农产品网站pbootcms源码下载本模板基于PbootCMS内核开发,为生态农业企业量身打造,适用于农业种植、有机农场、农产品电商等业务场景。模板设计充分体现绿色环保理念,突出农业特色,同时保持简洁大气的视觉效果,帮助农业企业建立专业形象。查看源码 -
(自适应)工业机械制造设备网站pbootcms模板下载为机械制造、工业设备类企业设计,特别适合各类机械设备、生产线、工业自动化产品展示。采用响应式技术,确保在不同设备上都能清晰展示机械产品的技术参数和细节特点。查看源码 -
(PC+WAP)高端餐饮美食小吃加盟网站模板下载pbootcms本模板基于PbootCMS内核开发,为餐饮美食品牌加盟、小吃连锁企业量身打造。通过精致的美食视觉呈现与加盟业务流程展示,帮助餐饮企业建立专业线上门户,实现品牌形象与加盟业务的双重展示。查看源码 -
(PC+WAP)门窗门业家居定制铝合金产品pbootcms模板下载基于PbootCMS内核开发的门窗门业企业专用模板,采用响应式设计结构,数据一次录入即可同步适配电脑与手机端浏览。通过简洁大气的视觉呈现,帮助门窗企业快速建立专业线上展示平台,有效传递产品价值与服务优势。查看源码 -
自适应LED照明外贸灯具灯泡灯具英文网站模板该外贸灯具网站模板专为LED照明、灯具出口企业定制,采用PbootCMS内核开发,提供高效建站方案。通过响应式设计和SEO优化能力,帮助企业低成本构建专业外贸展示平台。查看源码
| 分享笔记 (共有 篇笔记) |

