下載

wget http://nginx.org/download/nginx-1.19.6.tar.gz

安裝

./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module 

make && make install

安装第3方库

安裝pcre

#!/bin/bash
pcre_version="8.36"

pcre_url="http://jaist.dl.sourceforge.net/project/pcre/pcre/"$pcre_version"/pcre-"$pcre_version".tar.gz"
wget $pcre_url

./configure
make && make install

安裝open_ssl

#!/bin/bash

openssl_version="1.1.1"

echo "下载:openssl-"$openssl_version""
openssl_url="http://www.openssl.org/source/openssl-"$openssl_version".tar.gz"
wget $openssl_url

tar -zxvf openssl-"$openssl_version".tar.gz

./config
make && make install

安装zlib

#!/bin/bash
zlib_version="1.2.11"
echo "下载:zlib-"$zlib_version""
zlib_url="http://zlib.net/zlib-"$zlib_version".tar.gz"
wget $zlib_url
echo "解压:zlib-"$zlib_version".tar.gz"
tar -zxvf zlib-"$zlib_version".tar.gz
echo "进入目录:zlib-"$zlib_version""
cd zlib-"$zlib_version"

./configure
make && make install

問題

問題1

configure: error: You need a C++ compiler for C++ support.

yum -y install gcc-c++

问题2

./nginx: error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory

已经装了openssl的情况下还报这个错

# find / -name libssl.so.1.1
# 我知道具体的安装目录
# 返回/software/openssl-1.1.1/libssl.so.1.1
find /software -name libssl.so.1.1

解决

ln -s /software/openssl-1.1.1/libssl.so.1.1 /usr/lib64/libssl.so.1.1
ln -s /software/openssl-1.1.1/libcrypto.so.1.1 /usr/lib64/libcrypto.so.1.1

问题3

nginx启动了,发现访问不了,有可能是Linux防火墙已经开启, 把80端口屏蔽了

配置

./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
./configure
--sbin-path=/usr/local/nginx/nginx
--conf-path=/usr/local/nginx/nginx.conf
--pid-path=/usr/local/nginx/nginx.pid
--with-http_ssl_module
--with-pcre=../pcre-8.44
--with-zlib=../zlib-1.2.11