NGINX源码安装

2021/6/1 7:25:23

本文主要是介绍NGINX源码安装,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

一、准备环境

node01 192.168.0.2   CentOS Linux release 7.6.1810 (Core)

安装包:http://nginx.org/download/nginx-1.20.1.tar.gz

二、安装步骤

1、下载安装包

 wget -c http://nginx.org/download/nginx-1.20.1.tar.gz

2、解压安装包

[root@node01 ~]# tar xf nginx-1.20.1.tar.gz
[root@node01 ~]# ls
anaconda-ks.cfg nginx-1.20.1 nginx-1.20.1.tar.gz ssx_test
[root@node01 ~]# cd nginx-1.20.1
[root@node01 nginx-1.20.1]# ls
auto CHANGES CHANGES.ru conf configure contrib html LICENSE man README src
[root@node01 nginx-1.20.1]#

3、预编译

预编译主要用于检查系统环境是否具备安装软件包的条件,并生成Makefile文件,改文件为编译、安装、升级nginx指明了相应参数。

[root@node01 nginx-1.20.1]# ./configure --prefix=/usr/local/nginx                           

 

预编译命令详解:

./configure --help 可以查看预编译参数

--prefix 指定nginx编译安装的目录;

--user=*** 指定nginx的属主

--group=*** 指定nginx的属主的属组

--with-*** 指定编译某模块(默认不会编译)

--without-** 指定不编译某模块(默认会编译)

--add-module 编译第三方模块

4、编译并安装

[root@node01 nginx-1.20.1]# make && make install

 

查看nginx服务进程

 

访问测试页: 

 

 

基于安全考虑下图版本信息需要屏蔽:

 

 

因此,升级nginx,步骤如下:

1、修改core模块的nginx.h

 

2、预编译&安装&升级

[root@node01 core]# /usr/local/nginx/sbin/nginx -V
nginx version: sugonweb/2.2
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)
configure arguments: --prefix=/usr/local/nginx/ --with-http_stub_status_module

 

[root@node01 nginx-1.20.1]# ./configure --prefix=/usr/local/nginx/ --with-http_stub_status_module

[root@node01 nginx-1.20.1]# make && make install && make upgrade

 

 

3、登录验证

 



这篇关于NGINX源码安装的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程