一、安装准备

1.安装Openssl 要使Apache支持SSL,需要首先安装Openssl支持。推荐下载安装openssl-0.9.8k.tar.gz 下载Openssl:http://www.openssl.org/source/ tar -zxf openssl-0.9.8k.tar.gz //解压安装包 cd openssl-0.9.8k //进入已经解压的安装包 ./config //配置安装。推荐使用默认配置 make && make install //编译及安装 openssl默认将被安装到/usr/local/ssl

2. 安装Apache ./configure --prefix=/usr/local/apache --enable-so --enable-ssl --with-ssl=/usr/local/ssl --enable-mods-shared=all //配置安装。推荐动态编译模块 make && make install

动态编译Apache模块,便于模块的加载管理。Apache 将被安装到/usr/local/apache

3.申请证书

我这以wosign证书为例,成功在沃通申请证书后,会得到一个有密码的压缩包文件,输入证书密码后解压得到五个文件:forApache、forIIS、forNgnix、forTomcat、forOther Server,这个是证书的几种格式,Apache上需要用到forApache格式的证书。

4.安装ssl证书

a、打开apache安装目录下conf目录中的httpd.conf文件,找到 #LoadModule ssl_module modules/mod_ssl.so #Include conf/extra/httpd_ssl.conf 删除行首的配置语句注释符号“#” 保存退出。

b、打开apache安装目录下conf/extra目录中的httpd-ssl.conf文件 在配置文件中查找以下配置语句

将服务器证书公钥配置到该路径下 SSLCertificateFile conf/ssl.crt/domian.com.crt (证书公钥)

将服务器证书私钥配置到该路径下 SSLCertificateKeyFile conf/ssl.key/domain.com.key (证书私钥)

将服务器证书链配置到该路径下 #SSLCertificateChainFile conf/ssl.crt/root_bundle.crt(证书链)删除行首的“#”号注释符

保存退出,并重启Apache。重启方式: c、进入Apache安装目录下的bin目录,运行如下命令 ./apachectl -k stop ./apachectl -k start

5.测试安装结果

访问https://+证书绑定的域名,测试效果如下

linux下的apache部署ssl证书_linux                                                    

注:部署完毕后若网站无法通过https正常访问,可确认服务器443端口是否开启或被网站卫士等加速工具拦截。 (1)开启方法:防火墙设置-例外端口-添加443端口(TCP)。 (2)若被安全或加速工具拦截,可以在拦截记录中将443添加至信任列表。 重启后,重新通过https访问。