nginx源码安装及配置https自签名
nginx源码安装
一般来说,用户的服务器都是不练外网的。有的甚至可能没有rpm源。所以个人还是喜欢从源码进行安装。安装参考以下的两个链接:
官方从源码安装的介绍
官方源码安装包
虽然官方已经有了安装介绍,接下来还是自己安装操作一次。
安装基础环境
安装nginx之前要先安装编译环境gcc,g++,pcre, zlib,ssl 开发库之类的需要提前装好,安装命令如下:
yum -y groupinstall 'Development Tools'
yum -y install pcre pcre-devel
yum -y install openssl openssl-devel
上传源码,解压预编译源码:
tar -zxvf nginx-1.23.0.tar.gz
cd nginx-1.23.0
./configure --prefix=/usr/local/nginx --with-http_ssl_module
解释一下,–prefix是安装路径,一般都是建议放到/usr/local/nginx目录。–with-http_ssl_module是添加nginx的https模块。
如果不经过步骤1,有可能报下面的错误,像下面的错误就是没有安装PCRE:
checking for PCRE library ... not found
checking for PCRE library in /usr/local/ ... not found
checking for PCRE library in /usr/include/pcre/ ... not found
checking for PCRE library in /usr/pkg/ ... not found
checking for PCRE library in /opt/local/ ... not found
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.
编译安装
make && make install
ln -s /usr/local/nginx/sbin/nginx /usr/sbin/nginx #为了方便起见,创建软连接前面的路径是执行路径
安装完毕后启动验证一下服务和对应的模块:
[root@localhost bin]# nginx -V
nginx version: nginx/1.23.0
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (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
如果连不上,请检查是否关闭了防火墙
systemctl stop firewalld.service
HTTPS自签名
创建证书文件夹并生成key
cd ~ && makedir key && cd key
openssl genrsa -des3 -out ssl.key 2048
过程中随便输入1个密码,要输入两次。
修改key中的密码
mv ssl.key xxx.key
openssl rsa -in xxx.key -out ssl.key #输入上一步中的密码
rm xxx.key
生成crt证书并放到nginx目录下
[root@localhost key]# openssl req -new -key ssl.key -out ssl.csr
#过程中间一路回车
[root@localhost key]# openssl x509 -req -days 365 -in ssl.csr -signkey ssl.key -out ssl.crt
Signature ok
subject=/C=XX/L=Default City/O=Default Company Ltd
Getting Private key
[root@localhost key]# ll
total 12
-rw-r--r--. 1 root root 1103 Jul 9 08:43 ssl.crt
-rw-r--r--. 1 root root 952 Jul 9 08:34 ssl.csr
-rw-r--r--. 1 root root 1679 Jul 9 08:31 ssl.key
[root@localhost key]#
[root@localhost key]# cp * /usr/local/nginx/conf/
修改nginx配置文件
先备份历史文件
找到最后面的配置文件,放开:
server {listen 443 ssl;server_name localhost;ssl_certificate ssl.crt; #修改点ssl_certificate_key ssl.key; #修改点ssl_session_cache shared:SSL:1m;ssl_session_timeout 5m;ssl_ciphers HIGH:!aNULL:!MD5;ssl_prefer_server_ciphers on;location / {root html;index index.html index.htm;}}
如同坑系列里面提的,一定要先验证配置文件,然后再重启
[root@localhost nginx]# nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
大功告成!!
nginx源码安装及配置https自签名相关推荐
- Nginx源码安装及调优配置
由于Nginx本身的一些优点,轻量,开源,易用,越来越多的公司使用nginx作为自己公司的web应用服务器,本文详细介绍nginx源码安装的同时并对nginx进行优化配置. Nginx编译前的优化 [ ...
- CentOS上PHP源码安装和配置
CentOS上PHP源码安装和配置 此文是在CentOS 7上已经部署了Nginx的基础上进行的 关于CentOS7上安装Nginx,可参考我之前的文章: CentOS上Nginx安装记录 我们现在在 ...
- nginx源码安装教程(CentOS)
1.说明 官方源码安装说明:http://nginx.org/en/docs/configure.html 源码包下载地址:http://nginx.org/en/download.html 版本说明 ...
- php mysql 源码 安装教程_源码安装和配置apache(httpd)和 PHP 和 mysql全过程(一)...
[服务器环境为:CentOS6.5 64位目标:搭建LNMP(Linux + Nginx + MySQL + PHP +SVN),其中svn是用来代替ftp,方便开发中调试同步代码相关目录:所有软件都 ...
- 一、Nginx源码安装与yum安装
目录标题 源码安装: yum安装: 源码安装: wget http://nginx.org/download/nginx-1.15.8.tar.gz tar -zxvf nginx-1.15.8.ta ...
- Nginx源码安装及应用
一:Nginx简介: Nginx ("engine x") 是一个高性能的HTTP和反向代理服务器.在高连接并发的情况下,Nginx是Apache服务器不错的替代品. Nginx作 ...
- mysql源码启动_Mysql源码安装、配置、初始化及启动
[在此处输入文章标题] 主机环境redhat6.5 64位 实验环境服务端ip 172.25.29.1 mysql 安装包mysql-boost-5.7.11.tar.gz cmake-2.8.12 ...
- nginx mysql5.7_Centos7+Php7+Mysql5.7+Nginx源码安装实战部署手册
本文以Centos 7.1+Php 7.1.3+Mysql5.7.17为例,介绍Centos7+Php7+Mysql5.7+Nginx 1.10.3源码安装实战部署的过程. 一.准备工作 软件获取 二 ...
- nginx 源码安装并开启gzip静态压缩
前言 Nginx 使用 yum (Centos7) 在线安装方式无法开启 gzip 静态压缩,只能采用源码安装并开启 gzip 静态压缩(gzip_static). 安装下载工具 yum instal ...
- centos7.4下安装配置PHP服务(源码安装)并配置nginx支持php
一.检查php是否已经安装,使用php -v,是否能够看到版本号,或者使用rpm -qa | grep php查看是否安装过. # yum remove php* -y 二.依赖包安装 Linux软件 ...
最新文章
- 英特尔在移动市场另辟蹊径
- VMware Virtual SAN 互操作性:OpenStack
- nginx 修改并隐藏版本号
- PL/SQL复合变量
- TriggerMesh开源用于多云环境的Knative Event Sources
- 十月 android版本分布,安兔兔发布2018年10月份Android手机性能排行榜
- Java技术:项目构建工具Maven最佳替代者gradle介绍
- 计算机公式column,函数公式的左膀右臂:ROW、COLUMN函数知多少
- 双网卡主机配置oracle监听,VirtualBox设置双网卡实现虚机上网及主宿机互访
- 【离散数学】命题逻辑联结词的自然语言表述
- C#将LINQ数据集转换为Datatable
- 通达信报计算机内存不足,导入通达信股票数据至内存数组中的方法和代码
- 博世传感器调试笔记(二)加速度及陀螺仪传感器BMI160
- 2021肿瘤早筛行业研究报告
- java 中文分词转拼音_如何实现拼音与汉字的互相转换
- 5种Windows网络模型之select模型
- python爬取海量PPT模板,再也不用辛苦地找模板了
- linux添加core文件位置,Linux生成core文件、core文件路径设置
- UWB,可以应用到生活中的方方面面
- Unity 3D 泰课网小球移动 相机跟随