搭建lnmp+nfs+调度器

原创
小哥 2年前 (2023-05-20) 阅读数 6 #大杂烩

→→→ 虾好吃 ←←←

目录

搭建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安装操作

[root@nginx1 ~]# rpm -ivh /media/nginx-rpm/* --nodeps --force

[root@nginx1 ~]# systemctl start nginx

[root@nginx1 ~]# systemctl enable nginx

2.web2安装操作

[root@nginx2 ~]# rpm -ivh /media/nginx-rpm/* --nodeps --force

[root@nginx2 ~]# systemctl start nginx

[root@nginx2 ~]# systemctl enable nginx

3.mysql安装操作

[root@mysql ~]# rpm -ivh /media/mysql5.6-rpm/* --nodeps --force

[root@mysql ~]# systemctl start mysqld

[root@mysql ~]# systemctl enable mysqld

[root@mysql ~]# mysqladmin -uroot password

New password: //输入一个新密码

Confirm new password: //输入一个新密码

4.php安装操作

[root@php ~]# rpm -ivh /media/php-rpm/* --nodeps --force

[root@php ~]# systemctl start php-fpm

[root@php ~]# systemctl enable php-fpm

nginx配置

1.安装论坛

[root@nginx1 ~]# cp -rp /media/wordpress-4.9.4-zh_CN.zip /

[root@nginx1 ~]# cd /

[root@nginx1 /]# unzip wordpress-4.9.4-zh_CN.zip 

[root@nginx1 /]# chmod -R 777 wordpress

2.nginx1编辑配置文件

[root@nginx1 ~]# cd /etc/nginx/conf.d/

[root@nginx1 conf.d]# rm -rf default.conf          //删除默认的文件

[root@nginx1 conf.d]# vim blog.conf

server {

        listen 80;

        server_name www.blog.com;

        root /wordpress;

        index index.php index.html;

        location ~ .php$ {

                root /wordpress;

                fastcgi_pass 192.168.1.7:9000;         //指定新的PHP主机IP

                fastcgi_index index.php;

                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

                include fastcgi_params;

                }

        }

[root@nginx1 conf.d]# systemctl restart nginx

[root@nginx1 conf.d]# scp -rp blog.conf root@192.168.1.5:/etc/nginx/conf.d/

3.nginx2配置

[root@nginx2 ~]# rm -rf /etc/nginx/conf.d/default.conf          //删除默认的配置文件

[root@nginx2 ~]# systemctl restart nginx

[root@nginx2 ~]# scp -rp root@192.168.1.4:/wordpress /

mysql配置

创建一个数据库,创建用户。

[root@mysql ~]# mysql -uroot -p123

//省略一些内容

mysql> create database blog;

Query OK, 1 row affected (0.00 sec)

mysql> grant all on blog.* to lisi@% identified by 123456;

Query OK, 0 rows affected (0.00 sec)

php配置

[root@php ~]# vim /etc/php-fpm.d/www.conf //修改以下两行

listen = 192.168.1.7:9000 //监听php主机

listen.allowed_clients = 192.168.1.4,192.168.1.5 //允许监听主机

[root@php ~]# systemctl restart php-fpm

[root@php ~]# scp -rp root@192.168.1.4:/wordpress / //复制nginx1安装论坛PHP根目录下

验证

现在访问192.168.1.4或者192.168.1.5您应该能够看到下面的安装页面,点击现在就开始!

输入数据库信息并单击Submit。

添加网站信息,管理员用户密码,电子邮件,等等。

接下来,登录到新创建的admin用户可以看到论坛主页,这样他们就可以根据自己的需求添加和修改自己的论坛。

nfs+调度器

安装服务

1.nfs安装操作

[root@nfs ~]# yum -y install nfs-utils rpcbind

[root@nfs ~]# systemctl start nfs rpcbind

[root@nfs ~]# systemctl enable nfs rpcbind

2.调度程序安装操作

[root@nginx_lb ~]# rpm -ivh /media/nginx-rpm/* --nodeps --force

[root@nginx_lb ~]# systemctl start nginx

[root@nginx_lb ~]# systemctl enable nginx

nfs配置

1.nfs服务器

[root@nfs ~]# mkdir -p /nfs/blog //创建挂载点

[root@nfs ~]# vim /etc/exports //发布共享目录

/nfs/blog    192.168.1.0/24(rw,sync,no_root_squash)

[root@nfs ~]# systemctl restart nfs rpcbind //重启服务

2.nginx服务器身份验证

[root@nginx1 ~]# showmount -e 192.168.1.8

Export list for 192.168.1.8:

/nfs/blog 192.168.1.0/24

3.挂载nfs服务器盘

(1)nginx1挂载

[root@nginx1 ~]# cd /wordpress/

[root@nginx1 wordpress]# scp -rp wp-content/* root@192.168.1.8:/nfs/blog/ //复制网站主页nfs服务器中

[root@nginx1 wordpress]# mount -t nfs 192.168.1.8:/nfs/blog wp-content //挂载nfs服务器

(2)nginx2挂载

[root@nginx2 ~]# cd /wordpress/

[root@nginx2 wordpress]# mount -t nfs 192.168.1.8:/nfs/blog wp-content

(3)php挂载

[root@php ~]# cd /wordpress/

[root@php wordpress]# mount -t nfs 192.168.1.8:/nfs/blog wp-content

调度程序配置

[root@nginx_lb ~]# cd /etc/nginx/conf.d/

[root@nginx_lb conf.d]# rm -rf default.conf

[root@nginx_lb conf.d]# vim lb.conf

upstream webcluster {

        server 192.168.1.4:80;

        server 192.168.1.8:80;

}

server {

        listen 80;

        server_name www.blog.com;

        location / {

                proxy_pass      http://webcluster;

                proxy_set_header Host $http_host;

                proxy_set_header X-Real-IP $remote_addr;

                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

        }

}

[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

版权声明

所有资源都来源于爬虫采集,如有侵权请联系我们,我们将立即删除