How to recompile Nginx and add modules

How to recompile Nginx and add modules

When compiling and installing Nginx, some modules are not installed by default, such as http_ssl_module. In order for Nginx to support HTTPS, this module must be added.

The following explains how to add a new module after it has already been installed.

1. Find the source code root directory where nginx is installed (that is, the directory where the installation package is stored). If not, download the new source code and decompress it.

cd software
ls
nginx-1.10.2 nginx-1.10.2.tar.gz

2. Check the nginx version and its compilation parameters

/usr/local/nginx/sbin/nginx -V

3. Enter the nginx source directory

cd nginx-1.10.2

4. Recompiled code and modules

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

5. Execute make (note: do not make install, otherwise the installation will be overwritten). After make, there will be an nginx in the /software/nginx-1.10.2/objs directory. This is the new version of the program.

6. Back up the old nginx program

cd /usr/local/nginx/sbin/
mv nginx nginx_bak

7. Copy the new nginx program to /usr/local/nginx/sbin/

cp /software/nginx-1.10.2/objs/nginx /usr/local/nginx/sbin/

8. Test whether the new nginx program is correct

/usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

9. Smooth service startup

/usr/local/nginx/sbin/nginx -s reload

Check if the module is installed

/usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.10.2
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-4) (GCC)
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --with-http_ssl_module

Restart Nginx

./nginx -s quit
./nginx

nginx reload module completed!

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:
  • Nginx dynamically forwards to upstream according to the path in the URL
  • Example of nginx ip blacklist dynamic ban
  • Nginx uses Lua+Redis to dynamically block IP
  • Detailed explanation of several ways to write Nginx dynamic DNS reverse proxy
  • How to dynamically add modules to Nginx

<<:  MySQL 8.0.11 Installation Tutorial under Windows

>>:  JavaScript example code to determine whether a file exists

Recommend

How to view image information in Docker

In this article, we will need to learn how to vie...

The textarea tag cannot be resized and cannot be dragged with the mouse

The textarea tag size is immutable Copy code The c...

How to connect to MySQL remotely through Navicat

Using Navicat directly to connect via IP will rep...

MySQL 5.6.28 installation and configuration tutorial under Linux (Ubuntu)

mysql5.6.28 installation and configuration method...

How to set the height of the autosize textarea in Element UI

After setting textarea input in Element UI to aut...

Detailed process of Vue front-end packaging

Table of contents 1. Add packaging command 2. Run...

Rounding operation of datetime field in MySQL

Table of contents Preface 1. Background 2. Simula...

Three ways to communicate between React components (simple and easy to use)

Table of contents 1. Parent-child component commu...

Sample code for implementing 3D rotation effect using pure CSS

Mainly use the preserve-3d and perspective proper...

Application of CSS3 animation effects in activity pages

background Before we know it, a busy year is comi...

How to detect if the current browser is a headless browser with JavaScript

Table of contents What is a headless browser? Why...

Detailed example of MySQL exchange partition

Detailed example of MySQL exchange partition Pref...

Steps to change mysql character set to UTF8 under Linux system

Table of contents 1. Check the MySQL status in th...