linux nginx服务 反向代理 负载均衡 nfs服务

本文档详细介绍了如何配置Nginx服务,包括停用防火墙、安装Nginx及依赖包、修改配置文件等内容;同时,还介绍了NFS服务的配置过程,包括服务端与客户端的设置步骤;最后,提供了Nginx反向代理的配置实例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一、nginx服务

1.首先软件停用firewall

#systemctl stop firewalld 

stop:本次停用
disable:开机停用
enable:开机启用

#ps aux | grep firewalld     #检查是否停用

2.关闭内核防火墙

#vim /etc/selinux/config

1122851-20170320172347486-819807972.png
需要重启linux

3.yum安装nginx以及依赖包

#yum install epel-release -y     #添加nginx仓库(epel-release)
#yum install nginx -y     #安装nginx

4.修改配置文件

#vim /etc/nginx/nginx.conf

1122851-20170320164414924-1121470243.png

5.重读nginx配置文件

#systemctl reload nginx

restart:重新打开
status:查看状态
nginx服务开启:
1122851-20170320172658002-977653386.png

6.动态查看nginx进程日志

#tail -f /var/log/nginx/access.log

1122851-20170320195959471-1150958589.png

二、nfs服务

首先:
服务端ip:192.168.185.130
web1:192.168.185.134
web2:192.168.185.133
web3:192.168.185.132

1.服务端yum安装nfs和RPC服务

#yum install rpcbind nfs-utils -y

新建输出目录share,增加写权限

#mkdir  /share
#chmod -R o+w /share/     #增加写权限

2.服务端修改配置文件

#vim /etc/exports

添加:

/share 192.168.185.0/24(rw,sync,fsid=0)

3.服务端设置开机启动nfs和rpcbind

#systemctl enable nfs-server.service
#systemctl enable rpcbind.service

4.服务端启动nfs和rpcbind

#systemctl start nfs-server.service
#systemctl start rpcbind.service

5.web1(客户端)配置

#yum install rpcbind nfs-utils -y   
#systemctl enable rpcbind.service      #rpcbind开机启动
#systemctl start rpcbind.serive    #启动rpcbind
#showmount -e  192.168.185.130   #查看服务端是否有共享目录
#mount -t nfs 192.168.185.130:/share /var/www/html/   #挂载服务端/share目录

配置成功:
1122851-20170320194926096-1643627418.png

三、ngix反向代理

1.修改nginx.conf

#vim /etc/nginx/nginx.conf

nginx官网介绍负载均衡(Using nginx as HTTP load balancer)
http://nginx.org/en/docs/http/load_balancing.html

2.实现基于轮询的方式

http {
    upstream myapp1 {
        server srv1.example.com;
        server srv2.example.com;
        server srv3.example.com;
    }

    server {
        listen 80;

        location / {
            proxy_pass http://myapp1;
        }
    }
}

3.实现基于权重的方式

upstream myapp1 {
        server srv1.example.com weight=3;
        server srv2.example.com;
        server srv3.example.com;
    }

4.实现基于hash的方式

upstream myapp1 {
    ip_hash;
    server srv1.example.com;
    server srv2.example.com;
    server srv3.example.com;
}

转载于:https://www.cnblogs.com/sunqim16/p/6589226.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值