[Pictures and texts] Installation steps of linux system nginx

Installation environment (written in front):

Operating system: CentOS7 64-bit
nignx version: 1.18.0

1: Configure the nginx installation environment

  • 1.1: Before installing nginx To compile the source code, compile the source code dependent on gccthe environment, so you need to install gccinstructions
yum install gcc-c++
  • 1.2: The HTTP module of nginx is used pcreto parse regular expressions, so the installation pcrelibrary needs to be installed . The instructions are as follows:
yum install -y pcre pcre-devel
  • 1.3: nginx uses zlibgzip compression on the content of the HTTP module, so it needs to be installed zlib. The instructions are as follows:
yum install -y zlib zlib-devel
  • 1.4: nginx not only supports the http protocol, but also supports https (that is, HTTP is transmitted over the ssl protocol), so you need to install the OpenSSL library, the instructions are as follows:
yum install -y openssl openssl-devel

2: Download the nginx compressed package

Download link: http://nginx.org/en/download.html

Insert picture description here
(This installation uses the linux version as an example)

3: Upload the nginx compressed package and install it

  • 3.1 Create a blank folder
mkdir /usr/local/nginx-1.18.0
  • 3.2 Upload the downloaded tar package to the nginx-1.18.0 folder and decompress it
tar -zxvf nginx-1.18.0.tar.gz 
  • 3.3 Enter the unzipped directory
cd nginx-1.18.0
  • 3.4 Use the default configuration to generate a Makefile
./configure
  • 3.5 Compile (a bunch of C files will be generated, which takes a long time, wait patiently)
make
  • 3.6 After the compilation is successful, start the installation
make install

4: Start nginx

Since the default installation is used, the files generated by the successful installation are in the /usr/local directory.

Enter the sbin directory:

cd /usr/local/nginx/sbin

Start nginx:

./nginx

Close nginx:

./nginx -s quit

Set the power-on auto-start:

vim /etc/rc.local

Just add it at the bottom /usr/local/nginx/sbin/nginx.

Problem: After nginx is installed successfully, the machine cannot be accessed. The solution is as follows:

Open port 80, permanent access:

firewall-cmd --zone=public --add-port=80/tcp --permanent  

Turn off the firewall:

systemctl stop firewalld.service

Restart the firewall:

systemctl start firewalld.service

Guess you like

Origin blog.csdn.net/single_0910/article/details/113061140