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.
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.
Import the downloaded nginx_pacakge unzipped package into the /usr/local directory
Check to see if gcc is installed in the system
gcc -v
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.
Check to see if gcc is installed in the system
g++ -v
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.
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
Compile and install:
make && make install
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
Compile and install:
make && make install
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
Compile and install:
make && make install
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
Compile and install:
make && make install
Go to the /usr/local/nginx/sbin directory to verify that the installation was successful:
./nginx -t
./nginx
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --reload