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

Explanation of MySQL index types Normal, Unique and Full Text

MySQL's index types include normal index, uni...

Solution to the problem of English letters not wrapping in Firefox

The layout of text has some formatting requiremen...

How to convert a column of comma-separated values ​​into columns in MySQL

Preface Sometimes you come across business tables...

Implementation of Vue top tags browsing history

Table of contents nonsense Functions implemented ...

Detailed explanation of setting up DNS server in Linux

1. DNS server concept Communication on the Intern...

How to implement parent-child component communication with Vue

Table of contents 1. Relationship between parent ...

How to install and deploy zabbix 5.0 for nginx

Table of contents Experimental environment Instal...

Analysis and solutions to problems encountered in the use of label tags

I used the label tag when I was doing something re...

Simple use of Vue bus

Simple use of Vue bus Scenario description: Compo...

MySQL sql_mode analysis and setting explanation

When inserting a set of data into the MySQL datab...

getdata table table data join mysql method

public function json_product_list($where, $order)...

Implementation of Nginx hot deployment

Table of contents Semaphore Nginx hot deployment ...

An article to deal with Mysql date and time functions

Table of contents Preface 1. Get the current time...

Installation steps of Ubuntu 20.04 double pinyin input method

1. Set up Chinese input method 2. Set the double ...