Linux安装nginx并配置https
第一步:安装下载nginx安装包
# 下载 /usr/local
wget http://nginx.org/download/nginx-1.15.12.tar.gz
# 解压
tar -zxvf nginx-1.15.12.tar.gz
第二步:编译安装并配置https
# 进入nginx解压后的目录
cd /usr/local/nginx-1.15.12
# 配置ssl模块(默认配置)
./configure --with-http_ssl_module
# 编译
make
# 安装
make install
第三步:检查是否有ssl
# 进入/usr/local/nginx/sbin目录
./nginx -V
显示 configure arguments: --with-http_ssl_module 成功
nginx version: nginx/1.15.12
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-17) (GCC)
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --with-http_ssl_module
第四步:生成ssl证书(介绍生成三种)
生成一个RSA秘钥
[root@localhost ssl]# openssl genrsa -des3 -out nginx.key 1024 #实际使用中看服务器性能,如果足够好也可以使用4096位秘钥
Generating RSA private key, 1024 bit long modulus
.......++++++
...++++++
e is 65537 (0x10001)
Enter pass phrase for nginx.key: #输入密码,自定义,不少于4个字符
Verifying - Enter pass phrase for nginx.key: #确认密码
生成一个证书请求(三种不同)
第一种: 本地局域网 例如: 192.168.99.122
[root@localhost ssl]# openssl req -new -key nginx.key -out nginx.csr
Enter pass phrase for nginx.key: #输入刚刚创建的秘密码
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [XX]:CN