发新话题
打印

Linux下Apache配置HTTPS

Linux下Apache配置HTTPS

首先在阿里或者其他平台申请SSL证书(免费版)。yum -y install mod_ssl

安装后
/etc/httpd/conf.d目录下会出现一个ssl.conf文件
里面的三个文件分别填写你的ssl证书所在路径SSLCertifiCateFile  对应的public.crt路径
SSLCertifiCateChainFile   对应的chain.crt
SSLCertifiCateKeyFile    对应的xxx.key

配置443端口在ssl.conf里面找到VirtulHost
默认端口为443
ServerName www.unclez.top
ServerAlias *.unclez.top

完整案例:
Listen 443
NameVirtualHost *:443
<VirtualHost *:443>
  DocumentRoot "/var/www/html/xxx"
  ServerName www.xxx.com
  ErrorLog logs/ssl_error_log
  TransferLog logs/ssl_access_log
  LogLevel warn
  SSLEngine on
  SSLCertificateFile /etc/httpd/cert/public.crt
  SSLCertificateKeyFile /etc/httpd/cert/xxx.com.key
  ##SSLCertificateChainFile /etc/httpd/cert/chain.crt
</VirtualHost>



保存退出检查配置是否正确service httpd configtest
返回ok就没问题

重启service httpd restart

TOP

如果你用的是阿里云,除了在防火墙里把443端口开放外,还需要在你购置的云服务器 ECS实例》安全组》配置规则里,手动新增443端口。

TOP

发新话题