1、下载 mod_ssl 和 apache

登入http://www.modssl.org/source/,下载

mod_ssl-2.8.31-1.3.41.targz;

2.8.31是mod_ssl版本号;1.3.41是apache版本号(mod_ssl和apache是一一对应的)

apache_1.3.41.tar.gz (https://archive.apache.org/dist/httpd/)

2、下载openssl

openssl-0.9.6.tar.gz  (http://www.openssl.org/source/openssl-0.9.6.tar.gz)

[注意:

将下载好的压缩包统一放在/usr/local/src/下(便于管理接下来的配置)]

解压

tar zxvf *.tar.gz

安装

一、配置apache

# cd /usr/local/src/apache_1.3.41

# ./configure --prefix=/usr/local/apache

二、编译openssl

# cd ../openssl-0.9.6

# ./config --prefix=/usr/local/openssl

[注意:这里是 config 而不是 configure。]

# make

# make test

# make install

make[1]: gcc: Command not found, download gcc http://ftp.gnu.org/gnu.

三、配置mod_ssl

# cd ../mod_ssl-2.8.31-1.3.41

# ./configure --with-apache=../apache_1.3.41

四、编译apache

# cd ../apache_1.3.41

# SSL_BASE=../openssl-0.9.6

#./configure --prefix=/usr/local/apache --enable-module=ssl --enable-shared=ssl

# make

五、生成CA

# make certificate TYPE=custom

这一步要生成你自己的 CA (如果你不知道,我也不能细说了,简单地 说就是认证中心),和用它来为你的服务器签署证书。 有很多东西要输入。

______________________________________________________________________

STEP 0: R选择算法,使用缺省的 RSA

______________________________________________________________________

STEP 1: 生成 ca.key,CA的私人密钥

______________________________________________________________________

STEP 2: Generating X.509 certificate signing request for CA [ca.csr]

You are about to be asked to enter information that will be incorporated

into your certificate request.

(为CA生成X.509的认证请求 ca.csr 要输入一些信息)

Country Name: cn 国家代码,两个字母

State or Provice name: fujain省份

Locality Name: xiamen城市名

Organization Name: home CA 组织名,随便写吧

Organization Unit Name: home CA

Common Name: home CA

Email Address: 365263452@qq.com我的Email

Certificate Validity: 4096 四千多天,够了吧

______________________________________________________________________

STEP 3: Generating X.509 certificate for CA signed by itself [ca.crt]

Certificate Version (1 or 3) [3]:1

______________________________________________________________________

STEP 4: Generating RSA private key for SERVER (1024 bit) [server.key]

(生成服务器的私人密钥,server.key)

______________________________________________________________________

STEP 5: Generating X.509 certificate signing request for SERVER [server.csr]

You are about to be asked to enter information that will be incorporated

into your certificate request.

(生成服务器的认证请求,server.csr 要输入一些信息,和STEP 2类似)

[注意:

Common Name是你的网站域名,如 www.mydomain.com

Certificate Validity不要太大,365就可以了]

Country Name: cn

State or Provice name: fujain

Locality Name: xiamen

Organization Name: home

Organization Unit Name: home

Common Name: home

Email Address: 365263452@qq.com

Certificate Validity: 365

______________________________________________________________________

STEP 6: Generating X.509 certificate signed by own CA [server.crt]

Certificate Version (1 or 3) [3]:1

(为你的服务器签名,得到server.crt)

______________________________________________________________________

STEP 7: Enrypting RSA private key of CA with a pass phrase for security [ca.key]

(为你的 ca.key加密)

Encrypt the private key now? [Y/n]: y

______________________________________________________________________

STEP 8: Enrypting RSA private key of SERVER with a pass phrase for security [server.key]

(为你的 server.key加密)

Encrypt the private key now? [Y/n]: y

六、apache安装

# make install

七、配置http.conf

# vi /usr/local/apache/conf/httpd.conf

修改BindAddress 和 ServerName 加入关于PHP4的行 .如果要改变 DocumentRoot 要记得把httpd.conf里SSL Virtual Host Context部分的DocumentRoot设定也改掉。

SSLCertificateFile和SSLCertificatKeyFile的设定也在 SSL Virtual Host Context部分。 它可能是这样设定的:

SSLCertificateFile /usr/local/apache/conf/ssl.crt/server.crt

SSLCertificateKeyFile /usr/local/apache/conf/ssl.key/server.key

要注意ssl.key ssl.crt等目录和文件的权限! 所有的key,csr,crt,prm文件都应该设为 400 属性!

八、启动https端口

# cd /usr/local/apache

# bin/apachectl startssl

输入密码:ccy123

[错误:

#cd /usr/local/apache/bin

#apachectl startssl]

九、测试

#netstat -tunal |grep 443

linux上浏览器 / window 36浏览器输入:https://localhost/

[注意:

在window上的IE浏览器输入会报错]

虽然在安装MOD_SSL时已经使用 make certificate 命令建立了服务器 的证书签名,但是有时你可能需要改变它。

当然有很多自动的脚本可以实现它,但是最可靠的方法是手工签署 证书。

十、维护

1)/usr/local/openssl/bin加入 执行文件查找路径。

2)将MOD_SSL的源代码目录树下的pkg.contrib目录中,文件名为 sign.sh拷贝到 /usr/local/openssl/bin 中

十一、创建CA

1)先建立一个 CA 的证书,首先为 CA 创建一个 RSA 私用密钥

#cd /usr/local/openssl/bin

#openssl genrsa -des3 -out ca.key 1024

#chmod 400 ca.key(生成 ca.key 文件属性改为400,并放在安全的地方)

#openssl rsa -noout -text -in ca.key(查看ca.key内容)

2)利用 CA 的 RSA 密钥创建一个自签署的 CA 证书(X.509结构)

#openssl req -new -x509 -days 3650 -key ca.key -out ca.crt

然后需要输入下列信息:

Country Name: cn

State or Province Name: fujain

Locality Name: xiamen

Organization Name: Family home

Organizational Unit Name: home

Common Name: home

Email Address: 365263452@qq.com

#chmod 400 ca.crt

#openssl x509 -noout -text -in ca.crt

十二、创建服务器证书签署请求

1)首先为你的 Apache 创建一个 RSA 私用密钥:

#openssl genrsa -des3 -out server.key 1024

#chmod 400 server.key

#openssl rsa -noout -text -in server.key

2)用server.key 生成证书签署请求 CSR.

#openssl req -new -key server.key -out server.csr

#openssl req -noout -text -in server.csr

3)下面可以签署证书了,需要用到脚本 sign.sh

#./sign.sh server.csr(可以得到server.crt)

#chmod 400 server.crt

#rm server.csr

十三、最后apache设置

如果你的apache编译参数prefix为/usr/local/apache,

拷贝server.crt 和 server.key 到 /usr/local/apache/conf .

修改httpd.conf 将下面的参数改为:

SSLCertificateFILE /usr/local/apache/conf/server.crt

SSLCertificateKeyFile /usr/local/apache/conf/server.key

十四、开启

#apachectl startssl

[注意:

配置修改后,必须重启apache才生效]

 

Linux_install mod_ssl openssl apache的更多相关文章

  1. 腾讯云CentOS Apache开启HTTPS

    1.申请SSL证书 https://console.qcloud.com/ssl?utm_source=yingyongbao&utm_medium=ssl&utm_campaign= ...

  2. CentOS 6下Apache的https虚拟主机实践

    题目:1.建立httpd服务器,要求: 提供两个基于名称的虚拟主机: (a)www1.buybybuy.com,页面文件目录为/web/vhosts/www1:错误日志为/var/log/httpd/ ...

  3. apache和nginx开启https

    1.安装mod_ssl和openssl yum -y install mod_ssl openssl 2.建立服务器密钥 mkdir /etc/httpd/conf.d/ssl.key/ cd /et ...

  4. CentOS下Apache安装SSL

    https是一个安全的访问方式,数据在传输过程中是加密的.https基于ssl. 一.安装apache和ssl模块1.安装apacheyum install httpd2.安装ssl模块yum ins ...

  5. Apache 配置HTTPS协议搭载SSL配置

    在设置Apache + SSL之前, 需要做:     安装Apache, 请参见: Windows环境下Apache的安装与虚拟目录的配置, 下载安装Apache时请下载带有ssl版本的Apache ...

  6. 《Apache数据传输加密、证书的制作》——涉及HTTPS协议

    首先了解http和https: HTTPS(Secure Hypertext Transfer Protocol)安全超文本传输协议. HTTPS和HTTP的区别: http是超文本传输协议,信息是明 ...

  7. apache http添加证书转成https

    使用yum安装的apache. 第一步,需要把准备好的证书上传到服务器.具体位置:/app/cacerts/ 第二步,安装ssl. 命令:yum install mod_ssl openssl 安装完 ...

  8. centos7基于SVN+Apache+IF.svnadmin实现SVN的web管理

    一.介绍 本文介绍的是CentOS7上搭建基于Apache.SVN Server.iF.svnadmin实现web后台可视化管理SVN. iF.SVNAdmin应用程序是Subversion授权文件基 ...

  9. windows Apache 环境下配置支持HTTPS的SSL证书

    windows Apache 环境下配置支持HTTPS的SSL证书 1.准备工作 1)在设置Apache + SSL之前, 需要做: 安装Apache, 下载安装Apache时请下载带有SSL版本的A ...

随机推荐

  1. [Java] TreeMap - 源代码学习笔记

    TreeMap 实现了 SortedMap 和 NavigableMap 接口,所有本文还会记录 SortedMap 和 NavigableMap 的阅读笔记. SortedMap 1. 排序的比较应 ...

  2. [Java] 继承中,父类被覆盖的成员变量、方法的可访问性

    在 Java 的继承机制里,在子类内部,可以访问父类被覆盖的变量和方法:在子类外部,可以访问父类的被覆盖变量,但是不能访问父类的被覆盖方法. 父类中被覆盖的方法不能在外部被方法,这是出于封装的考虑. ...

  3. unittest笔记

    学习资料: 官网: https://docs.python.org/2.7/library/unittest.html IBM Python自动单元测试框架: http://www.ibm.com/d ...

  4. java排序算法-插入排序

    public class InsertSortUtils { public static void main(String[] args) { insertSortTest(); shellSortT ...

  5. 多目标遗传算法 ------ NSGA-II (部分源码解析) 交叉操作 crossover.c

    遗传算法中的交叉操作是 对NSGA-II  源码分析的  最后一部分, 这一部分也是我 从读该算法源代码和看该算法论文理解偏差最大的  函数模块. 这里,首先提一下,遗传算法的  交叉操作.变异操作都 ...

  6. Sublime text 3 格式化HTML/css/js/json代码 插件

    JsFormat: 这里下载这插件包 https://github.com/jdc0589/JsFormat ,点油下角的zip就能下载 插件包放到sublime安装目录的Data\Packages目 ...

  7. atitit.提升研发效率的利器---重型框架与类库的差别与设计原则

    atitit.提升研发效率的利器---重型框架与类库的差别与设计原则 1. 框架的意义---设计的复用 1 1.1. 重型框架就是it界的重武器. 1 2. 框架 VS. 库 可视化图形化 1 2.1 ...

  8. Cocos2dx 多线程

    多-threaded负荷plist特征.获取知识的必要性: 1.多线程开启:pthread 2.怎样在线程中载入plist 一.多线程开启 当我们想在程序中开多线程中.第一想到的是cocos2d-x有 ...

  9. UML解惑:图说UML中的六大关系--转

    UML定义的关系主要有六种:依赖.类属.关联.实现.聚合和组合.这些类间关系的理解和使用是掌握和应用UML的关键,而也就是这几种关系,往往会让初学者迷惑.这里给出这六种主要UML关系的说明和类图描述, ...

  10. Mybatis插入语句useGeneratedKeys="true"的用法

    <!-- 插入新的问题件 --> <!-- useGeneratedKeys="true"把新增加的主键赋值到自己定义的keyProperty(id)中 --&g ...