nginx备查大全

nginx基础命令:

sudo nginx // 开启nginx服务器

sudo nginx -s reload // 重启nginx服务器
sudo nginx -s stop // 关闭nginx
nginx -t // 检查nginx配置,如果出现以下提示表示配置成功
nginx: the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok
nginx: configuration file /usr/local/etc/nginx/nginx.conf test is successful

 

文件操作相关:

sudo vim XXX(文件名)  // 打开文件

:q  // 退出vim编辑模式

:wq!  // 保存退出vim模式

sudo touch xxx(文件名)  // 创建一个文件

rm -rf xxx  // 删除xxx文件夹

rm -f  python.py  // 删除xx文件

 

权限相关:

linux chmod xxx  

权限分为三种:读(r=4),写(w=2),执行(x=1)

eg: 

可读可执行(rx=5=4+1)、可读可写(rw=6=4+2)、可读可写可执行(rwx=7=4+2+1)

chmod 755: 

1.文件所有者可读可写可执行

2.与文件所有者同属一个用户组的其他用户可读可执行

3.其它用户组可读可执行

 

nginx配置相关:

nginx代理配置:

在nginx中配置proxy_pass时,如果是按照^~匹配路径时,要注意proxy_pass后的url最后的/,当加上了/,相当于是绝对根路径,则nginx不会把location中匹配的路径部分代理走;如果没有/,则会把匹配的路径部分也给代理走。

 location ^~ /support/ 

  proxy_cache js_cache;
  proxy_set_header Host www.xudengwei.com;
  proxy_pass http://www.xudengwei.com/;
}
如上面的配置,如果请求的url是http://servername/support/test.html
会被代理成http://www.xudengwei.com/test.html

而如果这么配置
location ^~ /support/
{
  proxy_cache js_cache;
  proxy_set_header Host www.xudengwei.com;
  proxy_pass http://www.xudengwei.com;
}
则会被代理到http://www.xudengwei.com/support/test.htm

当然,我们可以用如下的rewrite来实现/的功能
location ^~ /support/
{
  proxy_cache js_cache;
  proxy_set_header Host www.xudengwei.com;
  rewrite /support/(.+)//1 break;
  proxy_pass http://www.xudengwei.com;
}

 

 

转载于:https://www.cnblogs.com/xudengwei/p/9674640.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值