Apache配置https

申请免费DV证书

阿里云官方文档

申请SSL证书

  1. 访问证书资源包购买页,领取阿里云免费DV证书。

  2. 申请免费版SSL证书。

下载证书并上传服务器


重命名文件chain.crt –> ca.crt, public.crt –> server.key
通过XShell上传至服务器,并放在/usr/local/apache2/conf/key

1
2
3
4
[root@ECS key]# pwd
/usr/local/apache2/conf/key
[root@ECS key]# ls
ca.crt server.crt server.key

在Apache服务器上安装SSL证书

阿里云官方文档

配置httpd.conf

# vim /usr/local/apache2/conf/httpd.conf

1
2
3
LoadModule ssl_module modules/mod_ssl.so
Include conf/extra/httpd-ssl.conf
#Include conf/extra/httpd-ahssl.conf

配置httpd-ssl.conf

# vim /usr/local/apache2/conf/extra/httpd-ssl.conf

1
2
3
4
5
6
7
8
9
10
11
12
<VirtualHost _default_:443>
DocumentRoot "/usr/local/apache2/htdocs"
ServerName www.oeong.com:443 # 域名
ServerAdmin oeong@foxmail.com # 邮箱
ErrorLog "/usr/local/apache2/logs/error_log"
TransferLog "/usr/local/apache2/logs/access_log"

SSLCertificateFile "/usr/local/apache2/conf/key/server.crt"
SSLCertificateKeyFile "/usr/local/apache2/conf/key/server.key"
SSLCertificateChainFile "/usr/local/apache2/conf/key/ca.crt"

SSLEngine on

重启Apache

[root@ECS conf]# /usr/local/apache2/bin/apachectl restart


本博客所有文章除特别声明外,均采用 CC BY-SA 4.0 协议 ,转载请注明出处!