在arm平台openeuler系统上编译安装nginx-1.20.2

在arm平台openeuler编译安装nginx-1.20.2

写在前面:
系统环境:openEuler release 20.03 (LTS)
CPU:Kunpeng-920
Nginx:1.20.2 + ngx_http_stub_status_module(监控nginx状态使用)

一、检查依赖

依赖主要分为两类,一类是编译工具,一类是系统库。

## 编译工具
gcc gcc-c++

## 系统库
zlibc zlibc-devel openssl openssl-devel

## 检查依赖包
rpm -q gcc gcc-c++ zlib zlib-devel openssl openssl-devel
eg:
[root@localhost ~]# rpm -q gcc gcc-c++ zlib zlib-devel openssl openssl-devel
gcc-7.3.0-20190804.h31.oe1.aarch64
gcc-c++-7.3.0-20190804.h31.oe1.aarch64
zlib-1.2.11-17.oe1.aarch64
zlib-devel-1.2.11-17.oe1.aarch64
openssl-1.1.1d-9.oe1.aarch64
openssl-devel-1.1.1d-9.oe1.aarch64

## 安装
yum install -y gcc gcc-c++ zlib zlib-devel openssl openssl-devel

二、配置、编译和安装

1、配置

解压安装包后,执行configure配置工具,指定安装目录,和需要nginx插件模块,生成 Makefile。

[root@ecs-gz1-2c4 tmpwp]# tar -xf ./nginx-1.20.2.tar.gz
[root@ecs-gz1-2c4 tmpwp]# ls
nginx-1.20.2  nginx-1.20.2.tar.gz
[root@ecs-gz1-2c4 tmpwp]# cd nginx-1.20.2
[root@ecs-gz1-2c4 nginx-1.20.2]# ./configure --prefix=/tmp/nginx --with-http_stub_status_module
checking for OS
 + Linux 4.19.90-2003.4.0.0036.oe1.aarch64 aarch64
checking for C compiler ... found
 + using GNU C compiler
 + gcc version: 7.3.0 (GCC)
checking for gcc -pipe switch ... found
checking for -Wl,-E switch ... found
checking for gcc builtin atomic operations ... found
............
............
............
checking for PCRE library ... found
checking for PCRE JIT support ... found
checking for zlib library ... found
creating objs/Makefile

Configuration summary
  + using system PCRE library
  + OpenSSL library is not used
  + using system zlib library

  nginx path prefix: "/tmp/nginx"
  nginx binary file: "/tmp/nginx/sbin/nginx"
  nginx modules path: "/tmp/nginx/modules"
  nginx configuration prefix: "/tmp/nginx/conf"
  nginx configuration file: "/tmp/nginx/conf/nginx.conf"
  nginx pid file: "/tmp/nginx/logs/nginx.pid"
  nginx error log file: "/tmp/nginx/logs/error.log"
  nginx http access log file: "/tmp/nginx/logs/access.log"
  nginx http client request body temporary files: "client_body_temp"
  nginx http proxy temporary files: "proxy_temp"
  nginx http fastcgi temporary files: "fastcgi_temp"
  nginx http uwsgi temporary files: "uwsgi_temp"
  nginx http scgi temporary files: "scgi_temp"

2、编译和安装

完成配置后,执行编译,可以通过-j 参数增加编译线程。

[root@ecs-gz1-2c4 nginx-1.20.2]# make -j4
make -f objs/Makefile
make[1]: Entering directory '/tmp/tmpwp/nginx-1.20.2'
cc -c -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
        -o objs/src/core/nginx.o \
        src/core/nginx.c
cc -c -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
        -o objs/src/core/ngx_log.o \
        src/core/ngx_log.c
cc -c -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
        -o objs/src/core/ngx_palloc.o \
        src/core/ngx_palloc.c
........................
........................
........................
objs/src/http/modules/ngx_http_upstream_keepalive_module.o \
objs/src/http/modules/ngx_http_upstream_zone_module.o \
objs/src/http/modules/ngx_http_stub_status_module.o \
objs/ngx_modules.o \
-ldl -lpthread -lcrypt -lpcre -lz \
-Wl,-E
make[1]: Leaving directory '/tmp/tmpwp/nginx-1.20.2'

[root@ecs-gz1-2c4 nginx-1.20.2]# make install
make -f objs/Makefile install
make[1]: Entering directory '/tmp/tmpwp/nginx-1.20.2'
test -d '/tmp/nginx' || mkdir -p '/tmp/nginx'
test -d '/tmp/nginx/sbin' \
        || mkdir -p '/tmp/nginx/sbin'
test ! -f '/tmp/nginx/sbin/nginx' \
        || mv '/tmp/nginx/sbin/nginx' \
                '/tmp/nginx/sbin/nginx.old'
cp objs/nginx '/tmp/nginx/sbin/nginx'
test -d '/tmp/nginx/conf' \
        || mkdir -p '/tmp/nginx/conf'
cp conf/koi-win '/tmp/nginx/conf'
cp conf/koi-utf '/tmp/nginx/conf'
cp conf/win-utf '/tmp/nginx/conf'
test -f '/tmp/nginx/conf/mime.types' \
        || cp conf/mime.types '/tmp/nginx/conf'
cp conf/mime.types '/tmp/nginx/conf/mime.types.default'
test -f '/tmp/nginx/conf/fastcgi_params' \
        || cp conf/fastcgi_params '/tmp/nginx/conf'
cp conf/fastcgi_params \
        '/tmp/nginx/conf/fastcgi_params.default'
test -f '/tmp/nginx/conf/fastcgi.conf' \
        || cp conf/fastcgi.conf '/tmp/nginx/conf'
cp conf/fastcgi.conf '/tmp/nginx/conf/fastcgi.conf.default'
test -f '/tmp/nginx/conf/uwsgi_params' \
        || cp conf/uwsgi_params '/tmp/nginx/conf'
cp conf/uwsgi_params \
        '/tmp/nginx/conf/uwsgi_params.default'
test -f '/tmp/nginx/conf/scgi_params' \
        || cp conf/scgi_params '/tmp/nginx/conf'
cp conf/scgi_params \
        '/tmp/nginx/conf/scgi_params.default'
test -f '/tmp/nginx/conf/nginx.conf' \
        || cp conf/nginx.conf '/tmp/nginx/conf/nginx.conf'
cp conf/nginx.conf '/tmp/nginx/conf/nginx.conf.default'
test -d '/tmp/nginx/logs' \
        || mkdir -p '/tmp/nginx/logs'
test -d '/tmp/nginx/logs' \
        || mkdir -p '/tmp/nginx/logs'
test -d '/tmp/nginx/html' \
        || cp -R html '/tmp/nginx'
test -d '/tmp/nginx/logs' \
        || mkdir -p '/tmp/nginx/logs'
make[1]: Leaving directory '/tmp/tmpwp/nginx-1.20.2'

三、配置状态模块

ngx_http_stub_status_module是一个提供 http 接口的查询 Nginx 运行状态的免费模块。官网参考信息入口。

## nginx.conf 中 server 模块增加配置,声明查询状态的接口和模块运行规则
location /ng-status {
             stub_status on;  ## 开启状态查询功能
             allow 127.0.0.1;  ## 仅允许本地访问
             deny all;  ## 禁止其他访问
         }

[root@ecs-gz1-2c4 nginx]# curl http://127.0.0.1/ng-status
Active connections: 1
server accepts handled requests
 1 1 1
Reading: 0 Writing: 1 Waiting: 0

你可能感兴趣的:(Env,nginx)