How to compile and install Nginx

王林
Release: 2023-05-19 23:58:05
forward
5233 people have browsed it

1. Download the nginx source file

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

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

## 2. Check the installation dependencies

Execute the following command to install nginx dependent libraries:

yum -y install gcc pcre pcre-devel zlib zlib-devel openssl openssl-devel
Copy after login

3. Configure nginx installation options

I only configure the installation to the /opt directory here , other options can be viewed by executing ./configuration –help.


cd nginx installation directory, execute the following command:

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

Official website parameter configuration instructions:

4. Compile and install

make && make install
Copy after login

5. Start, stop, restart

# 1.启动nginx
shell> nginx
# 可通过ps -ef | grep nginx查看nginx是否已启动成功
# 2.停止nginx
shell> nginx -s stop
# 3. 重新启动
shell> nginx -s reload
Copy after login

How to compile and install Nginx

After nginx default configuration is started successfully, it will There are two processes, a main process (daemon process) and a worker process. The main process is responsible for managing the worker process, and the worker process is responsible for processing the user's http request.

6. Configure nginx to start at boot

Add the /usr/bin/nginx command to the /etc/rc.d/rc.local file. The rc.local file will be executed when the system starts. However, centos7 recommends writing the startup service as a service description file and adding it to the system service, so rc.local does not have execution permissions by default, and you need to add execution permissions to it.

shell> vim /etc/rc.d/rc.local
# 添加如下参数
/usr/bin/nginx

shell> chmod +x /etc/rc.d/rc.local
Copy after login

The above is the detailed content of How to compile and install Nginx. 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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!