查看Linux版本
cat /etc/os-release
cd soft
wget http://nginx.org/download/nginx-1.20.2.tar.gz
tar -xvf nginx-1.20.2.tar.gz
运行configure
yum -y install pcre-devel
yum -y install openssl openssl-devel
yum -y install gcc-c++
yum -y install pcre pcre-devel
yum -y install zlib zlib-devel
make
make install
whereis nginx
3、启动nginx
命令:./nginx
./nginx -c xxx/conf/nginx.conf
查看防火墙状态 systemctl status firewalld
开启防火墙 systemctl start firewalld
关闭防火墙 systemctl stop firewalld
开启防火墙 service firewalld start
若遇到无法开启
先用:systemctl unmask firewalld.service
然后:systemctl start firewalld.service
查询已开放的端口 netstat -ntulp | grep 端口号:可以具体查看某一个端口号
查询指定端口是否已开 firewall-cmd --query-port=80/tcp
提示 yes,表示开启;no表示未开启。
添加指定需要开放的端口:firewall-cmd --add-port=80/tcp --permanent
重载入添加的端口:firewall-cmd --reload
移除指定端口:firewall-cmd --permanent --remove-port=80/tcp
查看端口
netstat -an| grep 80
开启端口
iptables -A INPUT -p tcp --dport 端口号 -j ACCEPT
4、停止nginx
命令:./nginx -s stop
5、安全退出nginx
命令:./nginx -s quit
6、重新配置文件
命令:./nginx -s reload
7、查看nginx的进程
命令:ps aux|grep nginx
Kill -9 pid
413 Request Entity Too Large
在http{}中加入 client_max_body_size 10m;
本文详细指导如何在Linux系统上安装Nginx,包括版本查看、源码编译、配置及防火墙设置。从`cat /etc/os-release`开始,讲解了如何通过`wget`下载、编译、配置并启动Nginx,同时介绍了防火墙的开启、关闭、端口操作和安全策略,如`firewalld`的使用和iptables规则的管理。
1447

被折叠的 条评论
为什么被折叠?



