跳转至

Nginx with https全新安装

概要: 全新安装带有https模块的Nginx服务

创建时间: 2022.09.03 23:13:45

更新时间: 2023.08.16 22:26:51

全新安装

此处以 1.23.0 版本为例

Bash
1
2
3
4
5
wget http://nginx.org/download/nginx-1.23.0.tar.gz
tar -xzf nginx-1.23.0.tar.gz
cd nginx-1.23.0
./configure --prefix=/usr/local/nginx --with-http_ssl_module
make install

验证

查看是否安装成功

Bash
/usr/local/nginx/sbin/nginx -V
image.png

快捷方式

快速管理nginx配置文件

Bash
1
2
3
ln -s /usr/local/nginx/sbin/nginx /usr/bin/nginx
mkdir -p ~/config
ln -s /usr/local/nginx/conf/nginx.conf ~/config/nginx.conf

编译失败

主要解决一些库的缺失问题

PCRE库缺失

Bash
1
2
3
4
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.
image.png
解决方法
RedHat Linux
Bash
yum install pcre pcre-devel -y
Debian Linux
Bash
apt install libpcre3 libpcre3-dev -y

SSL模块缺失

Bash
1
2
3
4
./configure: error: SSL modules require the OpenSSL library.
You can either do not enable the modules, or install the OpenSSL library
into the system, or build the OpenSSL library statically from the source
with nginx by using --with-openssl=<path> option.
image.png
解决方法
RedHat Linux
Bash
yum install openssl openssl-devel -y
Debian Linux
Bash
apt install openssl libssl-dev -y

参考