The whole process of installing nginx 1.22 on the new server CentOS 8.2

1. Go to the official website to download the latest version of nginx (version optional)

nginx: downloadicon-default.png?t=M7J4http://nginx.org/en/download.html

 

2. Upload to the server, I use xftp here

3.tar decompression

tar -xvf nginx-1.22.0.tar.gz

 4. Install PCRE first, the role of PCRE is to enable Nginx to support the Rewrite function.

        Here it is recommended to install everything in one step, so as to save you from reinstalling when you need it later

I installed it here in the /opt/nginx/ directory

#进入安装目录
cd /opt/nginx/pcre
#下载安装包
wget http://downloads.sourceforge.net/project/pcre/pcre/8.45/pcre-8.45.tar.gz
#解压安装包
tar zxvf pcre-8.45.tar.gz
#进入安装包目录
cd pcre-8.45
#编译安装
./configure
 make && make install

There may be an error in ./configure:

 This is because the system lacks  the gcc-c++  library, which can be solved by installing it: the root super administrator user executes the following command, and the non-root super administrator adds it  sudo to obtain permission to execute.

#ROOT用户
yum install -y gcc-c++
#普通用户
# sudo yum install -y gcc-c++

After solving the problem, just  make && make install .

5. Here I modified the directory structure and renamed the directory of the installation file, and then I plan to install Nginx here:

6. Set the installation path, install

./configure --prefix=/opt/nginx/nginx-1.22.0 --with-http_stub_status_module --with-http_ssl_module --with-pcre=/opt/nginx/pcre/pcre-8.45
make 

make install

Pay attention to modify the installation path and change it to the path you specify.

If the error is as follows, you need to install the OpenSSL library

 Solution:

yum install openssl-devel

Enter y to confirm and the installation is complete:

 Then re-run the above installation command.

7. After the installation is complete, enter the sbin directory and check the nginx version

 8. Start nginx

 9. Try to access my server by ip

Nginx is bound to port 80 by default, and the server firewall is open to port 80 by default, so you can access it directly

 Well, you're done!

Guess you like

Origin blog.csdn.net/qq_16382227/article/details/126483487