当前位置: 首页 > news >正文

Nginx安装部署

什么是Nginx?

Nginx(发音同engine x)是一款由俄罗斯程序员Igor Sysoev所开发轻量级的网页服务器、反向代 理服务器以及电子邮件(IMAP/POP3)代理服务器。
Nginx 因具有高并发(特別是静态资源)、 占用系统资源少等特性,目.功能丰富而逐渐流行起来。 在功能应用方面,Nginx 不但是一个优秀的 Web 服务软件,还具有反向代理负载均衡功能和缓存 服务功能。

目录

安装

RMP包安装

1、获取RPM包

2、安装

3、查看版本,即安装成功

源码安装

1、获取地址

2、创建用户和组

3、安装

4、为nginx提供SysV init脚本

5、启动服务

6、浏览器查看

安装

RMP包安装

1、获取RPM包

Index of /packages/

2、安装
3、查看版本,即安装成功

源码安装

1、获取地址

Index of /download/ (nginx.org)

2、创建用户和组

[root@node2 ~]# groupadd -r nginx
[root@node2 ~]# grep nginx /etc/group
nginx:x:992:
[root@node2 ~]# useradd nginx -u 993 -r -g 992 -c "nginx user" -s /sbin/nologin

3、安装

[root@node2 ~]# yum install gcc gcc-c++ make -y

[root@node2 ~]# yum install -y  pcre-devel openssl-devel     #基础依赖包(重写、开发)

[root@node2 ~]# tar xf download/nginx-1.22.0.tar.gz -C /usr/local/
[root@node2 ~]# ll /usr/local/nginx-1.22.0/

[root@node2 nginx-1.22.0]# ./configure \     #检查缺省依赖

--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 \
--user=nginx --group=nginx \
--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-stream --with-stream_realip_module \
--with-stream_ssl_module \
--with-stream_ssl_preread_module

编译并安装

[root@node2 nginx-1.22.0]# make && make install

4、为nginx提供SysV init脚本

[root@node2 ~]# cat /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=/var/run/nginx.pid
ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf
ExecReload=/bin/sh -c "/bin/kill -s HUP $(/bin/cat /var/run/nginx.pid)"
ExecStop=/bin/sh -c "/bin/kill -s TERM $(/bin/cat /var/run/nginx.pid)"

[Install]
WantedBy=multi-user.target

5、启动服务

[root@node2 ~]# systemctl daemon-reload 
[root@node2 ~]# systemctl start nginx

Nginx 软件的主要企业功能应用

( 1 ) 作为 Web 服务软件
( 2 ) 反向代理或负载均衡服务
( 3 ) 前端业务数据缓存服务

6、浏览器查看

http://www.lryc.cn/news/111792.html

相关文章:

  • 物联网|按键实验---学习I/O的输入及中断的编程|读取I/O的输入信号|中断的编程方法|轮询实现按键捕获实验-学习笔记(13)
  • Hadoop-HDFS的Namenode及Datanode(参考Hadoop官网)
  • C:通过alarm发送信号
  • 如何将 dubbo filter 拦截器原理运用到日志拦截器中?
  • 【java】【maven】【基础】MAVEN安装配置介绍
  • 【C语言进阶】指针的高级应用(下)
  • 【uniapp APP隐藏顶部的电量,无线,时间状态栏与导航栏】
  • 微信小程序前后页面传值
  • 没有jodatime,rust里怎么比较两个日期(时间)的大小呢?
  • 【雕爷学编程】Arduino动手做(186)---WeMos ESP32开发板18
  • C语言假期作业 DAY 14
  • Maven-生命周期及命令
  • 常温超导:AI在研发中的潜力
  • 【C++】开源:Eigen3矩阵与线性代数库配置使用
  • OpenMesh 网格简化算法(基于边长度)
  • FFmpeg解码详细流程
  • 人工智能的缺陷
  • 基于ASP.NET MVC开发的、开源的个人博客系统
  • 【LeetCode】对称二叉树 平衡二叉树
  • 区块链和WEB3.0有哪些基础知识呢
  • 七、封装(1)
  • 问题解决和批判性思维是软件工程的重要核心
  • 【EI/SCOPUS征稿】2023年通信网络与机器学习国际学术会议(CNML 2023)
  • 算法-岛屿数量
  • Crescent QuickPak Crack
  • 六、ESP32数码管显示数字
  • 【Kubernetes】当K8s出现问题时,从哪些方面可以排查
  • [ MySQL ] — 库和表的操作
  • Hive常见面试题
  • 【单片机】晨启科技,酷黑版,密码锁