GCC, make, wget,g++ openssl is used to encrypt SSL modules and supports HTPS

Wget HTTP: / / https://www.openssl.org/source/openssl-1.0.2s.tar.gzCopy the code

Download pcRE to implement support for address redirection, address rewriting and localtion instructions and regular expressions

Wget HTTP: / / https://ftp.pcre.org/pub/pcre/pcre-8.43.tar.gzCopy the code

Download the Zlib gzip compression module

Wget HTTP: / / https://zlib.net/zlib-1.2.11.tar.gzCopy the code

Download Nginx

Wget HTTP: / / http://nginx.org/download/nginx-1.16.1.tar.gzCopy the code

Use tar to extract all files

ls *.tar.gz | xargs -n1 tar xzvf  
Copy the code
Compiler options

Scripts that use./configure to set various Nginx parameters, including source and configuration file paths, compiler options, connection handling methods, and a list of modules. This script is done by creating the makefiles required to compile the code and install Nginx open source.

parameter describe
–prefix= Nginx installation directory, and the base location of all relative paths set by paths with other configuration script options. The default value/usr/local/nginx
–sbin-path=<PATH The name of the Nginx binary execution file. Default:<prefix>/sbin/nginx
–conf-path= Name of the Nginx configuration file. However, you can always override this value at startup by specifying other files with options on the nginx command line. Default value:<prefix> conf / nginx.conf-c <FILENAME>
–pid-path= Pid is the name of the file used to store the process ID of the main nginx process. After installation, you can change the path to the file name using the PID directive in the Nginx configuration file. Default value:<prefix> /logs/nginx.pid
–error-log-path= The names of the log files for error, WARN, and diagnostic data. After installation, you can change the file name using the error_log directive in the Nginx configuration file. Default value:<prefix> /logs/error.log
–http-log-path= The name of the primary log file requested by the HTTP server. After installation, you can always change the file name using the access_log directive in the Nginx configuration file. Default value:<prefix> /logs/access.log
–user= Owner of the Nginx running process. After installation, you can change the name using the User directive in the Nginx configuration file. The default:nobody
–group=name Nginx runs the user group that owns the process. After installation, you can change the name using the User directive in the NGINX configuration file. Default: — the value set by the user option
–with-pcre= The path to the PCRE library source code, which is required by the location directive and the Rewrite module’s regular expression support
–with-pcre-jit Build the PCRE library with just-in-time compile support (the PCRE_JIT directive)
–with-zlib= Zlib library source code path, which is required by the Gzip module
–with-http_ssl_modul Enabling HTTPS
–with-http_v2_module Enable HTTP/2 request support

Compile the installation

./configure \ --with-openssl=.. / openssl - 1.0.2 \ - with - pcre = s. / pcre - 8.43 \ - with - zlib =. /zlib-1.2.11 \ -- with-pcl-jit --user=admin \ --prefix=/home/admin/nginx \ --with-http_ssl_module \ --with-http_v2_moduleCopy the code
make
make install
Copy the code

Now that the nginx installation is complete, create a folder cert in nginx to deploy SSL

mkdir /home/admin/nginx/cert
Copy the code

Add the. Pem and. Key files in SSL to cert to modify the configuration file

vim /home/admin/nginx/conf/nginx.conf
Copy the code

Comment out all HTTP content and add the following at the bottom

http{ server { listen 443 ssl; Server_name domain; Ssl_certificate /home/admin/nginx/cert. pem; Ssl_certificate_key /home/admin/nginx/cert/ File name. 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; } } server{ listen 80; Server_name domain; Return 301 https:// domain name; }}Copy the code

Reference: juejin. Cn/post / 684490…