分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 网页技术

centos7编译安装nginx及无缝升级https

发布时间:2023-09-06 01:49责任编辑:沈小雨关键词:nginxhttp编译

安装依赖:

[html] view plain copy
 
  1. yum install -y gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel  
下载nginx:
[html] view plain copy
 
  1. wget -c https://nginx.org/download/nginx-1.10.1.tar.gz  
  2. tar -zxvf nginx-1.10.1.tar.gz  
  3. cd nginx-1.10.1  
配置nginx:

1、默认配置

[html] view plain copy
 
  1. ./configure  
2、自定义配置
[html] view plain copy
 
  1. ./configure \  
  2. --prefix=/usr/local/nginx \  
  3. --conf-path=/usr/local/nginx/conf/nginx.conf \  
  4. --pid-path=/usr/local/nginx/conf/nginx.pid \  
  5. --lock-path=/var/lock/nginx.lock \  
  6. --error-log-path=/var/log/nginx/error.log \  
  7. --http-log-path=/var/log/nginx/access.log \  
  8. --with-http_gzip_static_module \  
  9. --http-client-body-temp-path=/var/temp/nginx/client \  
  10. --http-proxy-temp-path=/var/temp/nginx/proxy \  
  11. --http-fastcgi-temp-path=/var/temp/nginx/fastcgi \  
  12. --http-uwsgi-temp-path=/var/temp/nginx/uwsgi \  
  13. --http-scgi-temp-path=/var/temp/nginx/scgi  
编译安装nginx:
[html] view plain copy
 
  1. make  
  2. make install  
设置nginx开机并启动:
[html] view plain copy
 
  1. vi /etc/rc.local  
在rc.local文件中写入:
[html] view plain copy
 
  1. /usr/local/nginx/sbin/nginx  
设置启动文件权限:
[html] view plain copy
 
  1. chmod 755 /etc/rc.local  
启动和停止nginx命令:
[html] view plain copy
 
  1. cd /usr/local/nginx/sbin/  
  2. ./nginx   
  3. ./nginx -s stop  
  4. ./nginx -s quit  
  5. ./nginx -s reload  
nginx无缝升级https:

1、查看nginx是否支持ssl:1、查看nginx是否支持ssl:

[html] view plain copy
 
  1. /usr/local/nginx/sbin/nginx -V  
查看 configure arguments 信息中是否包含 -with-http_ssl_module 字样,如果没有则需要重新编译。找到之前安装 Nginx 时的编译目录,配置ssl模块:
[html] view plain copy
 
  1. ./configure --with-http_ssl_module  
  2. make  
2、因为这次是升级nginx,所以不需要执行 make install,首先备份原nginx执行脚本:
[html] view plain copy
 
  1. mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.old  

3、把新编译的nginx执行脚本拷贝到相应的目录下:

[html] view plain copy
 
  1. cd objs/  
  2. cp nginx /usr/local/nginx/sbin/  
4、最后进行平滑升级
[html] view plain copy
 
  1. cd ..  
  2. make upgrade  
5、编辑配置文件
[html] view plain copy
 
  1. cd /usr/local/nginx/conf  
  2. vim nginx.conf  
[html] view plain copy
 
  1. listen       443;  
  2. server_name  域名;  
  3. index index.html index.htm index.php;  
  4. root 项目根路径;  
  5.   
  6. ssl on;  
  7. ssl_certificate 证书路径及文件;  
  8. ssl_certificate_key 证书路径及文件;  
  9.   
  10. ssl_session_timeout  5m;  
  11.   
  12. ssl_protocols TLSv1 TLSv1.1 TLSv1.2;  
  13. ssl_ciphers  ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;  
  14. ssl_prefer_server_ciphers  on;  
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/dreamsqifan/article/details/73467672

centos7编译安装nginx及无缝升级https

原文地址:https://www.cnblogs.com/azhqiang/p/8794527.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved