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

配置文件

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 (待更新)的更多相关文章

  1. 【笔记】Nginx热更新相关知识

    (以下学习笔记内容均摘自参考链接,仅供个人查阅)   1.inotify文件系统监控特性 Inotify 是一个 Linux 内核特性,它监控文件系统,并且及时向专门的应用程序发出相关的事件警告,比如 ...

  2. nginx 平滑更新

    1.更新nginx源 #centos6的nginx源 #centos7的话吧url 的6改为7就行了 vim /etc/yum.repos.d/nginx.repo [nginx] name=ngin ...

  3. 一种使用gitlab的CI/CD功能实现Nginx配置更新的方法

    至于nginx的docker制作,前面已介绍过. 现在使用gitlab在线编辑的方式,可实现Nginx的自定义配置并更新. .gitlab-ci.yml内容如下: variables: project ...

  4. linux nginx svn 更新前端代码

    1.进入项目前端代码目录中 root@TServer:~# cd /home/p/web/gongti/ 2.更新svn上最新的代码版本 root@TServer:/home/p/web/gongti ...

  5. 负载均衡之nginx+consul(自动更新路由)

    前几篇先是记载了如何通过nginx配置服务负载均衡,后面记载了如何通过 ocelot 配置 服务负载均衡,分别介绍了用webapi注册服务以及配置文件注册服务,通过ocelot webapi + co ...

  6. Ansible安装配置Nginx

    一.思路 现在一台机器上编译安装好nginx.打包,然后在用ansible去下发 cd /etc/ansible 进入ansible配置文件目录 mkdir roles/{common,install ...

  7. [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. 安 ...

  8. Linux下Web服务器环境搭建LNMP一键安装包[20130911更新]

    2012年08月14日 ⁄ LNMP ⁄ 评论数 73 ⁄ 被围观 25,200次+ 最新版本:lnmp-2.4 安装说明:请保证服务器能够正常上网.服务器系统时间准确.yum命令可以正常使用! 1. ...

  9. Nginx模块fastcgi_cache的几个注意点 转

    Nginx模块fastcgi_cache的几个注意点   去年年底,我对nginx的fastcgi_cache进行摸索使用.在我的测试过程中,发现一些wiki以及网络上没被提到的注意点,这里分享一下. ...

随机推荐

  1. Spring Cloud Stream(十三)

    说明 对Spring Boot 和 Spring Integration的整合,通过Spring Cloud Stream能够简化消息中间件使用的复杂难度!让业务人员更多的精力能够花在业务层面 简单例 ...

  2. HDU4572 Bottles Arrangement

    /* HDU4572 Bottles Arrangement http://acm.hdu.edu.cn/showproblem.php?pid=4572 数论 找规律 题意:有m行n列和1-n的数各 ...

  3. ACDream - Graphs

    先上题目: Graphs Time Limit: 4000/2000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others) Submit ...

  4. DJANGO里让用户自助修改密码

    参考了网上的实现,最终实现的各代码如下: changepwd.html模板文件: {% extends "Prism/index.html" %} {% load staticfi ...

  5. mongodb--group聚合运算

    mongodb本质就是要做一个高性能,能简单则简单,不要把mongodb中的运算做的太复杂 count 最简单的一个聚合方法 distinct 选择结果中剔除重复的一个键值, 跟sql语句的效果是一样 ...

  6. C语言学习笔记:15_c语言中的进制操作.c

    /* * 15_c语言中的进制操作.c * * Created on: 2015年7月5日 * Author: zhong */ #include <stdio.h> #include & ...

  7. hdu1209(Clock)

    pid=1209">点击打开hdu1209 Problem Description There is an analog clock with two hands: an hour h ...

  8. 【cocos2d-x 3.7 飞机大战】 决战南海I (八) 背景移动

    採用双层背景.这样效果更好 .h class BackgroundMove : public Layer { public: BackgroundMove(); ~BackgroundMove(); ...

  9. bzoj-3524 Couriers

    题意: 给出一个长度为n的序列和m次询问. 每次询问给出区间[l,r],求区间中出现次数大于(r-l+1)/2的数字. n.m<=500000.1<=每一个数字<=n: 题解: 主席 ...

  10. C#趣味程序----分数之和

    问题:求这种四个自然数p,q,r,s(p<=q<=r<=s).使得等式1/p + 1/q +1/r +1/s=1成立. 分析:将原式同分,化简整理后得到:2<=p<5,p ...