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

What to do if the online MySQL auto-increment ID is exhausted

Table of contents Table definition auto-increment...

Detailed explanation of commands to view linux files

How to view linux files Command to view file cont...

CentOS7 uses rpm to install MySQL 5.7 tutorial diagram

1. Download 4 rpm packages mysql-community-client...

An enhanced screenshot and sharing tool for Linux: ScreenCloud

ScreenCloud is a great little app you didn’t even...

Summary of methods for inserting videos into HTML pages

Now if you want to use the video tag in a page, y...

How to use negative margin technology to achieve average layout in CSS

We usually use float layout to solve the compatib...

How to use environment variables in nginx configuration file

Preface Nginx is an HTTP server designed for perf...

Detailed explanation of MySQL syntax, special symbols and regular expressions

Mysql commonly used display commands 1. Display t...

Basic usage of UNION and UNION ALL in MySQL

In the database, both UNION and UNION ALL keyword...

Docker image export, import and copy example analysis

The first solution is to push the image to a publ...

onfocus="this.blur()" is hated by blind webmasters

When talking about the screen reading software op...

Modify the jvm encoding problem when Tomcat is running

question: Recently, garbled data appeared when de...

Nest.js hashing and encryption example detailed explanation

0x0 Introduction First of all, what is a hash alg...