企业级WEB服务Nginx安装

企业级WEB服务Nginx安装

1. Nginx版本和安装方式

  • Mainline version 主要开发版本,一般为奇数版本号,比如1.19
  • Stable version 当前最新稳定版,一般为偶数版本,如:1.20
  • Legacy versions 旧的稳定版,一般为偶数版本,如:1.18

Nginx安装可以使用yum或源码安装,但是推荐使用源码编译安装

  • yum的版本比较旧
  • 编译安装可以更方便自定义相关路径
  • 使用源码编译可以自定义相关功能,更方便业务的上的使用

2. 基于yum安装Nginx

2.1 查看当前系统中的Nginx版本

# Rocky Linux 9
[root@Rocky9 ~]# dnf info nginx
Last metadata expiration check: 2:51:40 ago on Fri 10 May 2024 12:57:53 PM CST.
Available Packages
Name         : nginx
Epoch        : 1
Version      : 1.20.1
Release      : 14.el9_2.1
Architecture : x86_64
Size         : 36 k
Source       : nginx-1.20.1-14.el9_2.1.src.rpm
Repository   : appstream
Summary      : A high performance web server and reverse proxy server
URL          : https://nginx.org
License      : BSD
Description  : Nginx is a web server and a reverse proxy server for HTTP, SMTP, POP3 and: IMAP protocols, with a strong focus on high concurrency, performance and low: memory usage.[root@Rocky9 ~]## CentOS7 需提前配置好epel源
[root@localhost ~]#yum info nginx
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile* base: mirrors.tuna.tsinghua.edu.cn* epel: mirrors.tuna.tsinghua.edu.cn* extras: mirrors.tuna.tsinghua.edu.cn* updates: mirrors.aliyun.com
Available Packages
Name        : nginx
Arch        : x86_64
Epoch       : 1
Version     : 1.20.1
Release     : 10.el7
Size        : 588 k
Repo        : epel/7/x86_64
Summary     : A high performance web server and reverse proxy server
URL         : https://nginx.org
License     : BSD
Description : Nginx is a web server and a reverse proxy server for HTTP, SMTP, POP3 and: IMAP protocols, with a strong focus on high concurrency, performance and low: memory usage.[root@localhost ~]#
# 我这里放到这里了
[epel]
name=epel
baseurl=https://mirrors.aliyun.com/epel/$releasever/$basearch/https://mirrors.cloud.tencent.com/epel/$releasever/$basearch/https://mirrors.tuna.tsinghua.edu.cn/epel/$releasever/$basearch/
gpgcheck=1
gpgkey=https://mirrors.tuna.tsinghua.edu.cn/epel/RPM-GPG-KEY-EPEL-7

可以看到这些都比较旧,查看官方版本

image-20240510155409672

2.2 官方包源安装最新版本 nginx

系统和EPEL源的中nignx版本较旧,可以安装官方源的最新版本

官方包链接:

https://nginx.org/en/linux_packages.html

官方yum源连接

https://nginx.org/en/linux_packages.html#RHEL

配置官方yum源

[root@Rocky9 ~]# vim /etc/yum.repos.d/nginx.repo
[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# yum列出所有版本
[root@Rocky9 ~]# yum list --showduplicates nginx
Last metadata expiration check: 0:01:25 ago on Fri 10 May 2024 04:07:30 PM CST.
Available Packages
nginx.x86_64                                               1:1.20.1-14.el9_2.1                                                appstream
nginx.x86_64                                               1:1.20.2-1.el9.ngx                                                 nginx-stable
nginx.x86_64                                               1:1.22.0-1.el9.ngx                                                 nginx-stable
nginx.x86_64                                               1:1.22.1-1.el9.ngx                                                 nginx-stable
nginx.x86_64                                               1:1.24.0-1.el9.ngx                                                 nginx-stable
nginx.x86_64                                               1:1.26.0-1.el9.ngx                                                 nginx-stable
[root@Rocky9 ~]##查看版本信息
[root@Rocky9 ~]# dnf info nginx
Last metadata expiration check: 0:15:08 ago on Fri 10 May 2024 04:07:30 PM CST.
Available Packages
Name         : nginx
Epoch        : 1
Version      : 1.26.0
Release      : 1.el9.ngx
Architecture : x86_64
Size         : 995 k
Source       : nginx-1.26.0-1.el9.ngx.src.rpm
Repository   : nginx-stable
Summary      : High performance web server
URL          : https://nginx.org/
License      : 2-clause BSD-like license
Description  : nginx [engine x] is an HTTP and reverse proxy server, as well as: a mail proxy server.[root@Rocky9 ~]# dnf -y install nginx

2.3 检查安装

查看Nginx安装包信息

[root@Rocky9 ~]# rpm -q nginx
nginx-1.26.0-1.el9.ngx.x86_64
[root@Rocky9 ~]# rpm -qi nginx
Name        : nginx
Epoch       : 1
Version     : 1.26.0
Release     : 1.el9.ngx
Architecture: x86_64
Install Date: Fri 10 May 2024 04:24:28 PM CST
Group       : System Environment/Daemons
Size        : 3511437
License     : 2-clause BSD-like license
Signature   : RSA/SHA256, Wed 24 Apr 2024 03:09:17 AM CST, Key ID abf5bd827bd9bf62
Source RPM  : nginx-1.26.0-1.el9.ngx.src.rpm
Build Date  : Wed 24 Apr 2024 02:25:42 AM CST
Build Host  : ip-10-1-17-66.eu-central-1.compute.internal
Vendor      : NGINX Packaging <nginx-packaging@f5.com>
URL         : https://nginx.org/
Summary     : High performance web server
Description :
nginx [engine x] is an HTTP and reverse proxy server, as well as
a mail proxy server.
[root@Rocky9 ~]## 查看相关文件列表
[root@Rocky9 ~]# rpm -ql nginx
/etc/logrotate.d/nginx
/etc/nginx
/etc/nginx/conf.d
/etc/nginx/conf.d/default.conf
/etc/nginx/fastcgi_params
/etc/nginx/mime.types
/etc/nginx/modules
/etc/nginx/nginx.conf
/etc/nginx/scgi_params
/etc/nginx/uwsgi_params
/usr/lib/.build-id
/usr/lib/.build-id/52
/usr/lib/.build-id/52/145ff3b622c4ce68927371a3c1c03f2b74eebe
/usr/lib/.build-id/75
/usr/lib/.build-id/75/43f6f2a6666b01d673a74132d0fe256c90c306
/usr/lib/systemd/system/nginx-debug.service
/usr/lib/systemd/system/nginx.service
/usr/lib64/nginx
/usr/lib64/nginx/modules
/usr/libexec/initscripts/legacy-actions/nginx
/usr/libexec/initscripts/legacy-actions/nginx/check-reload
/usr/libexec/initscripts/legacy-actions/nginx/upgrade
/usr/sbin/nginx
/usr/sbin/nginx-debug
/usr/share/doc/nginx-1.26.0
/usr/share/doc/nginx-1.26.0/COPYRIGHT
/usr/share/man/man8/nginx.8.gz
/usr/share/nginx
/usr/share/nginx/html
/usr/share/nginx/html/50x.html
/usr/share/nginx/html/index.html
/var/cache/nginx
/var/log/nginx
[root@Rocky9 ~]## 查看版本
[root@Rocky9 ~]# nginx -v
nginx version: nginx/1.26.0
# 查看编译参数
[root@Rocky9 ~]# nginx -V
nginx version: nginx/1.26.0
built by gcc 11.3.1 20221121 (Red Hat 11.3.1-4) (GCC)
built with OpenSSL 3.0.7 1 Nov 2022
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-http_v3_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -march=x86-64-v2 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -pie'
[root@Rocky9 ~]#

2.4 nginx程序用法帮助

使用安装完成的二进制文件nginx

[root@Rocky9 ~]# nginx -h
nginx version: nginx/1.26.0
Usage: nginx [-?hvVtTq] [-s signal] [-p prefix][-e filename] [-c filename] [-g directives]Options:-?,-h         : this help-v            : show version and exit	#显示版本-V            : show version and configure options then exit	# 显示编译参数-t            : test configuration and exit-T            : test configuration, dump it and exit-q            : suppress non-error messages during configuration testing	# 静默模式-s signal     : send signal to a master process: stop, quit, reopen, reload	# 发送信号,reload信号会生成新的worker,但master不会重新生成-p prefix     : set prefix path (default: /etc/nginx/)	# 指定Nginx 目录-e filename   : set error log file (default: /var/log/nginx/error.log)	# 日志文件路径-c filename   : set configuration file (default: /etc/nginx/nginx.conf) # 配置文件路径-g directives : set global directives out of configuration file # 设置全局指令,注意和配置文件不要同时配置,否则冲突[root@Rocky9 ~]#

2.5 验证Nginx

# 检查nginx语法是否正确
[root@Rocky9 ~]<

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/697628.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Ngnix VTS模块添加和测试

目录 VTS模块介绍 上传软件包xftp/lrzsz 执行脚本 添加vts的配置 测试 测试&#xff1a;nginx.conf配置文件是否有语法错误 测试&#xff1a;windows机器上访问效果 VTS模块介绍 Nginx VTS模块&#xff08;nginx Virtual Host Traffic Status Module&#xff09;是一个第三…

GLU(Gated Linear Unit) 门控线性单元

文章目录 一、RNN二、GLU2.1 整体结构2.2 输入层(Input SentenceLookup Table)2.3 中间层(ConvolutionGate)2.4 输出层(Softmax)2.5 实验结果2.6 实现代码 三、RNN与GLU的对比参考资料 GLU可以理解为能够并行处理时序数据的CNN网络架构&#xff0c;即利用CNN及门控机制实现了RN…

ES扩缩容

ES扩容 1.1 页面扩容ES1 1.2 拷贝插件及ssl文件 JSON [ec_admin@kde-offline3 ~]$ sudo rsync -avP /usr/kde_ec/2.3.6.6-1/elasticsearch1/plugins/* kde-offline6:/usr/kde_ec/2.3.6.6-1/elasticsearch1/plugins/ ;echo $? [ec_admin@kde-offline3 ~]$ sudo rsync -avP /us…

“圣诞树图案的打印~C语言”

圣诞树图案的打印~C语言 题目原文&#xff1a;[圣诞树](https://www.nowcoder.com/practice/9a03096ed8ab449e9b10b0466de29eb2?tpId107&rp1&ru/ta/beginner-programmers&qru/ta/beginner-programmers/question-ranking&difficulty&judgeStatus&tags&…

linux部署安装DataX和DataX-Web

1.基础环境 JDK&#xff08;1.8 及其以上都可以&#xff0c;推荐 1.8&#xff09;&#xff0c;安装过程略 Python&#xff08;2 或者 3 都可以&#xff09;&#xff0c;安装过程略 Apache Maven 3.6.1&#xff08;只有DataX源码编译安装时需要&#xff09; 1.1下载maven安装…

【MQTT】paho.mqtt.c 库的“介绍、下载、交叉编译” 详解,以及编写MQTT客户端例子源码

&#x1f601;博客主页&#x1f601;&#xff1a;&#x1f680;https://blog.csdn.net/wkd_007&#x1f680; &#x1f911;博客内容&#x1f911;&#xff1a;&#x1f36d;嵌入式开发、Linux、C语言、C、数据结构、音视频&#x1f36d; ⏰发布时间⏰&#xff1a;2024-05-13 1…

kubeflow文档-介绍与架构

1. kubeflow介绍 Kubeflow项目致力于使机器学习&#xff08;ML&#xff09;工作流在Kubernetes上的部署变得简单、可移植和可扩展。目标不是重新创建其他服务&#xff0c;而是提供一种直接的方法&#xff0c;将ML的开源系统部署到不同的基础设施中。无论在哪里运行Kubernetes&a…

【408真题】2009-10

“接”是针对题目进行必要的分析&#xff0c;比较简略&#xff1b; “化”是对题目中所涉及到的知识点进行详细解释&#xff1b; “发”是对此题型的解题套路总结&#xff0c;并结合历年真题或者典型例题进行运用。 涉及到的知识全部来源于王道各科教材&#xff08;2025版&…

【数据结构】-- 相交链表-环形链表

交叉链表 . - 力扣&#xff08;LeetCode&#xff09; 如果链表的两条链的长度一样&#xff0c;链表两端对齐&#xff0c;解决这个问题将会变得非常简单&#xff0c;直接分别遍历两个链表&#xff0c;想等时的节点即为所求。我们想办法让链表对齐--分别从a和b遍历链表&#xff…

群晖NAS本地搭建Bitwarden密码管理服务并实现远程同步密码托管

文章目录 1. 拉取Bitwarden镜像2. 运行Bitwarden镜像3. 本地访问4. 群晖安装Cpolar5. 配置公网地址6. 公网访问Bitwarden7. 固定公网地址8. 浏览器密码托管设置 Bitwarden是一个密码管理器应用程序&#xff0c;适用于在多个设备和浏览器之间同步密码。自建密码管理软件bitwarde…

数字人解决方案——AniTalker声音驱动肖像生成生动多样的头部说话视频算法解析

1.概述 AniTalker是一款先进的AI驱动的动画生成工具&#xff0c;它超越了简单的嘴唇同步技术&#xff0c;能够精准捕捉并再现人物的面部表情、头部动作以及其他非言语的微妙动态。这不仅意味着AniTalker能够生成嘴型精准同步的视频&#xff0c;更重要的是&#xff0c;它还能够…

增强型植被指数EVI、ndvi数据、NPP数据、GPP数据、土地利用数据、植被类型数据、降雨量数据

引言 多种卫星遥感数据反演增强型植被指数&#xff08;EVI&#xff09;产品是地理遥感生态网推出的生态环境类数据产品之一&#xff0c;产品包括1986-2021年度月度数据&#xff0c;数据类型tif栅格数据。该产品经过专家组验证&#xff0c;质量良好。 正文 栅格数据源 数据名…