编译安装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. python adb 关闭拼多多

    def gbpdd(sjh): aaka="adb -s {0} shell am force-stop com.xunmeng.pinduoduo".format(sjh) aa ...

  2. python使用selenium,webdriver自动下载百度网盘内容

    想实现一个自动下载微信公众号分享百度网盘图片链接的爬虫,使用selenium和火狐的webdriver进行完成 1.首先根据自己的浏览器下载相应的webdriver驱动器,python中导入selen ...

  3. Motion Planning 是什么

    前言与引用 这一个呢,主要是自己突然看一篇论文的时候不知道 为什么他提出的方法对于规划来说就是好的,规划又应该分为哪几个部分,解决的是哪几个部分的问题?带着这个问题,我就去搜:Motion Plann ...

  4. Eclipse配置反编译插件jadclipse

    参考自:https://blog.csdn.net/moneyshi/article/details/79715891 Jad是一个Java的一个反编译工具,是用命令行执行,和通常JDK自带的java ...

  5. Python+Requests+Xpath实现动态参数获取实战

    1.古诗文网直接登录时,用浏览器F12抓取登录接口的入参,我们可以看到框起来的key对应的value是动态参数生成的,需获取到: 2.登录接口入参的值一般是登录接口返回的原数据值,若刷新后接口与对应源 ...

  6. C++ Primer Plus 第四章 复合类型 学习笔记

    第四章 复合类型 1. 数组概述 1.1 数组的定义 数组(array)是一种数据格式,能够存储多个同类型的值.每个值都存储在一个独立的数组元素中,计算机在内存中依次存储数组的各个元素. 数组声明的三 ...

  7. Html模板引擎Handlerbars使用demo

    1.自定义demo <html> <head> <script src="./handlebars-v4.0.12.js"></scrip ...

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

    又发现模拟 \(22\) 的总结也咕掉了,现在补上它... 似乎又是gg的一场. 以为自己的部分分数打的很全,然而到后面发现自己的树剖打假了 \(\color{green}{\huge{\text{树 ...

  9. php-socket通信演示

    client: error_reporting(E_ALL); set_time_limit(0); echo "<h2>TCP/IP Connection</h2> ...

  10. 承载童年的游戏机,已停产!但我在 GitHub 找到了它们

    那些年,上网用的是电话线,小企鹅也只会笨拙地左右摇晃,手机还只是打电话的工具.虽然那些年没有互联网,但游戏机承载了我的童年. 小时候我老是追着我的两个哥哥,他们带我玩了好多种游戏机,比如街机.红白机. ...