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

Initial summary of the beginner's website building tutorial

After writing these six articles, I started to fee...

Implementation of tomcat deployment project and integration with IDEA

Table of contents 3 ways to deploy projects with ...

How to use the Linux md5sum command

01. Command Overview md5sum - Calculate and verif...

CSS Skills Collection - Classics among Classics

Remove the dotted box on the link Copy code The co...

Detailed explanation of the wonderful CSS attribute MASK

This article will introduce a very interesting at...

Solve the problem that Docker cannot ping the host machine under Mac

Solution Abandon the Linux virtual machine that c...

Html+CSS drawing triangle icon

Let’s take a look at the renderings first: XML/HT...

Token verification login in Vue project (front-end part)

This article example shares the specific code of ...

How to insert a link in html

Each web page has an address, identified by a URL...

MySQL 8.0.20 installation and configuration tutorial under Docker

Docker installs MySQL version 8.0.20 for your ref...

Two methods of MySql comma concatenation string query

The following two functions are used in the same ...