• Nginx的二进制安装教程


    一、安装前准备工作

    安装nginx需要一些环境支持

    1.1 安装gcc

    GCC用来对nginx源码进行编译

    yum -y install gcc-c++
    
    • 1

    1.2 安装pcre

    Nginx的Rewrite模块和HTTP核心模块会使用到PCRE正则表达式语法。
    这里需要安装两个安装包pcre和pcre-devel。
    第一个安装包提供编译版本的库,而第二个提供开发阶段的头文件和编译项目的源代码。

    yum install -y pcre pcre-devel
    
    • 1

    1.3 安装zlib

    zlib库提供了开发人员的压缩算法,在Nginx的各种模块中需要使用gzip压缩.

    yum install -y zlib zlib-devel
    
    • 1

    1.4 安装安装Open SSL

    nginx不仅支持 http协议,还支持 https(即在 ssl 协议上传输 http)。
    如果使用了 https,需要安装 OpenSSL 库.

    yum install -y openssl openssl-devel
    
    • 1

    二、正式安装步骤

    2.1 官网下载安装包

    官网下载地址: https://nginx.org/en/download.html
    选择稳定版本
    在这里插入图片描述

    2.2 将安装包下载到/opt目录中

    curl -O https://nginx.org/download/nginx-1.22.0.tar.gz
    
    • 1

    2.3 解压缩

    tar -zxvf nginx-1.22.0.tar.gz
    
    • 1

    2.4 进入到解压后的目录执行配置命令

    ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
    
    • 1

    2.5 编译

    make
    
    • 1

    2.6 安装

    make install
    
    • 1

    2.7 启动nginx

    cd /usr/local/nginx/sbin
    ./nginx
    
    • 1
    • 2

    2.8 验证是否启动成功

    Nginx默认为80端口,启动后可以在浏览器输入自己的ip和端口号进行验证是否启动成功。
    在这里插入图片描述

    三、配置环境变量

    3.1 编辑/etc/profile文件

    vi /etc/profile
    
    • 1

    添加nginx路径。
    在这里插入图片描述

    刷新配置文件

    source /etc/profile
    
    • 1

    3.2 查看nginx的版本信息

    nginx -v
    
    • 1
    nginx version: nginx/1.22.0
    built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) 
    built with OpenSSL 1.0.2k-fips  26 Jan 2017
    TLS SNI support enabled
    configure arguments: --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
    
    • 1
    • 2
    • 3
    • 4
    • 5
  • 相关阅读:
    LeetCode·701.二叉搜索树中的插入操作·递归
    Redis设计与实现(八)| 事务
    Android Studio.exe 下载 2023 最新更新,网盘下载
    密码学 | 期末考前小记
    mongoDB mapreduce使用总结
    让Pegasus天马座开发板用上OLED屏
    STM32CubeIDE、HAL、OLED、MPU6050学习笔记
    大聪明教你学Java | SpringBoot 项目里如何在拦截器中获取 @RequestBody 参数
    PMP提分练习
    c++ 11 auto、decltype比较
  • 原文地址:https://blog.csdn.net/lemmon_tree/article/details/127412661