Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to compile and install Nginx

Shulou Source: shulou.com Published: 2022-05-31 12:51:54 09月24日 Update

In this article, the editor introduces in detail "how to compile and install Nginx". The content is detailed, the steps are clear, and the details are handled properly. I hope this article "how to compile and install Nginx" can help you solve your doubts.

Download the nginx source file

Go to the nginx website to download the stable version of nginx. I downloaded 1.10.0.

Decompress: tar-zxvf nginx-1.10.0.tar.gz

Check installation dependencies

Execute the following command to install the dependent libraries for nginx:

Yum-y install gcc pcre pcre-devel zlib zlib-devel openssl openssl-devel

Configure nginx installation options

Here I only configure to install to the / opt directory, other options can be performed. / configuration-help view.

Cd nginx installation directory, execute the following command:

. / configure-prefix=/opt/nginx-sbin-path=/usr/bin/nginx

Description of parameters configuration on official website:

IV. Compile and install

Make & & make install

Start, stop and restart

# 1. Start nginxshell > nginx# via ps-ef | grep nginx to check whether nginx has been started successfully # 2. Stop nginxshell > nginx-s stop# 3. Restart shell > nginx-s reload

After the nginx default configuration starts successfully, there will be two processes, a main process (daemon) and a worker process. The main process is responsible for managing the worker process, and the worker process is responsible for handling the user's http requests.

6. Configure nginx to boot

The / usr/bin/nginx command is added to the / etc/rc.d/rc.local file, and the rc.local file is executed when the system boots. However, centos7 recommends that the boot service be written as a service description file to add to the system service, so rc.local does not have execution permission by default, so you need to add execution permission to it.

Shell > vim / etc/rc.d/rc.local# add the following parameters / usr/bin/nginxshell > chmod + x / etc/rc.d/rc.local read here, this "how to compile and install Nginx" article has been introduced, want to master the knowledge of this article also need to practice and use to understand, if you want to know more related articles, welcome to follow the industry information channel.

Tags: Process configuration compilation commands files articles work services success content parameters permissions directory system processing proper two suggestions ideas new knowledge Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Linux macOS MySQL Docker