设置APACHE支持SSL

本文介绍如何为Apache服务器配置SSL证书,包括安装openssl、生成自签名证书、放置证书文件到指定目录、修改Apache SSL配置文件及重启Apache服务等步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

总体分两步:一、生成SSL证书;二、设置Apache的SSL配置


1.   安装openssl

yum install mod_ssl openssl

2.    生成自签名的证书

[plain]  view plain  copy
  1. #Generate private key   
  2. openssl genrsa -out ca.key 2048   
  3. #Generate CSR Certificate Signing Request   
  4. openssl req -new -key ca.key -out ca.csr  
  5. #Generate Self Signed Certificate  
  6. openssl x509 -req -days 365 -in ca.csr -signkey ca.key -out ca.crt  

3.    证书放到规范的目录中

[plain]  view plain  copy
  1. #Copy the files to the correct locations  
  2. cp ca.crt /etc/pki/tls/certs  
  3. cp ca.key /etc/pki/tls/private/ca.key  
  4. cp ca.csr /etc/pki/tls/private/ca.csr  

4.    修改Apache的SSL配置

Edit the Apache SSL configuration file /etc/httpd/conf.d/ssl.conf.

Change the paths to match where the Keyfile is stored.

[plain]  view plain  copy
  1. SSLCertificateFile /etc/pki/tls/certs/ca.crt  

Then set the correct path for theCertificate Key File a few lines below.

[plain]  view plain  copy
  1. SSLCertificateKeyFile /etc/pki/tls/private/ca.key  

Quit and save the file.

5.    重启Apache

[plain]  view plain  copy
  1. service httpd restart  

All being well you should now be ableto connect over https to your server. As the certificate is self signedbrowsers will generally ask you whether you want to accept the certificate.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值