Home  >  Article  >  Operation and Maintenance  >  How to recompile Nginx and add modules

How to recompile Nginx and add modules

WBOY
WBOYforward
2023-05-23 15:28:502746browse

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 unzip it

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

2. Check the nginx version and compilation parameters

/usr/local/nginx/sbin/nginx -v

3. Enter the nginx source code 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), make After that, there will be an additional 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 the new Is the nginx program 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. Start the service smoothly

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

Check whether the module has been 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 reloads the module. !

The above is the detailed content of How to recompile Nginx and add modules. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete