详细教程:如何编译安装Nginx

silverwq
2022-05-15 / 0 评论 / 325 阅读 / 正在检测是否收录...

概述

本篇安装教程是基于 nginx-1.18.0 版本的安装,不过最新版本应该也是这个安装方式

安装

访问官网 http://nginx.org/ 获取下载地址

解压安装包

安装依赖

# rewrite 模块需要用到正则表达式(pcre 库)
yum install pcre pcre-devel

# 某些 content-type 响应时候可以进行压缩 `gzip on`(zlib 库)
# 错误提示: `error: the HTTP gzip module requires the zlib library`
yum install -y zlib
yum install -y zlib-devel

# 编译需要(gcc 库)
yum install gcc gcc-c++

# MD5,SHA1 的散列函数,https 的 SSL 协议传输 http 需要(OpenSLL 库)
# 错误提示:`./configure: error: SSL modules require the OpenSSL library`
yum install openssl openssl-devel

执行 configure

# 执行以下命令
# --with-http_ssl_module 代表开启 https 功能
# --with-http_stub_status_module 代表性能统计模块,可以统计一些请求的情况;
./configure --prefix=/usr/local/nginx/ \
--with-http_stub_status_module \
--with-http_ssl_module

执行 make,如果提示提示 nginx: [emerg] the maximum number of files supported by select() is 64,表示 FD_SETSIZE 的值比 nginx 配置文件中 worker_connections 指令所指定的值小,你可以把 nginx. conf 里的 worker_connections 选项改小一些,比如改为 30 就好了。

make

执行 make install

make install
0

评论 (0)

取消