SoFunction
Updated on 2025-04-08

How to handle exceptions of Nginx installation SSl templates

Preface

If web services need to support https, Nginx needs to support SSL. You may encounter some difficulties in the middle. This article introduces some exceptions in my configuring environment in the Linux environment.

1. Configure Nginx to support ssl

   server {
        listen       443 ssl;
        server_name  localhost;
 
        ssl_certificate      ;
        ssl_certificate_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   ;
        }
   }

2. Restart Nginx

Enter the sbin directory

Reload:/nginx-s reload

3. An error is found

nginx: [emerg] unknown directive “ssl” in /usr/local/nginx/conf/

1. Analysis is missing ssl module

2. Start installing the ssl module

3. Install in the nginx file directory

./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module

4. An error is found

./configure: error: SSL modules require the OpenSSL library

1. Analysis is missing OpenSSL package

The version command found that the machine has openedSSl installed

2. Because I have an internet-free environment

  • Download the openssl file.
  • The download address is:/source/openssl-1.0.

3. Unzip tar -xvzf openssl-1.0.

./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-openssl=/usr/local/openssl

4. I filled in the above with-openssl path to the unzipped file, and then the installation was successful. I installed OpenSSL directly. The installation failed in my Linux environment.

one time

Summarize

The above is personal experience. I hope you can give you a reference and I hope you can support me more.