1.编辑 /opt/lampp/etc/php.ini 文件,找到 “;extension=php_openssl.dll” (去掉前面的;号注释)
2.需要配置 httpd-ssl.conf 文件(opt/lampp/etc/extra/httpd-ssl.conf)
配置 DocumentRoot 和 ServerName ,改成自己定义的;
配置三个证书文件
SSLCertificateFile "/opt/lampp/etc/ssl.crt"
SSLCertificateKeyFile "/opt/lampp/etc/ssl.key"
SSLCertificateChainFile "/opt/lampp/etc/ssl_chain.crt"#记得去掉它前面的#号
or
#SSLCertificateFile "/etc/letsencrypt/live/xxx.com/fullchain.pem"
#SSLCertificateKeyFile "/etc/letsencrypt/live/xxx.com/privkey.pem"
完整配置参考:
<VirtualHost *:443>
ServerAdmin nbllq@qq.com
DocumentRoot "/opt/lampp/htdocs/test/web/"
ServerName xxx.amyflash.com
SSLEngine on
SSLCertificateFile "/opt/lampp/etc/ssl.crt"
SSLCertificateKeyFile "/opt/lampp/etc/ssl.key"
SSLCertificateChainFile "/opt/lampp/etc/ssl_chain.crt"
<Directory "/opt/lampp/htdocs/test/web/">
Options FollowSymLinks
AllowOverride All
Require all granted
ErrorLog "logs/www.test.com-error_log"
CustomLog "|/opt/lampp/bin/rotatelogs /opt/lampp/logs/www.test.com-access_log_%Y-%m-%d 86400 480" common
</VirtualHost>
3.访问80端口需要在httpd-vhosts.conf里面配置
<VirtualHost *:80>
ServerAdmin nbllq@qq.com
DocumentRoot "/opt/lampp/htdocs/test/web/"
ServerName xxx.amyflash.com
#RewriteEngine On
#RewriteRule ^/(.*)$ https://xxx.amyflash.com/$1 [R=301,L]
</VirtualHost>
4.将http跳转到https上,网站根目录下加入.htaccess文件
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R,L]
ps:多站点多证书对应配置即可
阿里云官方文档:https://help.aliyun.com/knowledge_detail/95493.html?spm=a2c4g.11186623.2.11.35da34f1JnB78t