Nginx启动命令和停止命令(nginx启动命令和停止命令linux)

Nginx启动命令和停止命令(nginx启动命令和停止命令linux)

扫码添加渲大师小管家,免费领取渲染插件、素材、模型、教程合集大礼包!

Nginx是一个高性能的HTTP和反向代理服务器。特点是占用内存少。并发能力强。事实上Nginx的并发能力确实在同类型的网页服务器中表现较好。使用Nginx的过程中。我们可能总是需要修改Nginx配置文件。然后不停地启动或者停止Nginx服务。本文为大家整理汇总了Nginx启动命令和停止命令。

一。启动 Nginx 服务

启动Nginx非常简单。 只需运行以下命令:

sudo systemctl start nginx

成功执行后。该命令不会产生任何输出。

如果您使用的发行版上没有安装 systemd ,可以通过以下命令启动:

sudo service start nginx

除了手动启动 Nginx 服务。建议将其设置为在系统启动时自动启动。通过以下命令进行设置:

sudo systemctl enable nginx

二。停止 Nginx 服务

即使存在打开的连接。停止Nginx也会快速关闭所有 Nginx 工作进程。

要停止Nginx。请运行以下命令之一:

sudo systemctl stop nginx

如果您使用的发行版上没有安装 systemd ,可以通过以下命令停止:

sudo service stop nginx

三。重启 Nginx 服务

重启是一种先停止然后再启动 Nginx 服务器的快速方法。

使用以下命令执行 Nginx 重新启动:

sudo systemctl restart nginx

如果您使用的发行版上没有安装 systemd ,可以通过以下命令重启:

sudo service restart nginx

这些是您可能最常使用的命令。

四。重载 Nginx 配置文件

当您更改其 Nginx 配置时。您都需要重新加载或重新启动 Nginx。重新加载选项将加载新配置。使用新配置启动新的工作进程并正常关闭旧工作进程。服务并不会中断。

要重新加载Nginx配置。请使用以下命令:

sudo systemctl reload nginx

如果您使用的发行版上没有安装 systemd ,可以通过以下命令重载:

sudo service reload nginx

五。测试 Nginx 配置

每当您更改 Nginx 服务器的配置文件时。最好在重新启动或重新加载服务之前测试配置。

使用以下命令测试 Nginx 配置是否存在任何语法或系统错误:

sudo nginx -t

输出类似如下:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

如果有任何错误。命令将打印详细消息。

六。查看 Nginx 状态

要检查 Nginx 服务的状态。请使用以下命令:

sudo systemctl status nginx

输出结果类似如下:

nginx.service - A high performance web server and a reverse proxy server
   Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
   Active: active (running) since Sun 2019-07-18 10:57:01 PDT; 5min ago
     Docs: man:nginx(8)
  Process: 4491 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid (code=exited, status=0/SUCCESS)
  Process: 4502 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
  Process: 4492 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
 Main PID: 4504 (nginx)
    Tasks: 3 (limit: 2319)
   CGroup: /system.slice/nginx.service
           |-4504 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
           |-4516 nginx: worker process
           `-4517 nginx: worker process

结果中的Active: active (running)显示了 Nginx 运行状态。

七。检查 Nginx 版本

有时您可能需要知道 Nginx 的版本。以便调试问题或确定某个功能是否可用。

您可以通过运行以下方式检查您的 Nginx 版本:

sudo nginx -v

和小写-v不同使用参数-V选项将输出 Nginx 版本以及 configure 选项。注意这个是大写的V

sudo nginx -V
分享到 :
相关推荐

服务器固态硬盘有哪些优势(服务器固态硬盘有哪些优势和劣势)

服务器固态硬盘的优势:1。服务器使用固态硬盘能够有效提高服务器读写速度。使数据传输变...

澳门服务器租用哪家有(澳门服务器租用哪家有保险柜)

澳门服务器是全中国少数没有实行备案。白名单制度的地区之一。其到达内陆地区各省市速度均...

Krypt iON账户付款发票打印教程

iON和Krypt的关系想必不用多说。大多数用户都知道。iON是以美国云主机和美国[...

爬虫程序用来干什么(网络爬虫有什么用途)

大家好,今天来介绍爬虫程序用来干什么(爬虫python能做什么工作)的问题,以下是渲...

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注