Centos6.8配置HTTPS
HTTPS服务
http+openssl
环境要求:
CA证书:		192.168.1.103
网站服务器:	192.168.1.104
客户端:		192.168.1.107  (linux图形化界面)
内核:(客户端是centos 7图形化)
# cat /etc/centos-release 
	  CentOS release 6.8 (Final
# uname -r
	  2.6.32-642.el6.x86_64
网站服务器配置:
# mkdir /opop
# cd /opop
# yum -y install openssl openssl-devel  mod-ssl  libcurl  gcc*  expat-devel  pcre-devel
**********************************************************************************************
yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gd gd-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers             注:缺哪个依赖自己装上即可
***********************************************************************************************
注:要支持ssl加密功能就需要安装openssl openssl-devel mod_ssl
# wget http://mirrors.hust.edu.cn/apache//httpd/httpd-2.4.33.tar.gz
# wget http://mirrors.hust.edu.cn/apache//apr/apr-1.6.3.tar.gz
# wget http://mirrors.shu.edu.cn/apache//apr/apr-util-1.6.1.tar.gz
# wget https://ftp.pcre.org/pub/pcre/pcre-8.42.tar.gz               // Pcre基于perl的兼容的正则表达式的支持
# wget https://github.com/nghttp2/nghttp2/releases/download/v1.24.0/nghttp2-1.24.0.tar.bz2
# wget https://curl.haxx.se/download/curl-7.60.0.tar.gz
# wget http://www.digip.org/jansson/releases/jansson-2.11.tar.gz
# wget https://jaist.dl.sourceforge.net/project/libpng/zlib/1.2.11/zlib-1.2.11.tar.gz
# for i in `ls`;do tar -zxvf $i;done
# tar -jxvf nghttp2-1.24.0.tar.bz2
# cd pcre-8.42
# ./configure && make && make install
# cd nghttp2-1.24.0
# ./configure && make && make install
# cd curl-7.60.0
# ./configure && make && make install
# cd zlib-1.2.11
# ./configure && make && make install
# cd jansson-2.11
# ./configure && make && make install
# cd ..
# cp -r apr-1.6.3 httpd-2.4.33/srclib/apr
# cp -r apr-util-1.6.1 httpd-2.4.33/srclib/apr-util
(有的需要自己装,有的可以直接发到httpd-2.4.33/srclib目录下,根据./configur时的提示进行修改)

安装Apache:
# cd httpd-2.4.33
# ./configure --prefix=/usr/local/apache2 --sysconfdir=/usr/local/apache2/etc --enable-ssl --with-crypto --with-included-apr  --with-apr=/opop/httpd-2.4.33/srclib/apr   --with-apr-util=/opop/httpd-2.4.33/srclib/apr-util  --with-pcre=/opop/httpd-2.4.33/srclib/pcre/pcre-config --with-jansson=/opop/httpd-2.4.33/srclib/jansson --with-curl=/opop/httpd-2.4.33/srclib/curl --enable-http --enable-include  --with-ldap
# make && make install
配置CA服务器端:
证书位置:cd /etc/pki/CA/
# cd /etc/pki/CA/
# (umask 077;openssl genrsa -out private/cakey.pem 2048)        //这也是一条命令
注:openssl是命令,genrsa是要用rsa的算法输出(-out)一个在"当前"目录下的private目录的证书,证书长度为2048。
	因为这个文件不能随意的看里面的内容才在命令的最开始用了文件的反码,077创建出来的文件权限就是700
打开证书的配置文件修改一些参数,使证书生成一些默认的值:
# vim /etc/pki/tls/openssl.cnf
	  [ req_distinguished_name ]	    	//在req_distinguished_name区域内修改
	  countryName_default             = CN         		//默认国家
	  stateOrProvinceName_default     = BJ       		//默认省份,该条默认是注释状态
	  localityName_default    = BJ                 		//默认城市
	  0.organizationName_default      = LENOVO       		//默认组织、公司
	  organizationalUnitName_default  = cloud computing          //默认单位名称,该条默认是注释状态,cloud computing是云计算的意思
生成证书:
# openssl req -new -x509 -key private/cakey.pem -out cacert.pem -days 3650         //因为在模板里面已经配置好所以下面只要全部回车即可
  Country Name (2 letter code) [CN]:            //回车
	  State or Province Name (full name) [BJ]:	  //回车
	  Locality Name (eg, city) [BJ]:	    			//回车
	  Organization Name (eg, company) [LENOVO]:	  //回车
	  Organizational Unit Name (eg, section) [cloud computing]:	  	//回车
	  Common Name (eg, your name or your server's hostname) []:  		//回车
	  Email Address []:root@djkk.com                  //手动输入一个邮箱地址即可
返回到网站服务器端:
# cd /usr/local/apache2/
# mkdir ssl
# cd ssl/
# (umask 077;openssl genrsa 1024 > httpd.key)
# openssl req -new -key httpd.key -out httpd.crq
	  Country Name (2 letter code) [XX]: CN                         //手动输入,要和证书服务器上的一致
	  State or Province Name (full name) []:BJ                      //手动输入,要和证书服务器上的一致
	  Locality Name (eg, city) [Default City]:BJ                    //手动输入,要和证书服务器上的一致
	  Organization Name (eg, company) [Default Company Ltd]:LENOVO          //手动输入,要和证书服务器上的一致
	  Organizational Unit Name (eg, section) []:cloud computing             //手动输入,要和证书服务器上的一致
	  Common Name (eg, your name or your server's hostname) []:www.biubiubiu.com   //这里你的网站是什么域名就写什么
	  Email Address []:root@djkk.com                              //邮箱按需定即可
Please enter the following 'extra' attributes
	to be sent with your certificate request
	A challenge password []:                               //额外信息按需配置,会和证书一起颁发出去,我这里没写额外的信息,回车
	An optional company name []:                        //额外信息按需配置,会和证书一起颁发出去,我这里没写额外的信息,回车
注:将生成的httpd.crq发送到CA服务器上的/tmp目录,该步一定要注意....
# scp httpd.crq 192.168.1.103:/tmp
启用虚拟主机:
# vim /usr/local/apache2/etc/httpd.conf
	  Include etc/extra/httpd-vhosts.conf           //启用该选项,默认是关闭状态
进行虚拟主机的配置:
# cp /usr/local/apache2/etc/extra/httpd-vhosts.conf /usr/local/apache2/etc/extra/httpd-vhosts.conf.bak
# vim /usr/local/apache2/etc/extra/httpd-vhosts.conf
	  <VirtualHost *:80>
	      DocumentRoot "/usr/local/apache2/htdocs/www"
	      ServerName www.biubiubiu.com
	  </VirtualHost>
  <VirtualHost *:80>
	      DocumentRoot "/usr/local/apache2/htdocs/edu"
	      ServerName edu.biubiubiu.com
	  </VirtualHost>
		    //虚拟主机区域留2个区域即可,其他全部注释并进行修改
生成主页文件:
# cd /usr/local/apache2/htdocs/
# mkdir www edu
# vim www/index.html
	  Finally finished.....
# vim edu/index.html
	  It's not easy....
打开win系统上面 C:\Windows\System32\drivers\etc 中hosts文件进行添加网站服务器进行测试:
		  192.168.1.104	  www.biubiubiu.com
		  192.168.1.104	  edu.biubiubiu.com
启动Apache服务:
# /usr/local/apache2/bin/apachectl start         {restart | stop}
在 win 系统上访问 www.biubiubiu.com 和 edu.biubiubiu.com 域名进行测试
回到CA服务器:
[root@192 CA]# pwd
	  /etc/pki/CA
# touch index.txt
# echo "00" > serial     	//数字0
签署证书:
# openssl ca -in /tmp/httpd.crq -out /tmp/httpd.crt -days 3650            //注意:一个是crq,一个是crt。按2次y即可
# ll /tmp/         //查看证书有没成功签署
回到网站服务器:
# scp 192.168.1.103:/tmp/httpd.crt .  //将CA服务器上生成的证书拿到当前/usr/local/apache2/ssl目录下,不要忘记后面的    点
//此时CA服务器上的crq和crt文件就没用了可以删除掉
证书申请成功,需要让证书在网站生效:
# vim /usr/local/apache2/etc/httpd.conf
	Include etc/extra/httpd-ssl.conf             	//启用该项,默认是注释状态
修改ssl模板的配置文件:
# vim /usr/local/apache2/etc/extra/httpd-ssl.conf
		  Listen 443             	//监听44端口
		  ...........略一部分内容..............
		  <VirtualHost _default_:443>
  #   General setup for the virtual host
		  DocumentRoot "/usr/local/apache2/htdocs/www"           //网页在什么位置
		  ServerName www.biubiubiu.com:443                       //改成自己的域名
		  #ServerAdmin you@example.com                             //注释掉
		  #ErrorLog "/usr/local/apache2/logs/error_log"  		 //注释掉
		  #TransferLog "/usr/local/apache2/logs/access_log"      //注释掉
		  ...........略一部分内容..............
		  SSLEngine on              //启用加密的引擎
		  ...........略一部分内容..............
		  SSLCertificateFile "/usr/local/apache2/ssl/httpd.crt"         //证书位置
		  ...........略一部分内容..............
		   SSLCertificateKeyFile "/usr/local/apache2/ssl/httpd.key"      //秘钥位置
# /usr/local/apache2/bin/apachectl -t               //检查Apache配置文件语法,这里会有一个语法错误.....
	  AH00526: Syntax error on line 52 of /usr/local/apache2/etc/extra/httpd-ssl.conf:
	  Invalid command 'SSLCipherSuite', perhaps misspelled or defined by a module not included in the server configuration
解决办法:

# vim /usr/local/apache2/etc/httpd.conf
	  LoadModule socache_shmcb_module modules/mod_socache_shmcb.so           //启用该模块
	  ...........略一部分内容..............
	  LoadModule ssl_module modules/mod_ssl.so                      //启用该模块
再来检查语法:
# /usr/local/apache2/bin/apachectl -t 
	Syntax OK                      //检查通过
重启Apache服务:
# /usr/local/apache2/bin/apachectl restart
客户端测试:
# vim /etc/hosts
192.168.1.104   www.biubiubiu.com
打开火狐浏览器访问 https://www.biubiubiu.com 和 https://edu.biubiubiu.com(会提示"您的连接不安全"字样)
高级--->添加例外--->查看--->(即能查看到我们的证书)--->确认安全例外--->即能查看到网页的具体内容--->完毕
注意:不同的浏览器显示出来的"效果"也会不同,注意访问时的"正确性"
Centos6.8配置HTTPS的更多相关文章
- centos6.8下配置https服务器
		centos6.8下配置https服务器 1.1 环境 l 系统环境:内核环境为2.6.32版本 64位的CentOS release 6.8 (Final) [root@localhost ~] ... 
- 使用Let’s Encrypt轻松配置https站点
		使用Let's Encrypt轻松配置https站点 https不仅能提高网站安全,更是被搜索引擎纳入排名的因素之一. 2015年10月份,微博上偶然看到Let's Encrypt 推出了beta版, ... 
- 在CentOS6上配置MHA过程全记录
		在CentOS6上配置MHA过程全记录 MHA(Master High Availability)是一款开源的MariaDB or MySQL高可用程序,为MariaDB or MySQL主从复制架构 ... 
- Nginx 配置HTTPS 与Node.js 配置HTTPS方法
		前段时间公司网站要求加上HTTPS安全CA证书,公司服务器全是阿里云服务器,并且配有负载均衡,所以选择直接在阿里云购买CA证书,阿里云有一种证书可以免费试用一年,决定申请此证书,阿里云证书需要验证,阿 ... 
- centos6 安装配置ss笔记
		2018-05-17 centos6 安装配置ss笔记 操作环境:Centos 6 x86_64 bbr 服务器地址:美国 1.准备VPS 在https://www.bwh1.net可购买,购买时已默 ... 
- CentOS6.5配置 cron
		CentOS6.5配置 cron 任务 - mengjiaoduan的博客 - CSDN博客https://blog.csdn.net/mengjiaoduan/article/details/649 ... 
- nginx配置https访问
		一.准备 环境:centos6.8 nginx:1.13.6 二.开始 首先安装依赖包: yum install -y gcc gcc-c++ autoconf automake make ... 
- Nginx配置Https
		1.申请证书: https://console.qcloud.com/ssl?utm_source=yingyongbao&utm_medium=ssl&utm_campaign=qc ... 
- 天河微信小程序入门:阿里云tomcat免费配置https
		天河君在第一时间通过了微信小程序验证,开启了我的微信小程序之旅.因为天河君之前是一名后端狗,对前端不是很了解,所以几乎可以认为是从零开始学做微信小程序.也希望有志在微信小程序方向做点事情的朋友能够和我 ... 
随机推荐
- 【Spring】12、Spring Security 四种使用方式
			spring security使用分类: 如何使用spring security,相信百度过的都知道,总共有四种用法,从简到深为:1.不用数据库,全部数据写在配置文件,这个也是官方文档里面的demo: ... 
- UserControl VS TemplatedControl
			一:首先来看一下UserControl 熟悉XAML的朋友们都知道,当我们创建一个用户控件的时候,VS会自动为我们生成一个XXX.xaml文件和XXX..xaml.cs文件,XAML文件用于进行控件的 ... 
- sublime text3快速生成html头部信息
			1.在网站开发过程中尤其写前台页面时要写头部很麻烦,怎么办呢?直接生成不更好吗? 这是快速生成的信息 2.方法: ctrl+shift+P打开命令面板 点击安装控制器 3.输入emmet 安装(以下图 ... 
- Python hashlib 模块
			使用 md5 加密 import hashlib m = hashlib.md5() m.update('hello world'.encode('utf-8')) # 加密的字符串需要先编码成 ut ... 
- react的生命周期需要知道的。
			有关React生命周期: 1.组件生命周期的执行次数是什么样子的??? 只执行一次: constructor.componentWillMount.componentDidMount 执行多次:ren ... 
- js小知识
			1.重新声明js变量,变量值不丢失 2.background-color 使用jquery获取样式中的background-color的值时发现在获取到的颜色值在IE中与Chrome.Firefox显 ... 
- 【工具相关】Web-Sublime Text2-安装插件HTMLPrettify
			一,打开Sublime Text2---->Preferences--->Browse Packages.--->查看Sublime Text2已经有的插件.如图所示. 二,在网上下 ... 
- Apex的对象共享
			Apex的对象共享 在Apex中,每个对象都有一个"共享"对象,其中存储了该对象的共享设定. 这种共享对象以"share"结尾.比如Account的共享对象是A ... 
- Linux高可靠技术
			1.进程挂死时,有后台监控程序检测重新拉起. 2.进程占用系统资源超过ulimit限定的资源时,会被ulimit杀死,同时配合后台监控程序,重新拉起进程,实现进程可靠性. 3.Linux系统的高可靠性 ... 
- wx python 基本控件
			一.静态文本控件 wx.StaticText(parent, id, label, pos=wx.DefaultPosition, size=wx.DefaultSize, style=0, n ... 
