Nginx config test failed because of failed SSL certificate
1. Problem
When I transferred my website from A server provider’s machine to B server provider’s machine. All data transferred seemed smooth. But the only problem was that nginx would not start due to failed ssl problem.
Feb 05 01:19:46 xxxxxxx nginx[933971]: nginx: [emerg] BIO_new_file(“/etc/dhparam”) failed (SSL: error:80000002:system library::No such file or directory:calling fopen(/etc/dhparam>
Feb 05 01:19:46 xxxxxxx nginx[933971]: nginx: configuration file /etc/nginx/nginx.conf test failed
Feb 05 01:19:46 xxxxxxx systemd[1]: nginx.service: Control process exited, code=exited, status=1/FAILURE
2. Solution and steps
1) Look into the specific nginx config for that website, locate the row where ssl_dhparam lies, and make sure it has the actual directory to hold a certificate, should like this:
ssl_dhparam /etc/dhparam/dhparams.pem;
2) Create a certificate using openssl, which may take one minute or two:
openssl dhparam -out /etc/dhparam/dhparams.pem 4096
Now it is safe to restart the nginx.