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以及网络上没被提到的注意点,这里分享一下. ...
随机推荐
- elasticsearch 权威指南聚合阅读笔记(七)
count(1) select clssId,count(1) from student group by classId { "size":0, "aggs" ...
- Appendix B: Netsh Command Syntax for the Netsh Firewall Context
11 out of 19 rated this helpful - Rate this topic Published: December 17, 2004 The following Netsh c ...
- HDU - 4323 - Magic Number
先上题目: Magic Number Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Other ...
- 互联网服务器的实现过程需要考虑哪些安全问题 & 加解密及哈希知识点
http://www.cnblogs.com/charlesblc/p/6341265.html 其中的一篇. 参考 https://zhuanlan.zhihu.com/p/20336461?ref ...
- TCP/IP解析(一):TCP/IP的工作方式
本文包括下面内容: 1.TCP/IP协议系统 2.OSI模型 3.数据包 4.TCP/IP的交互方式 1.TCP/IP模型的协议层 分为四层: 网络訪问层:提供与物理网络连接的接口.依据硬件的物理地址 ...
- Effective JavaScript Item 31 优先使用Object.getPrototypeOf,而不是__proto__
本系列作为Effective JavaScript的读书笔记. 在ES5中引入了Object.getPrototypeOf作为获取对象原型对象的标准API.可是在非常多运行环境中.也提供了一个特殊的_ ...
- C++实现顺序栈的基本功能
栈是限定仅在表头进行插入和删除操作的线性表.有着先进后出的特点(FILO): 如今我来动手实现栈的基本本功能练练手: 定义栈的头文件例如以下: #ifndef CSTOCK_H_ #define CS ...
- c19---指针和字符串
// // main.c // 指针和字符串 // // Created by xiaomage on 15/6/14. // Copyright (c) 2015年 xiaomage. All ri ...
- 略过天涯 深入浅出VGA和DVI接口【转】
本文转载自:http://www.cnblogs.com/lueguo/p/3373649.html 由CrazyBingo修改…… 前言:目前显示器的主流接口是VGA.DVI以及HDMI,再加上一个 ...
- Intel 的 MKL是可以用来训练的——官方的实验也提到了训练
TensorFlow如何充分使用所有CPU核数,提高TensorFlow的CPU使用率,以及Intel的MKL加速 转载 2017年09月07日 16:34:58 标签: cpu / gpu 转载 ...