redhat安装nginx

本文详细介绍了两种在Linux系统中安装Nginx的方法,包括使用YUM仓库管理和从源代码编译安装,同时提及了配置参数和可能出现的问题解决方法。
摘要由CSDN通过智能技术生成

Install Method 1: Use repo file to install nginx

No.

Steps

Commands

1Configure nginx repo file

#vim /etc/yum.repos.d/nginx.repo

add below content into this repo and rename epel.repo if have

repo file====>

[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true

[nginx-mainline]
name=nginx mainline repo            
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true

2Clean yum cache

#yum clean all

#yum makecache

3Install nginx#yum install nginx -y 
4Check version t0 verify install successfully#nginx -v
5Start nginx service#systemctl start nginx
6Check nginx service status

#systemctl status nginx

configuration under /etc/<nginx service>/conf.d should be included in NGINX configuration

Install Method 2: Use package to install nginx

No.

Steps

Commands

1Install related dependencies

#yum install gc gcc-c++ automake pcre pcre-devel zlib zlib-devel open openssl-devel

2Download latest nginx package#wget http://nginx.org/download/nginx-1.21.6.tar.gz
3Uncompressed the package#tar -zxvf nginx-1.21.6.tar.gz
4Configure nginx

#cd nginx-1.21.6/

#./configure --with-http_ssl_module --with-http_v2_module --with-stream

--with-http_ssl_module # 配置HTTPS时使用
--with-http_v2_module # 配置GOLANG语言时使用
--with-stream # 启用TCP/UDP代理服务

5Compile and Install

make && make install

6Add niginx into PATH

#vi /etc/profile

#add below line

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


#source /etc/profile

7Add into system management

#vi /usr/lib/systemd/system/nginx.service

[Unit]
Description=nginx - high performance web server
Documentation=http://nginx.org/en/docs/
After=network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target

[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s stop

[Install]
WantedBy=multi-user.target

8Re-load system service and start nginx

#systemctl daemon-reload

#systemctl start nginx

9Check nginx service status

#systemctl status nginx

configuration under /etc/<nginx service>/conf.d should be included in NGINX configuration

client_max_body_size         5G;
client_header_timeout        600s;
client_body_timeout          600s;
ssl_session_cache            shared:SSL:1m;
ssl_session_timeout          5m;


For method 1, If the following error occurs, please replace $releasever to the host os-release version. eg. The host OS is rhel7.9, change the $releasever to 7 in the yum repo file nginx.repo

  • 22
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
前端Nginx主备,负载均衡。 两台应用服务器每台都与负载均衡器相连,负载均衡器分配WEB请求到应用服务器。两台负载均衡器对外提供单一IP地址WEB服务; 通过heartbeat管理故障切换集群中可用的负载均衡分配器nginxd,提供对网络和硬件的维护和监视,对集群异常做自动修复和记录日志。 通过Mon提供负载均衡nginxd进程和jboss进程的维护和监视,对集群内部负载均衡进程故障做自动修复和记录日志。 高可用性特性列表  主节点电源失效,故障修复速度为12-16s。  主节点意外重启,故障修复速度为12-16s。  主节点HA进程意外停止,故障修复速度为12-16s。  主节点负载均衡进程意外停止,故障修复速度为2s。  主节点网线意外松动或断开,故障修复速度为12-16s。  备份节点电源失效,不影响对外提供服务。  备份节点意外重启,不影响对外提供服务。  备份节点HA进程意外停止,不影响对外提供服务。  备份节点负载均衡进程意外停止,不影响对外提供服务。  备份节点网线意外松动或断开,不影响对外提供服务。  维护和监视进程Mon通过linux计划任务维护和监视,故障修复速度为60s。 NGINX服务具有负载均衡、失效转移功能。两台NGINX服务器同时运行,正常运行时两台NGINX服务器同时提供服务,当其中一台NGINX出现故障时,负载均衡进程自动将客户请求转发到正常运行的NGINX服务上。 当游戏正在运行时,如果NGINX异常终止,则该局游戏作废处理,重新启动NGINX之后可以继续运行下一局游戏。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值