Web服务器—Nginx

Nginx常用命令:

启动nginx服务

[root@localhost ~]# service nginx start
[root@localhost ~]# systemctl start nginx.service
[root@localhost ~]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf      # nginx安装目录 -c nginx.conf配置文件目录。
[root@localhost sbin]# ./nginx      # 进入/usr/local/nginx/sbin/ 即nginx的安装目录下。通过 ./nginx 启动nginx服务。
# 启动nginx服务:参数 “-c” 指定了配置文件的路径,如果不加 “-c” 参数,Nginx 会默认加载其安装目录的 conf 子目录中的 nginx.conf 文件。

停止nginx服务

[root@localhost ~]# service nginx stop
[root@localhost ~]# systemctl stop nginx.service
[root@localhost sbin]# ./nginx -s stop    进入 nginx 的安装目录。通过 ./nginx -s stop 停止nginx服务。先查出nginx进程id,再使用kill命令强制杀掉进程。
[root@localhost sbin]# ./nginx -s quit    进入 nginx 的安装目录。通过 ./nginx -s quit 停止nginx服务。先等待nginx进程处理任务完毕后再停止。

重启nginx服务

[root@localhost ~]# service nginx restart
[root@localhost ~]# systemctl restart nginx.service
[root@localhost sbin]# ./nginx -s quit         # 对 nginx 进行先停止再启动。
[root@localhost sbin]# ./nginx

重载nginx配置文件

[root@localhost ~]# service nginx reload
[root@localhost ~]# systemctl reload nginx.service
[root@localhost sbin]# ./nginx -s reload          进入nginx的安装目录。通过 ./nginx -s reload 重新加载nginx配置文件。
# 当 nginx的配置文件 nginx.conf 修改后,要想让配置生效需要重启 nginx,使用-s reload不用先停止再启动 nginx,即可将配置信息在 nginx 中生效。

其他nginx命令

# 查看nginx安装目录
[root@localhost ~]# ps -ef | grep nginx
# 查看nginx.conf配置文件目录,验证nginx配置文件是否正确。进入nginx安装目录下,执行./nginx -t命令。
[root@localhost sbin]# ./nginx -t      

Nginx配置文件:

转载于:https://www.cnblogs.com/liuhaidon/p/11601841.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值