Install Nginx on Linux (super detailed steps)

1. Enter the official website to download Nginx resources:

Official website download: http://nginx.org/en/download.html
Insert image description here

2. Resource download (because it is installed on Linux, so I downloaded the resource package for Linux installation, you can choose the version you want)

Insert image description here

3. After downloading the resources, upload them to Linux (the location is optional, I uploaded it to /home/myqxin/java)

Insert image description here

4. Unzip the resources and enter the unzipped directory.

Unzip command

# 解压到当前目录下
tar -zxvf 资源包

Screenshot below:
Insert image description here

5. Configure basic information, the command is as follows
#配置configure --prefix 代表安装的路径,--with-http_ssl_module 安装ssl,--with-http_stub_status_module查看nginx的客户端状态
./configure --prefix=/usr/local/nginx-1.20.2 --with-http_ssl_module --with-http_stub_status_module

The execution is completed as follows (there are too many processes and the interception is incomplete. Only the input command and the end effect are intercepted)

Insert image description here
Then you can see that there is an additional Makefile file in our directory
Insert image description here

If the following problems occur when you execute

  • Problem 1:
    Insert image description here
    Solution 1, enter the following command
yum -y install gcc gcc-c++ autoconf automake make

This process needs to wait for some time. The execution is completed as follows (there are too many processes and the interception is incomplete. Only the input command and the end effect are intercepted)

Insert image description here

  • Problem 2:
    Insert image description here
    Solution 2: Enter the following command
yum -y install openssl openssl-devel

This process needs to wait for some time. The execution is completed as follows (there are too many processes and the interception is incomplete. Only the input command and the end effect are intercepted)
Insert image description here

6. Compile and install
#编译安装nginx
make & make install 

This process needs to wait for some time. The execution is completed as follows (there are too many processes and the interception is incomplete. Only the input command and the end effect are intercepted)
Insert image description here

7. Enter the directory after installation (in step 5, we configured the installation location)

Insert image description here

8. Enter the sbin directory and execute the command to start
./nginx

Insert image description here

9. Visit ip:80

Insert image description here
I didn't configure port 80 here, so I just turned off the firewall here.
Insert image description here

10. If you cannot access it, it may be a firewall problem.
添加 --permanent永久生效,没有此参数重启后失效 这里的6379为redis服务的端口,若为其他服务设置,需要对应端口
firewall-cmd --zone=public --add-port=6379/tcp --permanent 
重新载入
firewall-cmd --reload
查看所有打开的端口: 
firewall-cmd --zone=public --list-ports
防火墙的关闭: 
systemctl stop firewalld	//一般不用
防火墙的启动: 
systemctl start firewalld

Guess you like

Origin blog.csdn.net/qq_45752401/article/details/122660965