Nginx_https

安装nginx后,在原有的基础上安装证书和私钥
[root@kvm122103 ~]# yum -y install httpd mod_ssl
[root@kvm122103 ~]# ls /etc/pki/tls/certs/localhost.crt
/etc/pki/tls/certs/localhost.crt
[root@kvm122103 ~]#
[root@kvm122103 ~]# ls /etc/pki/tls/private/localhost.key
/etc/pki/tls/private/localhost.key
[root@kvm122103 ~]#

[root@kvm122103 ~]# vim /usr/local/nginx/conf/nginx.conf
server {
listen 443 ssl;
server_name localhost;

  ssl_certificate      localhost.crt;
  ssl_certificate_key  localhost.key;

  ssl_session_cache    shared:SSL:1m;
  ssl_session_timeout  5m;

  ssl_ciphers  HIGH:!aNULL:!MD5;
  ssl_prefer_server_ciphers  on;

  location / {
      root   html;
      index  index.html index.htm;
  }

}

[root@kvm122103 ~]# systemctl restart nginx
Job for nginx.service failed because the control process exited with error code. See “systemctl status nginx.service” and “journalctl -xe” for details.
[root@kvm122103 ~]#
[root@kvm122103 ~]# systemctl status nginx.service
● nginx.service - The nginx HTTP and reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Tue 2018-06-26 05:13:23 EDT; 12s ago
Process: 1837 ExecStop=/bin/kill -s QUIT $MAINPID (code=exited, status=0/SUCCESS)
Process: 1842 ExecStartPre=/usr/local/nginx/sbin/nginx -t (code=exited, status=1/FAILURE)
Main PID: 1720 (code=exited, status=0/SUCCESS)

Jun 26 05:13:23 kvm122103 systemd[1]: Starting The nginx HTTP and reverse proxy server…
Jun 26 05:13:23 kvm122103 nginx[1842]: nginx: [emerg] BIO_new_file("/usr/local/nginx/conf/localhost.crt") failed (SSL: error:02001002:syst…uch file)
Jun 26 05:13:23 kvm122103 nginx[1842]: nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed
Jun 26 05:13:23 kvm122103 systemd[1]: nginx.service: control process exited, code=exited status=1
Jun 26 05:13:23 kvm122103 systemd[1]: Failed to start The nginx HTTP and reverse proxy server.
Jun 26 05:13:23 kvm122103 systemd[1]: Unit nginx.service entered failed state.
Jun 26 05:13:23 kvm122103 systemd[1]: nginx.service failed.
Hint: Some lines were ellipsized, use -l to show in full.
[root@kvm122103 ~]#
[root@kvm122103 ~]# cp /etc/pki/tls/certs/localhost.crt /usr/local/nginx/conf/
[root@kvm122103 ~]# cp /etc/pki/tls/private/localhost.key /usr/local/nginx/conf/
[root@kvm122103 ~]#
[root@kvm122103 ~]# systemctl restart nginx
[root@kvm122103 ~]#

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值