nginx 常用命令 保持启动 重载 开机启动等

安装 Nginx 服务

CentOS
首先:

yum install epel-release
yum install nginx

Debian/Ubuntu

dnf install nginx

Fedora

apt install nginx

查看 Nginx 版本

查看版本

nginx -v

详细的使用:

nginx -V

在这里插入图片描述

检查Nginx配置语法正确

nginx -t

也可以查看安装目录
在这里插入图片描述

启动 Nginx 服务

#systemd

systemctl start nginx


#sysvinit

service nginx start

端口开启

如果服务器开启了防火墙,打开 80(HTTP)和 443(HTTPS)端口

firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --reload

开机自启动

systemctl enable nginx

or

service nginx enable

重启 Nginx 服务

systemctl restart nginx

or

service nginx restart

查看 Nginx 服务状态

systemctl status nginx

or

service nginx status

重载 Nginx 服务吗,配置文件更新,重置载入

systemctl reload nginx

or

service nginx reload

停止 Nginx 服务

systemctl stop nginx

or

service nginx stop

查看进程,使用lsof命令 ,也查到80端口进程是否有进程在运行。

lsof -i:80 

查看软件安装路径

whereis nginx

查询运行文件所在路径

which nginx
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值