CentOS-8x+Linux-8中源码编译安装Nginx-1.20详解版

CentOS-8x+Linux-8中源码编译安装Nginx-1.20*详解版


=目录索引=

01)系统 &环境

运行环境:实验室虚拟环境
系统型号:CtenOS-8.4-x86_64
Linux版本:linux-8-x86_64
CPU&内存:4H + 4GB
系统内核:4.18.0-305.3.1.el8.x86_64

=主题内容=

02)安装前准备
  1. 1 更新 CentOS-8 软件包 :
dnf update
  1. 2 关闭系统防火墙:
systemctl stop firewalld
  1. 3 关闭防火墙开机自启动:
systemctl disable firewalld
  1. 4 关闭 SELINUX
sed -ri '/^SELINUX=/c\SELINUX=disabled' /etc/selinux/config
setenforce 0
03)编译器 &【dev】库安装
  1. 1 安装 make & wget
yum -y install gcc automake autoconf libtool make wget
  1. 2 安装 gcc 编译器:
    • 系统内置 gcc 版本查询:
gcc --version
gcc (GCC) 10.2.1 20201112 (Red Hat 10.2.1-8)   //版本够高够新,不用升级....
yum -y install gcc gcc-c++
  1. 2 安装 OpenSSL 开发库:
    • ssl 模块,服务器使用 SSL 安全证书需要,【–http_ssl_module】用于开启 https 安全加密功能,依赖 OpenSSL 开发库 :
yum -y install openssl openssl-devel
  1. 3 安装 PCRE 正则式表达库:
    • nginx 必装模块【–http_rewrite_module】,基于正则匹配来实现重定向,依赖PCRE 库 :
yum -y install pcre pcre-devel
  1. 4 安装 zlib 压缩库:
    • nginx 必装模块【–http_gzip_module】,用于针对 HTTP 包中内容进行 gzip 格式的压缩,依赖 zlib 压缩库:
yum -y install zlib zlib-devel
04)编译安装【Nginx】
  1. 1 创建 nginxs 用户 & 用户属组:
useradd -s /sbin/nologin -M nginx
  1. 2 官网下载 nginx 最新稳定版:
mkdir lanmpp
cd /root/lanmpp
wget http://nginx.org/download/nginx-1.20.1.tar.gz
  1. 3 解压 & 删除 nginx 压缩包:
tar -xvf nginx-1.20.1.tar.gz
rm -rf nginx-1.20.1.tar.gz
  1. 4 预编译 & 配置 nginx 源码,使之生成可执行的二进制文件:
cd nginx-1.20.1/
./configure \
--prefix=/usr/local/nginx \
--sbin-path=/usr/local/nginx/sbin/nginx \
--conf-path=/usr/local/nginx/nginx.conf \
--error-log-path=/usr/local/nginx/logs/error.log \
--http-log-path=/usr/local/nginx/logs/access.log \
--pid-path=/usr/local/nginx/logs/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-pcre \
--with-file-aio \
--with-threads \
--with-mail \
--with-http_ssl_module \
--with-mail_ssl_module \
--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_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 \
--without-mail_pop3_module \
--without-mail_imap_module \
--without-mail_smtp_module 
      
  • 打印出现如下结果,则证明预编译 & 生成 makefile 二进制可执行文件成功…
Configuration summary
  + using threads
  + using system PCRE library
  + using system OpenSSL library
  + using system zlib library

  nginx path prefix: "/usr/local/nginx"
  nginx binary file: "/usr/local/nginx/sbin/nginx"
  nginx modules path: "/usr/local/nginx/modules"
  nginx configuration prefix: "/usr/local/nginx"
  nginx configuration file: "/usr/local/nginx/nginx.conf"
  nginx pid file: "/usr/local/nginx/logs/nginx.pid"
  nginx error log file: "/usr/local/nginx/logs/error.log"
  n
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值