内网安装nginx

第一部下载nginx 的rpm 

网址

nullicon-default.png?t=N2N8https://nginx.org/packages/centos/7/x86_64/RPMS/步骤三:安装。执行安装命令:rpm -ivh rpm包的名字

安装报错 

sudo rpm -ivh nginx-1.22.1-1.el7.ngx.x86_64.rpm 
warning: nginx-1.22.1-1.el7.ngx.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 7bd9bf62: NOKEY
error: Failed dependencies:
        libpcre2-8.so.0()(64bit) is needed by nginx-1:1.22.1-1.el7.ngx.x86_64

安装 libpcre2-8.so.0()(64bit) 

RPM resource libpcre2-8.so.0()(64bit)

安装成功

备注:我安装的nginx默认在/etc/nginx 目录下。

nginx 启动
nginx -s reload 重新加载配置文件并重启。
nginx -s reopen 重启
nginx -s stop 关闭nginx
nginx -s quit 进程结束后关闭
nginx -t 查看当前nginx配置是否有错误
nginx -t -c <配置路径> 检查配置是否有问题,如果已在配置目录,则不需要 -c
whereis nginx 查找nginx位置

1. 防火墙的开启、关闭、禁用命令
设置开机启用防火墙:systemctl enable firewalld.service
设置开机禁用防火墙:systemctl disable firewalld.service
启动防火墙:systemctl start firewalld
关闭防火墙:systemctl stop firewalld
检查防火墙状态:systemctl status firewalld
2. 使用firewall-cmd配置端口
查看防火墙状态:firewall-cmd --state
重新加载配置:firewall-cmd --reload
查看开放的端口:firewall-cmd --list-ports
开启防火墙端口:firewall-cmd --zone=public --add-port=9200/tcp --permanent
命令含义:
–zone #作用域
–add-port=9200/tcp #添加端口,格式为:端口/通讯协议
–permanent #永久生效,没有此参数重启后失效
注意:添加端口后,必须用命令firewall-cmd --reload重新加载一遍才会生效
关闭防火墙端口:firewall-cmd --zone=public --remove-port=9200/tcp --permanen

猜你喜欢

转载自blog.csdn.net/linsenaa/article/details/129832446