linux系统nginx常用命令

本文讲述了在Nginx配置中遇到关于proxy_pass不能包含URI部分的错误,特别是当在location或if语句中使用正则表达式时。作者详细解释了问题原因,并提供了解决方法。
摘要由CSDN通过智能技术生成

查nginx位置
find / -name nginx

nginx目录:/usr/local/

查看nginx进程号
ps -ef |grep nginx

停止进程
kill 2072

启动
./sbin/nginx
/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf

启动并校验校验配置文件
./sbin/nginx -t
看到如下显示nginx.conf syntax is ok nginx.conf test is successful 说明配置文件正确!

停止
./sbin/nginx -s stop

重启nginx服务
./sbin/nginx -s reload

另外一种方式:
nginx启动
start nginx

nginx停止
nginx -s stop

停止80端口
net stop http

nginx: [emerg] “proxy_pass” cannot have URI part in location given by regular expression, or inside named location, or inside “if” statement, or inside “limit_except” block
1、修改nginx.conf后,重启时报错
2、错误原因

如果location或if中用到了正则,则不能再转发除ip:port外的路径请求
正确:
location ^~ /tools {
if (!-e $request_filename) {
proxy_pass http://localhost:1620;
}
}
错误:
location ^~ /tools {
if (!-e $request_filename) {
proxy_pass http://localhost:1620/tools;
}
}

$request_filename
当前连接请求的文件路径,由root或alias指令与URI请求生成。
$request_filename 就是请求资源的路径啦~~

例如example.com/test.php,应该对应的是 root下的 index.php 和 test.php
当然还有看前面有没有伪静态规则什么的。。。

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Java知识技术分享

感谢支持!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值