Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Centos installs nginx tutorials offline


May 29, 2021 Article blog



In hospitals or in some environments, it is usually intranet and has no access to the outside network, so many services have to be installed offline, and the following W3Cschool section tells you how to install Nginx offline in a CentOs system.

Installation preparation

Nginx offline installation depends on the gcc, g++ environment, so check the following systems before installing whether you bring your own gcc and g+, and if not, you need to install it first.

Openssl, pcre, zlib need to be installed before installing Nginx, which, according to Nginx's official website, does not appear to require the openssl version, but for pcre it requires version 8.44, zlib for version 1.2.11, and nginx offline installation package for 1.18.0.

 Centos installs nginx tutorials offline1

Import the downloaded nginx_pacakge unzipped package into the /usr/local directory

Install gcc

Check to see if gcc is installed in the system

gcc -v

 Centos installs nginx tutorials offline2

As shown in the figure, gcc is installed in the system environment and does not need to be installed again, ignoring the following steps.

Otherwise, follow these steps:

Go to the /usr/local/nginx_package/gcc directory and install gcc with the following command:

rpm -ivh *.rpm --nodeps --force

Where --nodeps means ignore dependency checks, --force force installation.  Centos installs nginx tutorials offline3

Install the g-plus

Check to see if gcc is installed in the system

g++ -v

 Centos installs nginx tutorials offline4

As shown in the figure, if you have a g++ installed in your system environment, you do not need to install it again, ignoring the following steps.

Otherwise, follow these steps:

Go to the /usr/local/nginx_package/g?directory and install the g++ with the following command:

rpm -ivh *.rpm --nodeps --force

Where --nodeps indicates ignoring dependency checks,-- force indicates a forced installation.  Centos installs nginx tutorials offline5

Install openssl

Unzip openssl into/usr/local/nginx_package directory and perform the following command to unzip openssl:

tar -zxvf openssl-1.0.2h.tar.gz

Enter the unzipped opensl-1.0.2h directory and do the following commands to prepare for compilation:

./config

 Centos installs nginx tutorials offline6

Compile and install:

make && make install

 Centos installs nginx tutorials offline7

Install pcre

Unzip pcre into the /usr/local/nginx_package directory and unzip the pcre with the following command:

tar -zxvf pcre-8.44.tar.gz

Enter the unzipped pcre-8.44 directory and prepare for compilation with the following commands:

./configure

 Centos installs nginx tutorials offline8

Compile and install:

make && make install

 Centos installs nginx tutorials offline9

Install zlib

Unzip zlib into the /usr/local/nginx_package directory and perform the following command to unzip zlib:

tar -zxvf zlib-1.2.11.tar.gz

Enter the decompressed zlib-1.2.11 directory and do the following commands to prepare for compilation:

./configure

 Centos installs nginx tutorials offline10

Compile and install:

make && make install

 Centos installs nginx tutorials offline11

Install Nginx

Unzip nginx into the /usr/local/nginx_package directory and unzip nginx with the following command:

tar -zxvf nginx-1.18.0.tar.gz

Enter the unzipped nginx-1.18.0 directory, create the nginx directory under /usr/local, and do the following commands to prepare for compilation:

mkdir /usr/local/nginx

./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-pcre=../pcre-8.44 --with-zlib=../zlib-1.2.11 --with-openssl=../openssl-1.0.2h

 Centos installs nginx tutorials offline12

Compile and install:

make && make install

 Centos installs nginx tutorials offline13

Go to the /usr/local/nginx/sbin directory to verify that the installation was successful:

./nginx -t

 Centos installs nginx tutorials offline14

Start nginx

./nginx

Open 80 ports

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

firewall-cmd --reload

Access the test

 Centos installs nginx tutorials offline15