Solution to Nginx SSL certificate configuration error

Solution to Nginx SSL certificate configuration error

1. Introduction

When a web project is published on our Linux server, sometimes we need to configure an SSL certificate, which means that your website is more official, hahahaha. Once I downloaded the certificate and configured nginx.conf, everything was ready except for restarting. As a result, when I restarted, duang~something went wrong.

nginx: [emerg] unknown directive ssl, this is the error message

Because we need to reference the SSL module in nginx when configuring this SSL certificate, but when we first compiled Nginx, we did not compile the SSL module together, which led to this error.

2. Error resolution steps

Since SSL was not compiled during installation, should I uninstall nginx and reinstall it? No, no, no, we just need to add the ssl module on the original basis.

Step 1: Let's go to the decompressed directory where we downloaded the nginx package. If you installed it according to the tutorial I wrote, the decompressed directory should be "/usr/loacl/src/". Most of them should be in this directory, which is already a standard.

Step 2: After entering the decompressed directory, execute the following commands in order:

Command 1, ./configure --with-http_ssl_module //Re-add the ssl module

Note that if no error occurs, just look at command 2

This error occurs when executing the above command (./configure: error: SSL module requires OpenSSL library.) The reason is that OpenSSL is missing. Then we can install another one and execute: yum -y install openssl openssl-devel

After OpenSSL is installed, execute ./configure and then execute "Command 1".

Command 2: Execute the make command, but do not execute make install, because make is used for compilation, and make install is for installation, otherwise your entire nginx will be overwritten.

Command 3. After we execute the command, we can see that there is an additional nginx file in the objs folder in the nginx decompression directory. This is the new version of the program. First, we back up the previous nginx, and then copy the new program to overwrite the previous one.

cp /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.bak

cp objs/nginx /usr/local/nginx/sbin/nginx

Command 4. Finally, we go to the Nginx installation directory to check whether the SSL module has been installed successfully. Execute ./sbin/nginx -V to see the following figure:

3. Finally, if the above picture appears, the SSL module has been added to Nginx and compiled, and the restart is OK this time.

If you restart nginx, the following error is reported:

nginx error: [warn] the "ssl" directive is deprecated, use the "listen ... ssl" directive instead

Change ssl on to listen 443 ssl.

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Introduction to SSL certificate installation and deployment steps under Nginx
  • Example of how to configure nginx to implement SSL
  • Nginx domain name SSL certificate configuration (website http upgraded to https)
  • Nginx configuration SSL and WSS steps introduction

<<:  Detailed explanation of how to query fields containing '%' in MySQL like (ESCAPE usage)

>>:  HTML table tag tutorial (3): width and height attributes WIDTH, HEIGHT

Recommend

Use of Linux sed command

1. Function Introduction sed (Stream EDitor) is a...

Implementation of multi-port mapping of nginx reverse proxy

Code Explanation 1.1 http:www.baidu.test.com defa...

Pure CSS code to achieve drag effect

Table of contents 1. Drag effect example 2. CSS I...

Incomplete solution for using input type=text value=str

I encountered a very strange problem today. Look a...

About the configuration problem of MyBatis connecting to MySql8.0 version

When learning mybatis, I encountered an error, th...

A brief discussion on this.$store.state.xx.xx in Vue

Table of contents Vue this.$store.state.xx.xx Get...

Tutorial on installing PHP on centos via yum

First, let me introduce how to install PHP on Cen...

Implementing custom scroll bar with native js

This article example shares the specific code of ...

Summary of commonly used tool functions in Vue projects

Table of contents Preface 1. Custom focus command...

Detailed explanation of character sets and validation rules in MySQL

1Several common character sets In MySQL, the most...

Disabled values ​​that cannot be entered cannot be passed to the action layer

If I want to make the form non-input-capable, I se...

Solution to Vue data assignment problem

Let me summarize a problem that I have encountere...

Summary of the benefits of deploying MySQL delayed slaves

Preface The master-slave replication relationship...