LNMP部署wordpress

1.环境准备

总体架构介绍

序号类型名称外网地址内网地址软件
02负载均衡服务器lb0110.0.0.5192.168.88.5nginx keepalived
03负载均衡服务器lb0210.0.0.6192.168.88.6nginx keepalived
04web服务器web0110.0.0.7192.168.88.7nginx
05web服务器web0210.0.0.8192.168.88.8nginx
06web服务器web0310.0.0.9192.168.88.9nginx
07数据库服务器db0110.0.0.51192.168.88.51mariadb mysql
08存储服务器nfs0110.0.0.31192.168.88.31nfs-utils rpcbind
09备份服务器backup10.0.0.41192.168.88.41rsync
10批量管理服务器m0110.0.0.61192.168.88.61ansible
11跳板机服务器jumpserver10.0.0.71192.168.88.71jumpserver
12监控服务器zabbix10.0.0.72192.168.88.72zabbix
13缓存服务器redis

2.ansible搭建

cat >01_ins_ansible.sh<<EOF 
#!/bin/bash
cat >/etc/yum.repos.d/ansible.repo<<EOM
[ansible]
name=ansible
baseurl=https://mirror.tuna.tsinghua.edu.cn/epel/7/x86_64/
gpgcheck=0
enabled=1
EOM
yum clean all
yum repoinfo
yum -y install ansible
EOF
vim 02_config_ansible.sh
#!/bin/bash
ls /ansible
[ $? -eq 0 ] ||  mkdir /ansible
cat >/ansible/ansible.cfg<<EOF
[defaults]
host_key_checking = false
inventory = inventory
EOF
cat >/ansible/inventory<<EOF
[web]
192.168.88.7
192.168.88.8
192.168.88.9

[lb01]
192.168.88.5

[lb02]
192.168.88.6

[db]
192.168.88.51

[data]
192.168.88.31
[all:vars]
ansible_ssh_user=root     #所有机器用户名都是root,密码是123
ansible_ssh_pass=123
EOF

1.测试ansible可以正常访问

ansible all -m ping

3.web服务(LNMP架构wordpress)

(一)安装linux操作系统(略)

(二)整体文件系统说明

1设置tab键

每次缩进2个空格,方便编写yaml文件,直接拷贝执行即可
cat  >.vimrc<<EOF 
autocmd FileType yaml setlocal ai ts=2 sw=2 et
EOF

2.一键安装web服务器nginx,php,部署3台web

cd /ansible
cat >03_install_nginx.yaml<<EOF
---
- name: install nginx
  hosts: web
  tasks:
  - name: touch
    copy:
      content: |
        [nginx]
        name=nginx repo
        baseurl=http://nginx.org/packages/centos/7/$basearch/
        gpgcheck=0
        enabled=1
      dest: /etc/yum.repos.d/nginx.repo
  - name: shell
    shell:
      cmd:
        yum makecache
  - name: install nginx
    shell:
      cmd: |
        yum -y install nginx
        yum remove -y epel-release.noarch
        yum install -y epel-release
        yum install -y https://mirrors.tuna.tsinghua.edu.cn/remi/enterprise/remi-release-7.rpm
        yum --enablerepo=remi-php74 install -y php php-cli php-common php-devel php-embedded php-gd php-mbstring php-pdo php-xml php-fpm php-mysqlnd php-opcache php-mcrypt php-pecl-memcached php-pecl-mongodb php-pecl-redis
  - name: copy web/default.conf
    copy:
      src: web/default.conf
      dest: /etc/nginx/conf.d/
  - name: copy www.conf
 copy:
      src: files/www.conf
      dest: /etc/php-fpm.d/www.conf
  - name: start  nginx service
    service:
      name: "{{item}}"
      state: restarted
      enabled: yes
    loop: [nginx,php-fpm]
EOF
ansible-playbook  03_install_nginx.yaml  执行

3.一键安装代理服务器nginx,keepalived,部署2台lb01和lb02

cat >04_install_keepalived.yaml<<EOF
---
- name: install nginx
  hosts: lb01,lb02
  tasks:
  - name: touch
    copy:
      content: |
        [nginx]
        name=nginx repo
        baseurl=http://nginx.org/packages/centos/7/$basearch/
        gpgcheck=0
        enabled=1
      dest: /etc/yum.repos.d/nginx.repo
  - name: shell
    shell: yum makecache
  - name: install nginx
    yum:
      name: nginx,keepalived
      state: present
  - name: copy nginx.conf
    copy:
      src: files/nginx.conf
      dest: /etc/nginx/
  - name: copy default.conf
    copy:
      src: files/default.conf
      dest: /etc/nginx/conf.d/
- name: config keepalived.conf
  hosts: lb01
  tasks:
  - name:  copy lb01  keepalived.conf
 copy:
      src: files/keepalived.conf  #master配置文件
      dest: /etc/keepalived/
- name: lb02
  hosts: lb02
  tasks:
  - name:  copy lb02 keepalived.conf
    copy:
      src: ./keepalived.conf #slave配置文件
      dest: /etc/keepalived/
- name: start service
  hosts: lb01,lb02
  tasks:
  - name: start  nginx keepalived service
    service:
      name: "{{item}}"
      state: restarted
      enabled: yes
    loop: [nginx,keepalived]
EOF

4.nfs服务端文件系统部署

cat >05_install_server_nfs-utils.yaml<<EOF
---
- name: install nfs01
  hosts: data
  tasks:
  - name: install nfs-utils
    yum:
      name: nfs-utils,rpcbind
      state: present
  - name: copy /etc/exports
    copy:
      content: |
       /data 192.168.88.0/24(rw,sync)
      dest: /etc/exports
  - name: mkdir /data
    file:
      path: /data
      state: directory
      owner: nfsnobody
      group: nfsnobody
  - name: html
    copy:
      src: web/wordpress-6.1.1-zh_CN.tar.gz
      dest: /data
  - name: tar -xf wordpress-6.1.1-zh_CN.tar.gz
    shell: 
      cmd: |
        tar -xf   /data/wordpress-6.1.1-zh_CN.tar.gz -C /data
        chmod -R 777 /data
  - name: start rpcbind,nfs
    service:
      name: "{{item}}"
      state: restarted
      enabled: yes
    loop: [rpcbind,nfs]

EOF

5.nfs客户端web文件系统部署

cat >06_clientweb_nfs-utils.yaml<<EOF
---
- name: install nfs-utils
  hosts: web
  tasks:
  - name: install nfs-utils
    yum:
      name: nfs-utils
      state: present
  - name: copy /etc/
    copy:
      content: |
       mount -t nfs 192.168.88.31:/data /mnt
      dest: /etc/rc.d/nfs.local
  - name:  chmod a+x  /etc/rc.d/nfs.local
    shell:
      cmd: |
       chmod a+x  /etc/rc.d/nfs.local
       mount -t nfs 192.168.88.31:/data /mnt
EOF

6.mariadb数据库部署

cat >07-install_mariadb-server.yaml<<EOF
---
- name: install nfs-utils
  hosts: db
  tasks:
  - name: install nfs-utils
    yum:
      name: mariadb-server,mariadb
      state: present
  - name: start mariadb
    service:
      name: mariadb
      state: restarted
      enabled: yes
  - name: 修改passwd
    shell:
      cmd: |
       mysqladmin -u root password '123456'
EOF

7.创建收钱数据库和用户

cat >08-config-mysql.yml<<EOF
---
- name: config mysql
  hosts: db
  tasks:
  - name: create database
    script: files/config_mysql.sh
EOF

7.files目录下文件

1.files/config_mysql.sh
cat files/config_mysql.sh<<EOF
mysql -u root -p123456 -e "create database wordpress character set utf8mb4"
mysql -u root -p123456 -e "create user wordpress@'%' identified by 'wordpress'"
mysql -u root -p123456 -e "grant all privileges on wordpress.* to wordpress@'%'"
EOF
2.files/default.conf
cat >default.conf<<EOF
server {
    listen       80;
    server_name  localhost;

    #access_log  /var/log/nginx/host.access.log  main;

    location / {
    proxy_pass http://webserver; #路由转发
        root   /usr/share/nginx/html;
        index  index.html index.htm;
    }

    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    #location ~ \.php$ {
    #    root           html;
 #    fastcgi_pass   127.0.0.1:9000;
    #    fastcgi_index  index.php;
    #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
    #    include        fastcgi_params;
    #}

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny  all;
    #}
}
EOF
3.files/keepalived.conf 
cat >keepalived.conf<<EOF
! Configuration File for keepalived

global_defs {
   notification_email {
     acassen@firewall.loc
     failover@firewall.loc
     sysadmin@firewall.loc
   }
   notification_email_from Alexandre.Cassen@firewall.loc
   smtp_server 192.168.200.1
   smtp_connect_timeout 30
   router_id lb01
   vrrp_iptables
   vrrp_skip_check_adv_addr
   vrrp_strict
   vrrp_garp_interval 0
   vrrp_gna_interval 0
}
vrrp_script chk_http_port {  # 定义监视脚本
    script "/etc/keepalived/check_lvs.sh"  
   interval 2   # 脚本每隔2秒运行一次
 }
vrrp_instance VI_1 {
    state MASTER
    interface ens33
    virtual_router_id 51
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
     192.168.88.80/24
  }
track_script {    # 引用脚本
         chk_http_port
      }
}
EOF
4.files/check_lvs.sh
cat >files/check_lvs.sh<<EOF  #检测keepalived主备切换
#!/bin/bash
ss -ntulp | grep :80 &> /dev/null && exit 0 || exit 1
EOF
chmod +x files/check_lvs.sh #记得加执行权限
5.files/www.conf
cat >files/www.conf<<EOF #源文件修改以下2行
...
user = nginx

group = nginx
...
EOF

8.web目录下文件

1.web/www.conf
cat >web/default.conf<<EOF
server {
    listen       80;
    server_name  localhost;

    #access_log  /var/log/nginx/host.access.log  main;

    location / {
        root   /mnt/wordpress;
        index index.php index.html index.htm;
    }

    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /mnt/wordpress;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php$ {
        root           /mnt/wordpress;
        fastcgi_pass   127.0.0.1:9000;
     fastcgi_index  index.php;
      #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
       fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
       include        fastcgi_params;
    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny  all;
    #}
}
EOF

2.web/wordpress-6.1.1-zh_CN.tar.gz
下载网址

wordpress-6.1-zh_CN.zip - 坚果云 - 云盘|网盘|企业网盘|同步|备份|无限空间|免费网络硬盘|企业云盘 (jianguoyun.com)

9.注意事项

如果客户端是windows主机,则使用记事本程序打开C:\windows\System32\drivers\etc\hosts添加名称解析
当点击http://192.168.88.80页面中任意链接时,地址栏上的地址,都会变成192.168.88.7。通过以下方式修复它:
# 在nfs服务器上修改配置文件
[root@nfs01 ~]# vim /mnt/wordpress/wp-config.php 
# define('DB_NAME', 'wordpress')它的上方添加以下两行:
define('WP_SITEURL', 'http://192.168.88.80');
define('WP_HOME', 'http://192.168.88.80');

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

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

Nodejs -- 流程控制库

流程控制库 尾触发和next 尾触发最多的应用是在Connect的中间件 var app connect() app.use(connect.staticCache()) app.use(connect.static(__dirname /public)) app.use(conect.cokkieParser()) app.use(connect.session()) app.use(connect.query()) app.use(connect.…

跨平台终端软件——quardCRT

作为一个技术栈比较复杂的程序&#xff0c;工作常常会在windows/linux/macos等不同的平台切换开发&#xff0c;开发过程中最常用的就是终端工具了&#xff0c;一个趁手的终端可以成倍的提高工作效率&#xff0c;因此我一直希望能找个一个跨平台体验一致无缝切换的终端软件&…

Unity Audio Filter 入门

概述&#xff1a; 如果你在你项目中需要一些特殊的声音效果&#xff0c;那这部分声音过滤器的部分一定不要错过喔&#xff0c;让我们来学习这部分的内容吧&#xff01; 这部分理论性比较强&#xff0c;认真看我的注解哈&#xff0c;我尽量解释的易懂一点。 Audio Chorus Filter…

街道征迁项目档案管理系统

街道征迁项目档案管理系统是一个用于管理街道征迁项目档案的软件系统。该系统的主要功能包括档案录入、档案存储、档案检索、档案共享等。 系统的用户可以通过该系统录入征迁项目相关的档案信息&#xff0c;包括项目名称、征迁范围、土地面积、征迁补偿费用等。同时&#xff0c…

vue本地调试devtools

一、谷歌浏览器加载扩展程序 二、把解压的压缩包添加即可&#xff0c;重启浏览器 三、启动前端本地项目&#xff0c;即可看到Vue小图标

AD | Altium Designer(原理图设计、电路仿真、PCB绘图)汉化版

Altium Designer(原理图设计、电路仿真、PCB绘图) 通知公告 Altium Designer(AD)是一种功能强大的电子设计自动化(EDA)软件。它主要用于设计和开发电子产品,如电路板(PCB)、集成电路(IC)和嵌入式系统。AD提供了完整的设计工具套件,包括原理图设计、PCB布局、仿真、设…

ICode国际青少年编程竞赛- Python-1级训练场-识别循环规律1

ICode国际青少年编程竞赛- Python-1级训练场-识别循环规律1 1、 for i in range(4):Dev.step(6)Dev.turnLeft()2、 for i in range(3):Dev.turnLeft()Dev.step(2)Dev.turnRight()Dev.step(2)3、 for i in range(3):Spaceship.step(5)Spaceship.turnLeft()Spaceship.step(…

互联网轻量级框架整合之MyBatis底层运转逻辑

MyBatis运转过程中主要步骤有两个&#xff0c;其一读取配置文件缓存到Configuration对象&#xff0c;用于构建SqlSessionFactory&#xff1b;其二是SqlSession的执行过程&#xff0c;这其中SqlSessionFactory的构建过程相对很好理解&#xff0c;而SqlSession的执行过程就相对复…

LT6911GX HDMI2.1 至四端口 MIPI/LVDS,带音频 龙迅方案

1. 描述LT6911GX 是一款面向 VR / 显示应用的高性能 HDMI2.1 至 MIPI 或 LVDS 芯片。HDCP RX作为HDCP中继器的上游&#xff0c;可以与其他芯片的HDCP TX配合使用&#xff0c;实现中继器功能。对于 HDMI2.1 输入&#xff0c;LT6911GX 可配置为 3/4 通道。自适应均衡功能使其适合…

vue3+vite+js 实现移动端,PC端响应式布局

目前使用的是vue3vite&#xff0c;没有使用ts 纯移动端|PC端 这种适用于只适用一个端的情况 方法&#xff1a;amfe-flexible postcss-pxtorem相结合 ① 执行以下两个命令 npm i -S amfe-flexible npm install postcss-pxtorem --save-dev② main.js文件引用 import amfe-f…

FreeRTOS信号量

信号量简介 def 1&#xff1a; 信号量是一种解决问题的机制&#xff0c;可以实现共享资源的访问 信号量浅显理解例子&#xff1a; 空车位&#xff1a; 信号量资源&#xff08;计数值&#xff09; 让出占用车位&#xff1a; 释放信号量&#xff08;计数值&#xff09; 占用车…

LT6911UXB HDMI2.0 至四端口 MIPI DSI/CSI,带音频 龙迅方案

1. 描述LT6911UXB 是一款高性能 HDMI2.0 至 MIPI DSI/CSI 转换器&#xff0c;适用于 VR、智能手机和显示应用。HDMI2.0 输入支持高达 6Gbps 的数据速率&#xff0c;可为4k60Hz视频提供足够的带宽。此外&#xff0c;数据解密还支持 HDCP2.2。对于 MIPI DSI / CSI 输出&#xff0…

jvm 马士兵 01

01.JVM是什么 JVM是一个跨平台的标准 JVM只识别class文件&#xff0c;符合JVM规范的class文件都可以被识别

知乎广告开户流程,知乎广告的优势是什么?

社交媒体平台不仅是用户获取知识、分享见解的场所&#xff0c;更是品牌展示、产品推广的重要舞台。知乎作为国内知名的知识分享社区&#xff0c;以其高质量的内容生态和庞大的用户基础&#xff0c;成为了众多企业进行广告投放的优选之地。云衔科技通过其专业服务&#xff0c;助…

数字身份管理:Facebook如何利用区块链技术?

随着数字化进程的加速&#xff0c;个人身份管理已成为一个关键议题。在这方面&#xff0c;区块链技术正在逐渐展现其巨大潜力。作为全球最大的社交媒体平台&#xff0c;Facebook也在积极探索和应用区块链技术来改进其数字身份管理系统。本文将深入探讨Facebook如何利用区块链技…

<Linux> 权限

目录 权限人员相对于文件来说的分类更改权限文件的拥有者与所属组 权限 权限是操作系统用来限制对资源访问的机制&#xff0c;权限一般分为读、写、执行。系统中的每个文件都拥有特定的权限、所属用户及所属组&#xff0c;通过这样的机制来限制哪些用户、哪些组可以对特定文件…

Node私库Verdaccio使用记录,包的构建,推送和拉取

Node私库Verdaccio使用记录&#xff0c;包的构建&#xff0c;推送和拉取 Verdaccio是一个轻量级的私有npm代理注册中心&#xff0c;它可以帮助你在本地搭建一个npm仓库&#xff0c;非常适合企业内部使用。通过使用Verdaccio&#xff0c;你可以控制和缓存依赖包&#xff0c;提高…

政安晨:【Keras机器学习示例演绎】(二十七)—— 利用 NNCLR 进行自我监督对比学习

目录 简介 自我监督学习 对比学习 NNCLR 设置 超参数 加载数据集 增强 准备扩增模块 编码器结构 用于对比预训练的 NNCLR 模型 预训练 NNCLR 政安晨的个人主页&#xff1a;政安晨 欢迎 &#x1f44d;点赞✍评论⭐收藏 收录专栏: TensorFlow与Keras机器学习实战 希望…

DRF限流组件源码分析

DRF限流组件源码分析 开发过程中&#xff0c;如果某个接口不想让用户访问过于频繁&#xff0c;可以使用限流的机制 限流&#xff0c;限制用户访问频率&#xff0c;例如&#xff1a;用户1分钟最多访问100次 或者 短信验证码一天每天可以发送50次&#xff0c; 防止盗刷。 对于…

Spring - 7 ( 13000 字 Spring 入门级教程 )

一&#xff1a;Spring Boot 日志 1.1 日志概述 日志对我们来说并不陌生&#xff0c;我们可以通过打印日志来发现和定位问题, 或者根据日志来分析程序的运行过程&#xff0c;但随着项目的复杂度提升, 我们对日志的打印也有了更高的需求, 而不仅仅是定位排查问题 比如有时需要…
最新文章