How to install nginx in centos7

How to install nginx in centos7

Install the required environment

1. gcc installation

To install nginx, you need to compile the source code downloaded from the official website. The compilation depends on the gcc environment. If you don’t have the gcc environment, you need to install it:

yum install gcc-c++

2. PCRE pcre-devel installation

PCRE (Perl Compatible Regular Expressions) is a Perl library that includes a Perl compatible regular expression library. The http module of nginx uses pcre to parse regular expressions, so the pcre library needs to be installed on Linux. pcre-devel is a secondary development library developed using pcre. nginx also requires this library. Order:

yum install -y pcre pcre-devel

3. zlib installation

The zlib library provides many compression and decompression methods. Nginx uses zlib to gzip the contents of the http package, so the zlib library needs to be installed on Centos.

yum install -y zlib zlib-devel

4. OpenSSL Installation

OpenSSL is a powerful secure socket layer cryptographic library that includes major cryptographic algorithms, commonly used key and certificate packaging management functions, and SSL protocols, and provides a wealth of applications for testing or other purposes. Nginx not only supports the http protocol, but also supports https (that is, transmitting http over the ssl protocol), so you need to install the OpenSSL library on Centos.

yum install -y openssl openssl-devel

Download the official website

Download the .tar.gz installation package directly from: https://nginx.org/en/download.html

Unzip

tar -zxvf nginx-1.10.1.tar.gzcd nginx-1.10.1

Configuration
1. Use the default configuration

./configure

Compile and install

make
make install

Find the installation path:

whereis nginx

Start and stop nginx

cd /usr/local/nginx/sbin/
./nginx
./nginx -s stop
./nginx -s quit
./nginx -s reload

Query the nginx process: ps aux|grep nginx

To enable automatic startup, just add the startup code in rc.local.

vi /etc/rc.local

Add a row

/usr/local/nginx/sbin/nginx

Set Execute Permissions

chmod 755 rc.loca

You may also be interested in:
  • Install and configure Nginx on CentOS 7
  • Two methods of installing nginx on centos7
  • Detailed explanation of the solution to Nginx startup in Centos7
  • CentOS7 + node.js + nginx + MySQL server building process
  • How to Install Nextcloud with Nginx and PHP7-FPM in CentOS7
  • Compile, install and configure Nginx+PHP+MySql environment under Centos7
  • CentOS7 configuration Nginx support HTTPS access implementation solution

<<:  Pitfalls encountered when installing MySQL 5.7.17 compressed version under Windows

>>:  Implementation of WeChat applet message push in Nodejs

Recommend

How to use dynamic parameters and calculated properties in Vue

1. Dynamic parameters Starting from 2.6.0, you ca...

How to manually upgrade the node version under CentOs

1. Find the corresponding nodejs package, refer t...

Learn the key knowledge that must be mastered in the Vue framework

1. What is Vue Vue is a progressive framework for...

Vue sample code for implementing two-column horizontal timeline

Table of contents 1. Implement the component time...

Introduction to vim plugin installation under Linux system

Table of contents Install vim plugin manager Add ...

MySQL 8.0.12 Installation and Configuration Tutorial

This article records the detailed tutorial for in...

JavaScript operation element examples

For more information about operating elements, pl...

The latest collection of 18 green style web design works

Toy Story 3 Online Marketing Website Zen Mobile I...

A simple way to implement all functions of shopping cart in Vue

The main functions are as follows: Add product in...

Basic knowledge of MySQL database

Table of contents 1. Understanding Databases 1.1 ...

React Class component life cycle and execution order

1. Two ways to define react components 1. Functio...

How to configure Nginx's anti-hotlinking

Experimental environment • A minimally installed ...