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

How to recompile Nginx and add modules

WBOY
Release: 2023-05-23 15:28:50
forward
2807 people have browsed it

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
Copy after login

2. Check the nginx version and compilation parameters

/usr/local/nginx/sbin/nginx -v
Copy after login

3. Enter the nginx source code directory

cd nginx-1.10.2
Copy after login

4. Recompiled code and modules

./configure --prefix=/usr/local/nginx --with-http_ssl_module
Copy after login

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
Copy after login

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

cp /software/nginx-1.10.2/objs/nginx /usr/local/nginx/sbin/
Copy after login

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
Copy after login

9. Start the service smoothly

/usr/local/nginx/sbin/nginx -s reload
Copy after login

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
Copy after login

Restart nginx

./nginx -s quit
./nginx
Copy after login

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!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template