创建cert文件夹

mkdir /etc/apache2/cert

启用ssl

a2enmod ssl

并且将阿里云下载的全部文件拷贝到cert目录中
修改default-ssl

vi /etc/apache2/sites-available/default-ssl

修改这些内容

ServerName xxx.com
ServerAlias www.xxx.com
SSLEngine on
SSLCertificateFile /etc/apache2/cert/public.pem
SSLCertificateKeyFile /etc/apache2/cert/21xxxxxxx.key
SSLCertificateChainFile /etc/apache2/cert/chain.pem

运行和重启

a2ensite default-ssl
/etc/init.d/apache2 restart

强制http到https
打开 /etc/apache2/sites-available/000-default.conf,
在标签内随便一个地方加入以下三行

RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*) https://%{SERVER_NAME}$1 [L,R]

启动 rewrite mod

sudo a2enmod rewrite

重启 apache

sudo etc/init.d/apache2 restart