一、apache:

  1. 安装apache、ssl、opensslyum -y install httpd httpd-pear mod_ssl openssl
  2. 生成证书文件openssl genrsa -out server.key 2048openssl req -new -key server.key -out server.crt
    此步骤需要输入一些证书信息:(如果不想输入,也可一路回车)
    Country Name (2 letter code) [XX]:CNState or Province Name (full name) []:shanghai Locality Name (eg, city) [Default City]:shanghai Organization Name (eg, company) [Default Company Ltd]:ccc Organizational Unit Name (eg, section) []:bbb Common Name (eg, your name or your server's hostname) []:www.test.com Email Address []:a@a.com
  3. 移到证书文件到apache配置目录下mv {server.key,server.crt} /etc/httpd/conf/
  4. 修改nginx配置文件:vim /etc/httpd/conf/httpd.conf
    apache、nginx配置自签名证书_apache配置
    修改为刚才生成证书文件的路径
  5. 测试:
    apache、nginx配置自签名证书_vim_02
    二、nginx:
  6. 生成私钥文件:openssl genrsa -des3 -out server.key 2048
  7. 去除口令:mv server.key server.key.backopenssl rsa -in server.key.back -out server.key
  8. 创建请求证书:openssl req -new -key server.key -out server.csr
  9. 生成证书文件:openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
  10. 修改nginx配置文件:ssl on;ssl_certificate /etc/nginx/server.crt; ssl_certificate_key /etc/nginx/server.key;
    apache、nginx配置自签名证书_apache_03
  11. 测试:
    apache、nginx配置自签名证书_nginx配置_04