安装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 ~]#