SSL全称为secure socket layer 用以保障在inetnet上数据传输安全,利用数据加密保障数据在网络上传输过程不会被窃取窃听

//yum 安装使apache支持ssl

yum install mod_ssl openssl

//创建私钥

openssl genrsa -out server.key 1024

//证书签发亲求csr,系统会向你索取一些简单的信息,这里为了实验方便一路回车

#
  1. # openssl req -new -key server.key -out server.csr 
  2. You are about to be asked to enter information that will be incorporated 
  3. into your certificate request. 
  4. What you are about to enter is what is called a Distinguished Name or a DN. 
  5. There are quite a few fields but you can leave some blank 
  6. For some fields there will be a default value, 
  7. If you enter '.', the field will be left blank. 
  8. ----- 
  9. Country Name (2 letter code) [GB]: 
  10. State or Province Name (full name) [Berkshire]: 
  11. Locality Name (eg, city) [Newbury]: 
  12. Organization Name (eg, company) [My Company Ltd]: 
  13. Organizational Unit Name (eg, section) []: 
  14. Common Name (eg, your name or your server's hostname) []: 
  15. Email Address []: 
  16.  
  17. Please enter the following 'extra' attributes 
  18. to be sent with your certificate request 
  19. A challenge password []: 
  20. An optional company name []: 


由于我们不能申请上级CA授权认证,自己给自己创建一个CA

 

  1. [root@centos129 ~]# openssl x509 -days 365 -req -in server.csr -signkey server.key -out server.crt 
  2. Signature ok 
  3. subject=/C=GB/ST=Berkshire/L=Newbury/O=My Company Ltd 
  4. Getting Private key 

以上3个操作产生3个文件

 

  1. server.key 
  2. server.csr 
  3. server.key 

//修改www.zhoutao.name虚拟主机配置文件

内容如下

 

  1. [root@centos129 vconf.d]# cat nvhsot.conf  
  2. <VirtualHost 172.16.148.129:443> 
  3. ServerName www.zhoutao.name 
  4. ScriptAlias /cgi-bin/ "/www/zhoutao.name/cgi-bin/" 
  5. DocumentRoot /www/zhoutao.name 
  6. SSLEngine on 
  7. SSLOptions +StrictRequire 
  8. SSLCertificateFile /etc/httpd/conf/server.crt 
  9. SSLCertificateKeyFile /etc/httpd/conf/server.key 
  10. <Directory /www/zhoutao.name> 
  11. AllowOverride AuthConfig 
  12. </Directory> 
  13. </VirtualHost> 

//实验结束

访问https://www.zhoutao.name

 

apache 配置虚拟主机的安全连接 SSL_职场