apache 配置安装ssl证书实现https安全访问全过程
2018-02-08 09:19
766 查看
apache 配置安装ssl证书实现https安全访问全过程
2.打开extra目录下的httpd-ahssl.conf文件将下载的证书四个文件放置在conf下的ssl目录。httpd-ahssl.conf添加如下代码Listen 443 https
<VirtualHost _default_:443>
SSLEngine on
ServerName www.7428.cn:443
SSLCertificateFile "${SRVROOT}/conf/ssl/214329625123456.pem"
SSLCertificateKeyFile "${SRVROOT}/conf/ssl/214329625123456.key"
php_admin_value open_basedir "${SRVROOT}/htdocs/www7428cn;C:/windows/TEMP"
DocumentRoot "${SRVROOT}/htdocs/www7428cn"
ErrorDocument 404 "/404/"
# DocumentRoot access handled globally in httpd.conf
# CustomLog "${SRVROOT}/logs/ssl_request.log" \
# "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
<Directory "${SRVROOT}/htdocs/7428cnwww">
# Options Indexes Includes FollowSymLinks
Options Includes FollowSymLinks
AllowOverride AuthConfig Limit FileInfo
Require all granted
</Directory>
</virtualhost>
<VirtualHost _default_:443>
SSLEngine on
ServerName 7428.cn:443
SSLCertificateFile "${SRVROOT}/conf/ssl/214329625123456.pem"
SSLCertificateKeyFile "${SRVROOT}/conf/ssl/214329625123456.key"
<IfModule rewrite_module>
RewriteEngine On
RewriteCond %{http_host} ^7428.cn [NC]
RewriteRule ^(.*)$ https://www.7428.cn/$1 [L,R=301]
</IfModule>
php_admin_value open_basedir "${SRVROOT}/htdocs/www7428cn;C:/windows/TEMP"
DocumentRoot "${SRVROOT}/htdocs/www7428cn"
ErrorDocument 404 "/404/"
# DocumentRoot access handled globally in httpd.conf
# CustomLog "${SRVROOT}/logs/ssl_request.log" \
# "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
<Directory "${SRVROOT}/htdocs/www7428cn">
# Options Indexes Includes FollowSymLinks
Options Includes FollowSymLinks
AllowOverride AuthConfig Limit FileInfo
Require all granted
</Directory>
</virtualhost>
保存后重启apache其中的php_admin_value open_basedir两行代码作用是防止同一个服务器下其他域名站跨站访问。安全至上。ErrorDocument 是配置找不到页面的时候跳转的404页面信息。
<IfModule rewrite_module>里面的内容是实现https://7428.cn重定向到https://www.7428.cn,即不带www的跳转到
带www的下。
官方文件说明:1. 证书文件214329625123456.pem,包含两段内容,请不要删除任何一段内容。2. 如果是证书系统创建的CSR,还包含:证书私钥文件214329625123456.key、证书公钥文件public.pem、证书链文件chain.pem。( 1 ) 在Apache的安装目录下创建cert目录,并且将下载的全部文件拷贝到cert目录中。如果申请证书时是自己创建的CSR文件,请将对应的私钥文件放到cert目录下并且命名为214329625123456.key;( 2 ) 打开 apache 安装目录下 conf 目录中的 httpd.conf 文件,找到以下内容并去掉“#”:
安装证书(贴上未来智库站配置ssl的代码内容),官方的配置复杂且不具有通用性。
1.#修改httpd.conf文件
LoadModule ssl_module modules/mod_ssl.soInclude conf/extra/httpd-ssl.conf#去掉上面两行前的"#"2.打开extra目录下的httpd-ahssl.conf文件将下载的证书四个文件放置在conf下的ssl目录。httpd-ahssl.conf添加如下代码Listen 443 https
<VirtualHost _default_:443>
SSLEngine on
ServerName www.7428.cn:443
SSLCertificateFile "${SRVROOT}/conf/ssl/214329625123456.pem"
SSLCertificateKeyFile "${SRVROOT}/conf/ssl/214329625123456.key"
php_admin_value open_basedir "${SRVROOT}/htdocs/www7428cn;C:/windows/TEMP"
DocumentRoot "${SRVROOT}/htdocs/www7428cn"
ErrorDocument 404 "/404/"
# DocumentRoot access handled globally in httpd.conf
# CustomLog "${SRVROOT}/logs/ssl_request.log" \
# "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
<Directory "${SRVROOT}/htdocs/7428cnwww">
# Options Indexes Includes FollowSymLinks
Options Includes FollowSymLinks
AllowOverride AuthConfig Limit FileInfo
Require all granted
</Directory>
</virtualhost>
<VirtualHost _default_:443>
SSLEngine on
ServerName 7428.cn:443
SSLCertificateFile "${SRVROOT}/conf/ssl/214329625123456.pem"
SSLCertificateKeyFile "${SRVROOT}/conf/ssl/214329625123456.key"
<IfModule rewrite_module>
RewriteEngine On
RewriteCond %{http_host} ^7428.cn [NC]
RewriteRule ^(.*)$ https://www.7428.cn/$1 [L,R=301]
</IfModule>
php_admin_value open_basedir "${SRVROOT}/htdocs/www7428cn;C:/windows/TEMP"
DocumentRoot "${SRVROOT}/htdocs/www7428cn"
ErrorDocument 404 "/404/"
# DocumentRoot access handled globally in httpd.conf
# CustomLog "${SRVROOT}/logs/ssl_request.log" \
# "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
<Directory "${SRVROOT}/htdocs/www7428cn">
# Options Indexes Includes FollowSymLinks
Options Includes FollowSymLinks
AllowOverride AuthConfig Limit FileInfo
Require all granted
</Directory>
</virtualhost>
保存后重启apache其中的php_admin_value open_basedir两行代码作用是防止同一个服务器下其他域名站跨站访问。安全至上。ErrorDocument 是配置找不到页面的时候跳转的404页面信息。
<IfModule rewrite_module>里面的内容是实现https://7428.cn重定向到https://www.7428.cn,即不带www的跳转到
带www的下。
官方文件说明:1. 证书文件214329625123456.pem,包含两段内容,请不要删除任何一段内容。2. 如果是证书系统创建的CSR,还包含:证书私钥文件214329625123456.key、证书公钥文件public.pem、证书链文件chain.pem。( 1 ) 在Apache的安装目录下创建cert目录,并且将下载的全部文件拷贝到cert目录中。如果申请证书时是自己创建的CSR文件,请将对应的私钥文件放到cert目录下并且命名为214329625123456.key;( 2 ) 打开 apache 安装目录下 conf 目录中的 httpd.conf 文件,找到以下内容并去掉“#”:
#LoadModule ssl_module modules/mod_ssl.so (如果找不到请确认是否编译过 openssl 插件) #Include conf/extra/httpd-ssl.conf( 3 ) 打开 apache 安装目录下 conf/extra/httpd-ssl.conf 文件 (也可能是conf.d/ssl.conf,与操作系统及安装方式有关), 在配置文件中查找以下配置语句:
# 添加 SSL 协议支持协议,去掉不安全的协议 SSLProtocol all -SSLv2 -SSLv3 # 修改加密套件如下 SSLCipherSuite HIGH:!RC4:!MD5:!aNULL:!eNULL:!NULL:!DH:!EDH:!EXP:+MEDIUM SSLHonorCipherOrder on # 证书公钥配置 SSLCertificateFile cert/public.pem # 证书私钥配置 SSLCertificateKeyFile cert/214486743260863.key # 证书链配置,如果该属性开头有 '#'字符,请删除掉 SSLCertificateChainFile cert/chain.pem( 4 ) 重启 Apache。来源:未来智库 https://www.7428.cn
相关文章推荐
- WDCP上配置SSL证书即https 2017-08-28 百度总结 操作环境:linux的WDCP操作面板(没有操作面板就在命令行操作) wdcp 安装ssl证书教程实现https访问 1.申请
- 在linux安装配置svn并实现支持ssl认证https安全访问方式
- 用TLS实现安全TCP传输及配置和访问https的web服务
- Nginx配置SSL证书实现访问HTTPS网站
- 我是如何将网站全站启用Https的?-记录博客安装配置SSL证书全过程
- nginx配置ssl证书实现https和http共存访问
- 详解Nginx配置SSL证书实现Https访问
- wdcp+nginx+apache+mysql+php+免费申请ssl证书实现https访问
- apache服务器安装配置ssl数字证书,https访问
- nginx配置ssl证书实现https访问(附图解)
- 【狼人杀plus全记录】SpringBoot配置SSL证书实现Https访问
- linux环境apache配置https详解,apache配置ssl证书EV, OV, DV——linux安装web服务器19
- IIS 6.0下安装SSL证书实现https访问
- 网站升级HTTPS,免费SSL证书Let’s Encrypt安装使用教程:Apache和Nginx配置方法
- nginx配置免费的ssl证书,支持https安全访问
- 蛙蛙推荐:用TLS实现安全TCP传输及配置和访问https的web服务
- nginx配置ssl证书实现https访问的示例
- nginx配置免费的ssl证书,支持https安全访问
- LNMP环境配置SSL证书实现https访问