Nginx recompiles the method to add a module

  • 2020-05-17 07:42:03
  • OfStack

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

Here's how to add a new module after you've already installed it.

1. Find the source root directory where nginx is installed (that is, the installation package directory), download the new source code and unzip it if you don't have it


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

2. View 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: never make install, otherwise you will be overinstalled). After make is finished, there will be another nginx in the directory /software/ nginx-1.10.2 /objs.

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 the new nginx program for correctness


/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. Start the service smoothly


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

Check to see 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 complete!


Related articles: