• 搭建lnmp+nfs+调度器


    →→→大虾好吃吗←←←

    目录

    搭建lnmp平台

    nginx配置

    mysql配置

    php配置

    验证

    nfs+调度器

    安装服务

    nfs配置

    调度器配置

    验证


    →→→大虾好吃吗←←←

           实验目标:搭建lnmp平台,安装wordpress论坛搭建nfs,客户端通过调度器访问nfs论坛。

            实验拓扑图如下:

     

    搭建lnmp平台

    web1:192.168.1.4

    web2:192.168.1.5

    mysql:192.168.1.6

    php:192.168.1.7

            1.web1安装操作

    1. [root@nginx1 ~]# rpm -ivh /media/nginx-rpm/* --nodeps --force
    2. [root@nginx1 ~]# systemctl start nginx
    3. [root@nginx1 ~]# systemctl enable nginx

            2.web2安装操作

    1. [root@nginx2 ~]# rpm -ivh /media/nginx-rpm/* --nodeps --force
    2. [root@nginx2 ~]# systemctl start nginx
    3. [root@nginx2 ~]# systemctl enable nginx

            3.mysql安装操作

    1. [root@mysql ~]# rpm -ivh /media/mysql5.6-rpm/* --nodeps --force
    2. [root@mysql ~]# systemctl start mysqld
    3. [root@mysql ~]# systemctl enable mysqld
    4. [root@mysql ~]# mysqladmin -uroot password
    5. New password: //输入新密码
    6. Confirm new password: //输入新密码

            4.php安装操作

    1. [root@php ~]# rpm -ivh /media/php-rpm/* --nodeps --force
    2. [root@php ~]# systemctl start php-fpm
    3. [root@php ~]# systemctl enable php-fpm

    nginx配置

            1.安装论坛

    1. [root@nginx1 ~]# cp -rp /media/wordpress-4.9.4-zh_CN.zip /
    2. [root@nginx1 ~]# cd /
    3. [root@nginx1 /]# unzip wordpress-4.9.4-zh_CN.zip 
    4. [root@nginx1 /]# chmod -R 777 wordpress

            2.nginx1编辑配置文件

    1. [root@nginx1 ~]# cd /etc/nginx/conf.d/
    2. [root@nginx1 conf.d]# rm -rf default.conf          //删除默认文件
    3. [root@nginx1 conf.d]# vim blog.conf
    4. server {
    5.         listen 80;
    6.         server_name www.blog.com;
    7.         root /wordpress;
    8.         index index.php index.html;
    9.         location ~ \.php$ {
    10.                 root /wordpress;
    11.                 fastcgi_pass 192.168.1.7:9000;         //指定新的PHP主机IP
    12.                 fastcgi_index index.php;
    13.                 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    14.                 include fastcgi_params;
    15.                 }
    16.         }
    17. [root@nginx1 conf.d]# systemctl restart nginx
    18. [root@nginx1 conf.d]# scp -rp blog.conf root@192.168.1.5:/etc/nginx/conf.d/

            3.nginx2配置

    1. [root@nginx2 ~]# rm -rf /etc/nginx/conf.d/default.conf          //删除默认配置文件
    2. [root@nginx2 ~]# systemctl restart nginx
    3. [root@nginx2 ~]# scp -rp root@192.168.1.4:/wordpress /

    mysql配置

            创建数据库并创建用户。

    1. [root@mysql ~]# mysql -uroot -p123
    2. //省略部分内容
    3. mysql> create database blog;
    4. Query OK, 1 row affected (0.00 sec)
    5. mysql> grant all on blog.* to lisi@'%' identified by '123456';
    6. Query OK, 0 rows affected (0.00 sec)

    php配置

    1. [root@php ~]# vim /etc/php-fpm.d/www.conf //修改下面两行
    2. listen = 192.168.1.7:9000 //监听php主机
    3. listen.allowed_clients = 192.168.1.4,192.168.1.5 //允许监听的主机
    4. [root@php ~]# systemctl restart php-fpm
    5. [root@php ~]# scp -rp root@192.168.1.4:/wordpress / //复制nginx1安装的论坛到PHP根目录下

    验证

            现在访问192.168.1.4或者192.168.1.5应都可以看到下面的安装页面,点击现在就开始!。

     

            输入数据库信息点击提交,完成后点击现在安装。

     

     

            添加站点信息,管理员用户密码,邮箱等。

     

             下面登录刚创建好的admin用户,就可以看到论坛首页,这样用户可以根据需求添加修改自己的论坛了。

     

     

    nfs+调度器

    安装服务

            1.nfs安装操作

    1. [root@nfs ~]# yum -y install nfs-utils rpcbind
    2. [root@nfs ~]# systemctl start nfs rpcbind
    3. [root@nfs ~]# systemctl enable nfs rpcbind

            2.调度器安装操作

    1. [root@nginx_lb ~]# rpm -ivh /media/nginx-rpm/* --nodeps --force
    2. [root@nginx_lb ~]# systemctl start nginx
    3. [root@nginx_lb ~]# systemctl enable nginx

    nfs配置

            1.nfs服务器

    1. [root@nfs ~]# mkdir -p /nfs/blog //创建挂载点
    2. [root@nfs ~]# vim /etc/exports //发布共享目录
    3. /nfs/blog    192.168.1.0/24(rw,sync,no_root_squash)
    4. [root@nfs ~]# systemctl restart nfs rpcbind //重启服务

            2.nginx服务器验证

    1. [root@nginx1 ~]# showmount -e 192.168.1.8
    2. Export list for 192.168.1.8:
    3. /nfs/blog 192.168.1.0/24

            3.挂载nfs服务器盘

    (1)nginx1挂载

    1. [root@nginx1 ~]# cd /wordpress/
    2. [root@nginx1 wordpress]# scp -rp wp-content/* root@192.168.1.8:/nfs/blog/ //把网站首页复制到nfs服务器中
    3. [root@nginx1 wordpress]# mount -t nfs 192.168.1.8:/nfs/blog wp-content //挂载nfs服务器

    (2)nginx2挂载

    1. [root@nginx2 ~]# cd /wordpress/
    2. [root@nginx2 wordpress]# mount -t nfs 192.168.1.8:/nfs/blog wp-content

    (3)php挂载

    1. [root@php ~]# cd /wordpress/
    2. [root@php wordpress]# mount -t nfs 192.168.1.8:/nfs/blog wp-content

    调度器配置

    1. [root@nginx_lb ~]# cd /etc/nginx/conf.d/
    2. [root@nginx_lb conf.d]# rm -rf default.conf
    3. [root@nginx_lb conf.d]# vim lb.conf
    4. upstream webcluster {
    5.         server 192.168.1.4:80;
    6.         server 192.168.1.8:80;
    7. }
    8. server {
    9.         listen 80;
    10.         server_name www.blog.com;
    11.         location / {
    12.                 proxy_pass      http://webcluster;
    13.                 proxy_set_header Host $http_host;
    14.                 proxy_set_header X-Real-IP $remote_addr;
    15.                 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    16.         }
    17. }
    18. [root@nginx_lb conf.d]# systemctl restart nginx

    验证

            浏览器访问192.168.1.10,此时已经可以看到论坛页面了。

     

            使用nginx1和nginx2分别动态查看nginx访问日志。

    [root@nginx1 ~]# tail -f /var/log/nginx/access.log

     

    [root@nginx2 ~]# tail -f /var/log/nginx/access.log

     

     

  • 相关阅读:
    php 正则匹配中文汉字
    猿创征文|【Vue五分钟】 Vuex状态管理总结
    如何使用树莓派制作避障机器人
    web前端期末大作业 HTML+CSS+JavaScript仿京东
    【从零开始玩量化13】quantstats:分析你的量化策略
    [附源码]SSM计算机毕业设计疫情期间物资分派管理系统JAVA
    Nginx(四) absolute_redirect、server_name_in_redirect、port_in_redirect 请求重定向指令组合测试
    美团大脑百亿级知识图谱的构建及应用进展
    VsCode备忘
    互联网快讯:多地要求商家下架槟榔;多所高校延长专硕学制至3年
  • 原文地址:https://blog.csdn.net/qq_61116007/article/details/128045247