nginx (待更新)
install
apt install nginx
默认在 /etc/nginx 目录下
一个 master 以及多个 worker
3504 root 20 0 141M 7196 5552 S 0.0 0.4 0:00.03 nginx: master process nginx
6154 www-data 20 0 141M 3628 1828 S 0.0 0.2 0:00.00 `- nginx: worker process
6152 www-data 20 0 141M 3628 1828 S 0.0 0.2 0:00.00 `- nginx: worker process
常用命令
- nginx
- nginx -s stop
- nginx -s quit
- nginx -s reload
- nginx -s reopen
配置文件
- 语法
- 简单指令由空格分隔, 并且以
;
结尾 - 块指令由
{}
包围
- 简单指令由空格分隔, 并且以
- 参考文章 https://zhuanlan.zhihu.com/p/31202053
events {
worker_connections 768;
# multi_accept on;
}
http {
server {
root /opt;
location /test {
root /etc;
}
location /tmp/ {
root /home;
}
}
}
上面的这个配置文件:
当 path == test
的时候, eg: http://127.0.0.1/test/hello.txt 则 nginx 会 open /etc/test/hello.txt
path == /tmp
, eg: http://127.0.0.1/tmp/hello.txt 则 nginx open /home/tmp/hello.txt
path != test and path != tmp
eg:http://127.0.0.1/hello/hello.txt 则 nginx open /opt/htllo/hello.txt
- 注意: location 中不定义 root 则会使用 server 中定义的 root
例如:
location / {
# empty
}
反向代理
location /{
proxy_pass http://google.com;
}
使用通配符
location ~\.(pdf|doc) {
root /opt;
}
- 所以 当存在
location /{
root /opt;
}
的时候, 不符合 test 并且不符合 tmp 的请求会转发到 /opt/path 下
管理
- master pid
➜ nginx cat /var/run/nginx.pid
3504
查看日志
- /var/log/nginx
命令:
- /etc/init.d/nginx restart |start|stop
- seservice nginx status
组成部分
user www-data;
worker_processes 1;
pid /run/nginx.pid;
events {
worker_connections 768;
}
http {
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
gzip on;
gzip_disable "msie6";
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
nginx (待更新)的更多相关文章
- 【笔记】Nginx热更新相关知识
(以下学习笔记内容均摘自参考链接,仅供个人查阅) 1.inotify文件系统监控特性 Inotify 是一个 Linux 内核特性,它监控文件系统,并且及时向专门的应用程序发出相关的事件警告,比如 ...
- nginx 平滑更新
1.更新nginx源 #centos6的nginx源 #centos7的话吧url 的6改为7就行了 vim /etc/yum.repos.d/nginx.repo [nginx] name=ngin ...
- 一种使用gitlab的CI/CD功能实现Nginx配置更新的方法
至于nginx的docker制作,前面已介绍过. 现在使用gitlab在线编辑的方式,可实现Nginx的自定义配置并更新. .gitlab-ci.yml内容如下: variables: project ...
- linux nginx svn 更新前端代码
1.进入项目前端代码目录中 root@TServer:~# cd /home/p/web/gongti/ 2.更新svn上最新的代码版本 root@TServer:/home/p/web/gongti ...
- 负载均衡之nginx+consul(自动更新路由)
前几篇先是记载了如何通过nginx配置服务负载均衡,后面记载了如何通过 ocelot 配置 服务负载均衡,分别介绍了用webapi注册服务以及配置文件注册服务,通过ocelot webapi + co ...
- Ansible安装配置Nginx
一.思路 现在一台机器上编译安装好nginx.打包,然后在用ansible去下发 cd /etc/ansible 进入ansible配置文件目录 mkdir roles/{common,install ...
- [Linux]Nginx + Node.js + PM2 + MongoDb + (Memcached) Part I
运行环境: 在本地的VirtualBox下运行的Ubuntu 14.04 LTS 0. 查看一下Server的IP地址 ifconfig 我的Server IP是192.168.0.108 1. 安 ...
- Linux下Web服务器环境搭建LNMP一键安装包[20130911更新]
2012年08月14日 ⁄ LNMP ⁄ 评论数 73 ⁄ 被围观 25,200次+ 最新版本:lnmp-2.4 安装说明:请保证服务器能够正常上网.服务器系统时间准确.yum命令可以正常使用! 1. ...
- Nginx模块fastcgi_cache的几个注意点 转
Nginx模块fastcgi_cache的几个注意点 去年年底,我对nginx的fastcgi_cache进行摸索使用.在我的测试过程中,发现一些wiki以及网络上没被提到的注意点,这里分享一下. ...
随机推荐
- Nexus私服的搭建
1.nexus 介绍 是开源的,用该框架架设maven私有服务器 2.nexus私服环境搭建 把nexus.war包放到tomcat的webapps下面 浏览且登录 ...
- 格式化LInux后开机进入grub怎么办
问题:格式化Linux系统盘之后,重启进入grub 1.grub 引导进入windows系统 进入grub grub>rootnoverify (hd0,1) [可以使用Tab键( 比如 roo ...
- JS代码引用位置问题-转
看到很多JS代码全部放在head中的情况,其实这是个细节问题.转载一个知乎用户于江水的答案: 作者:于江水链接:https://www.zhihu.com/question/34147508/answ ...
- 洛谷——P1361 小猫爬山
https://www.luogu.org/problem/show?pid=1361#sub 题目描述 WD和LHX饲养了N只小猫,这天,小猫们要去爬山.经历了千辛万苦,小猫们终于爬上了山顶,但是疲 ...
- HDUOJ--4888--Redraw Beautiful Drawings【isap】网络流+判环
链接:http://acm.hdu.edu.cn/showproblem.php? pid=4888 题意:一个矩阵.限定每行行和.列和,每一个格子数字不超过k,问矩阵是否存在,如存在推断有单解还是多 ...
- [Cypress] Load Data from Test Fixtures in Cypress
When creating integration tests with Cypress, we’ll often want to stub network requests that respond ...
- wifi断线问题
近期在项目中,遇到wifi常常断线现象,平台是Android平台,现象是:连接wifi后,长时间播放视频,会出现wifi断开,界面上WiFi图标显示打叉,请问有WiFi方面的行家朋友,有没有办法来检測 ...
- maven环境配置好,一直提示mvn不是内部命令
设置了环境变量 M2_HOME 跟path ,在cmd中输入mvn一直提示不是内部命令 解决办法:通过命令设置path 如下:set path=输入值
- python 读取二进制文件 转为16进制输出
示例: #!/usr/bin/env python #encoding: utf-8 import binascii fh = open(r'C:\Temp\img\2012517165556.png ...
- hdoj--3072--Intelligence System(scc+缩点+数据去重)
Intelligence System Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Othe ...