nginx的负载均衡(centos 7)

1、安装nginx并搭建nginx负载均衡

操作系统:CentOS 7

服务器IP:(代理)192.168.139.151

(web)192.168.139.152 192.168.139.153

安装nginx过程:安装在代理服务器上
第一步:下载、上传到服务器后
第二步:安装依赖包:
    yum install pcre-devel automake make zlib-devel gcc-c++ libtool openssl openssl-devel -y
第三步:解压到指定位置:

    tar -zxvf nginx-1.20.2.tar.gz -C /usr/local/
第四步:新建用户名:useradd nginx -s /sbin/nologin -M

第五步:开始编译:
./configure \   
> --user=nginx \ #指定程序运行的用户
> --group=nginx \ #指定程序运行的用户组
> --prefix=/usr/local/nginx \ #指定安装目录
> --with-http_ssl_module \ #启用nginx-http_ssl_module的支持(使其支持https请求)
> --with-http_sub_module \ #启用nginx-http_sub_module的支持(允许用一些其他文本代替nginx)
> --with-http_stub_status_module \ #启用ngx_http_stub_status_module支持
> --with-http_gzip_static_module \#启用ngx_http_gzip_static_module支持
> --with-pcre    #启用pcre库
make && make install

    六:启动nginx
    1、检查语法   /usr/local/nginx/sbin/nginx -t
    2、启动nginx  /usr/local/nginx/sbin/nginx
    3、查看端口  lsof -i :80

 修改配置文件

vim /usr/local/nginx/conf/nginx.conf

启动nginx

/usr/local/nginx/sbin/nginx

2、配置两台web服务器

yum -y install httpd  注:用nginx也是相同操作只是发布目录不一样

vim /var/www/html/index.html

 

 重启httpd

systemctl restart httpd.service

访问IP

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

计网三班刘志伟

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值