Nginx linux安装步骤以及集群 以及问题解决 内网外网通用

目录

安装

修改系统配置

启动nginx

如果提示 ./configure: error: the HTTP rewrite module requires the PCRE library. 需要安装 pcre库

如果提示./configure: error: the HTTP gzip module requires the zlib library.

从新安装 第一步即可

集群搭建


下载ngin包不用多说了 

  1. 上传nginx安装包到服务器

登入 root 账号

进入: cd /usr/local/  这是安装路径 你们可以自行找安装路径

  1. 安装

  • 在/usr/local/路径下执行
  • mkdir nginx 
  • 新建nginx文件架
  • 解压上传到nginx的安装包:
  • tar -xzvf nginx-1.20.0.tar.gz -C /usr/local/nginx/
  • 解压到  /usr/local/nginx/
  • 进入解压目录 cd /usr/local/nginx/nginx-1.20.0/
  • 执行
  • ./configure --with-http_gzip_static_module --with-http_stub_status_module 
  • 我这里是安装了 --with-http_gzip_static_module 和 --with-http_stub_status_module资源包
  • 如果不需要的话直接执行
  • ./configure
  • --prefix=/usr/local/nginx就是你指定安装路径   默认安装目录就是当前解压路径

  • 然后执行 make
make

等上面执行完了以后执行

 make install

忘了截图

然后进入 安装目录 默认安装目录就是当前解压路径

  1. 修改系统配置

  • 执行
    vi /etc/profile

添加配置

#nginx

export PATH=/usr/local/nginx/sbin:$PATH

执行刷新配置

source /etc/profile
  1. 启动nginx

  • 进入 sbin目录 cd sbin
  • 执行
    ./nginx
  • 查看进程  ps -ef | grep nginx

如果提示 ./configure: error: the HTTP rewrite module requires the PCRE library. 需要安装 pcre库

  • 上传pcre库到服务器
  • 解压上传到pcre的安装包:
  • tar -xzvf pcre-8.45.tar.gz
  • 进入解压文件架 cd pcre-8.45
  • 执行   ./configure
  •  ./configure

 安装完成后

  • 进行编译先执行make
  • 然后执行  make install

如果提示./configure: error: the HTTP gzip module requires the zlib library.

  • 则需要安装 zlib库
  • 解压上传的zlib库
  •  tar -xzvf zlib-1.2.13.tar.gz

  • 进入 解压文件 cd zlib-1.2.13

  • 执行 ./configure

  • 执行make
  • 执行 make install
  • 从新安装 第一步即可

  • 集群搭建

默认有三台服务器10.192.80.20  10.192.80.21  10.192.80.22  ,对外服务器为 20服务器

修改20服务器配置文件

  • 修改对外nginx服务器配置文件 vi /usr/local/nginx/conf/nginx.conf

在http{} 添加   

 upstream text{

         server IP:端口;

         server IP:端口;;

   }

 upstream text的text与proxy_pass 后的配置一样

打马部分为10.192.80.21  10.192.80.22 2个ip  修改的配置文件是 20服务器

服务器关闭 SELINUX

vi /etc/selinux/config

集群nginx  关闭 SELINUX=enforcing 改为 disabled;

不用刷新

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值