Get the App
SLTechnology News&Howtos  ›  Servers  › 

Compile and install nginx-1.12.2 in CentOS7.5

Shulou Source: shulou.com Published: 2022-06-02 16:05:26 11月05日 Update

1 description

This document takes the Jilin examination project as an example to install and deploy nginx by compiling.

2 catalogue planning

Nginx version

Nginx source code package storage record

Nginx installation directory

Nginx stores the code directory

Nginx log directory

Nginx-1.12.2

Nginx-1.12.2

/ usr/local/nginx

/ home/yunwei/nginx-data

/ home/yunwei/nginx-logs

3 download nginx source code package

Create a directory for storing nginx source packages

Mkdir / usr/local/src/nginx

Download the nginx source package to the specified directory

Wget http://nginx.org/download/nginx-1.12.2.tar.gz-P / usr/local/src/nginx/

Decompress nginx source code packet

Tar xf / usr/local/src/nginx/nginx-1.12.2.tar.gz-C / usr/local/src/nginx/

4 compile and install nginx

Install dependency packages

Yum-y install pcre-devel openssl-devel

Create a nginx user

Useradd-s / sbin/nologin-M nginx

Create a nginx installation directory

Mkdir / usr/local/nginx

Cd / usr/local/src/nginx/nginx-1.12.2/

. / configure-prefix=/usr/local/nginx/-user=nginx-group=nginx-with-http_ssl_module-with-http_stub_status_module

Make & & make install

Ln-s / usr/local/nginx/sbin/nginx / sbin/nginx

5 create a directory to store the code and logs

Mkdir / home/yunwei/nginx-data/jl_exam/jl_exam_poral/ROOT-p

Mkdir / home/yunwei/nginx-data/jl_exam/jl_exam_manage_view/ROOT/-p

Mkdir / home/yunwei/nginx-logs/jl_exam/-p

Chmod 755 / home/yunwei/

Chown-R nginx.nginx / home/yunwei/nginx-*

6 Editing the profile

Backup configuration fil

Cp / usr/local/nginx/conf/nginx.conf {, .ori}

Create a virtual host configuration file storage directory

Mkdir / usr/local/nginx/conf/extra/jl_exam

6.1 Editing the nginx.conf main configuration file

Cat > / usr/local/nginx/conf/nginx.conf / etc/rc.local # added to boot self-startup

8 Log slicing configuration

Use the logrotate of the system to cut nginx log files

Create a nginx_jl_exam file

Cat > / etc/logrotate.d/nginx_jl_exam

Tags: Directory file log configuration source code code compilation maximum host backup size Tianhui client client message method version user site system Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Huawei Xiaomi Linux Apple