在已经安装的nginx上,增加ssl模块

1. /usr/local/nginx/sbin/nginx -V 查看nginx版本与编译安装了哪些模块

nginx version: nginx/1.16.1
built by gcc 7.4.0 (Ubuntu 7.4.0-1ubuntu1~18.04.1)
built with OpenSSL 1.1.0f  25 May 2017
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --with-pcre=../pcre-8.43 --with-zlib=../zlib-1.2.11 

2. 安装openssh(如果操作系统之前没有安装)

3. 下载openssl-1.1.0f(版本看操作时的情况了),不必安装

4. 可能还需要下载安装时用到的pcre-8.43与zlib-1.2.11(版本看操作时的情况了),不必安装
5. 下载nginx 1.10.3, 并且configure

./configure \
 --prefix=/usr/local/nginx \
 --with-http_stub_status_module \
 --with-http_ssl_module \
--with-pcre=../pcre-8.43 \
--with-zlib=../zlib-1.2.11 \
--with-openssl=../openssl-1.1.0f

6. 执行make ,千万不要make install 否则会覆盖现有的nginx

7. 关闭nginx

8. copy  ~/download/nginx-1.10.3/objs/nginx 到现有的/usr/local/nginx/sbin/nginx

9. /usr/local/nginx/sbin/nginx -V 查看编译安装的模块

nginx version: nginx/1.16.1
built by gcc 7.4.0 (Ubuntu 7.4.0-1ubuntu1~18.04.1)
built with OpenSSL 1.1.0f  25 May 2017
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre=../pcre-8.43 --with-zlib=../zlib-1.2.11 --with-openssl=../openssl-1.1.0f

10. 修改nginx.conf文件

 

server {
  server_name xxx.yyy.com;
  listen 443;
  ssl on;
  ssl_certificate /usr/local/nginx/conf/xxx.com_server.txt; #公钥
  ssl_certificate_key /usr/local/nginx/conf/xxx.com_private.txt; #私钥

  location / {
      # location的一堆配置
      # 
      #
      # ################
  }

  error_page   500 502 503 504  /50x.html;
  location = /50x.html {
      root   html;
  }
}
###########################80端口的处理###############################
server {
  listen 80;
        server_name  xxx.yyy.com;
        send_timeout 1800;

        rewrite ^(.*)$  https://xxx.yyy.com$1 permanent; # 80端口跳转
}

  • 1
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值