编译安装nginx的环境

yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel

下载nginx安装包

cd /usr/local/src
wget http://nginx.org/download/nginx-1.18.0.tar.gz
tar zxvf nginx-1.18.0.tar.gz

编译安装nginx

cd nginx-1.18.0
# 配置
./configure --prefix=/usr/local/nginx --with-http_ssl_module
# 编译,安装
make && make install
# 查询是否安装成功
/usr/local/nginx/sbin/nginx -V # 出现这个安装成功出现
nginx version: nginx/1.18.0
built by gcc 9.3.1 20200408 (Red Hat 9.3.1-2) (GCC)
built with OpenSSL 1.0.2k-fips 26 Jan 2017
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --with-http_ssl_module

配置nginx.conf

# http自动跳转到https
server {
listen 80;
server_name localhost; #将localhost修改为您证书绑定的域名,例如:www.example.com。
rewrite ^(.*)$ https://$host$1 permanent; #将所有http请求通过rewrite重定向到https。
location / {
index index.html index.htm;
}
} # ssl配置
server {
listen 443 ssl;
server_name localhost;
root html;
index index.html index.htm;
ssl_certificate cert/domain name.pem; #将domain name.pem替换成您证书的文件名。
ssl_certificate_key cert/domain name.key; #将domain name.key替换成您证书的密钥文件名。
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
location / {
index index.html index.htm;
}
}

Test

# http自动跳转到https
server {
listen 80;
server_name localhost; #将localhost修改为您证书绑定的域名,例如:www.example.com。
rewrite ^(.*)$ https://$host$1 permanent; #将所有http请求通过rewrite重定向到https。
location / {
index index.html index.htm;
}
} # ssl配置
server {
listen 443 ssl;
server_name localhost;
root html;
index index.html index.htm;
ssl_certificate /usr/local/nginx/cert/4329893_qra.psmtech.com.cn.pem; #将domain name.pem替换成您证书的文件名。
ssl_certificate_key /usr/local/nginx/cert/4329893_qra.psmtech.com.cn.key; #将domain name.key替换成您证书的密钥文件名。
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
location / {
index index.html index.htm;
}
}

源码安装nginx开启SSL功能的更多相关文章

  1. 源码安装nginx 方法二

    yum 仓库不能用大写字母 [root@oldboy conf.d]# gzip * 压缩当前目录下的所有文件 gzip ./* gzip . gzip./ # 关闭防火墙和selinux [root ...

  2. 源码安装nginx以及平滑升级

                                                           源码安装nginx以及平滑升级                               ...

  3. linux源码安装nginx

    任务目标:源码安装nginx,作为web服务修改配置文件,让配置生效,验证配置 首先要去官网nginx.org下载一个tar包: tar xvf 解包 进入到解包出来的目录,对configure进行配 ...

  4. 源码安装nginx env

    源码安装nginx 1. For ubuntu:18.04 apt -y install build-essential libtool libpcre3 libpcre3-dev zlib1g-de ...

  5. Linux之源码安装nginx,并按照作业一描述的那样去测试使用

    作业五:源码安装nginx,并按照作业一描述的那样去测试使用 [root@localhost nginx]# yum install gcc-* glibc-* openssl openssl-dev ...

  6. 源码安装Nginx以及用systemctl管理

    一.源码安装Nginx: 先安装gcc编译器(安装过的可以忽略) [root@localhost ~]# yum -y install gcc gcc-c++ wget 进入src目录 [root@l ...

  7. 工作笔记-- 源码安装nginx

    源码安装nginx 1.安装nginx的依赖包 [root@localhost ~]# yum -y install gcc gcc-c++ openssl openssl-devel pcre pc ...

  8. nginx使用-1(源码安装nginx)

    Nginx概述 Nginx (engine x) 是一个高性能的HTTP和反向代理web服务器,同时也提供了IMAP/POP3/SMTP服务.Nginx是由伊戈尔·赛索耶夫为俄罗斯访问量第二的Ramb ...

  9. centos7 中源码安装nginx

    使用nginx有一段时间了,还是有很多东西不懂的,在这里做一下自己学习过程中的一些整理,能使自己得到提升. 1.环境:centos7 1511  最小化安装 2.下载nginx,可以在系统中下载,也可 ...

随机推荐

  1. css--filter(滤镜) 属性

    前言 前段时间找工作面试官问到一个问题,你如何将一个网页整体置灰?面试遇到这样的问题,一下束手无策,之前没有接触过这样的需求,因此没有回答上来,面试结束我才知道了这是考查对 CSS3 的新属性的了解. ...

  2. Django 基础05篇 上下文管理和前端代码复用

    一.上下文管理器 在views中重复使用的代码,可以通过上下文管理器(在setting.py文件中的TEMPLATES中配置)中实现,减少代码冗余 上下文管理器的处理流程如下: 1.先走完views里 ...

  3. 高校表白App-团队冲刺第二天

    今天要做什么 今天要把昨天的activity进行完善,并且加上计时跳转的功能,将其设置为主页面,设置两种跳转功能. 遇到的问题 今天没遇到什么大的问题,只是在进行编写的时候,又出现了R文件无法找到的情 ...

  4. dart pub上传失败如何解决

    问题: Flutter Exception: Pub will wait for a while before trying to connect again. 解决 1.设置终端代理 export ...

  5. 在Springboot + Mybaitis-plus 项目中利用Jackson实现json对java多态的(反)序列化

    Jackson允许配置多态类型处理,当JSON面对的转换对象是一个接口.抽象类或者一个基类的时候,可以通过一定配置实现JSON的转换.在实际项目中,Controller层接收入参以及在Dao层将对象以 ...

  6. Spring总结之SpringMvc上

    一.简介 Spring Web MVC是一种基于Java的实现了Web MVC设计模式的请求驱动类型的轻量级Web框架. 二.流程架构 1.用户发送请求至 前端控制器DispatcherServlet ...

  7. Pytest单元测试框架之FixTure内置临时文件tmpdir操作

    1.前言:某些接口需要引用上个接口返回的值,作为下个接口的入参,但笔者又不想在本地维护及创建此文件,此时引出fixture内置函数中的临时文件存储tmpdir 2.首先下面的源码是使用flask框架写 ...

  8. [考试总结]noip模拟7

    为啥博客园 \(\LaTeX\) 老挂???! \(\huge{\text{菜}}\) 刚开始写 \(T1\) 的时候,在看到后缀前缀之后,直接想到 \(AC\) 自动机,在画了半个 \(trie\) ...

  9. 如何反编译Python写的exe到py

    参考链接: https://blog.csdn.net/qq_44198436/article/details/97314626?depth_1-utm_source=distribute.pc_re ...

  10. 【阅读笔记】Java核心技术卷一 #1.Chapter3

    3 Java的基本程序设计结构 3.1 一个简单的 Java 应用程序(略) 3.2 注释(略) 3.3 数据类型 8种基本类型 byte,short,int,long float,double ch ...