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. ACDream - Crayon

    题目: Description There are only one case in each input file, the first line is a integer N (N ≤ 1,000 ...

  2. 转载 - Pinyin4j的基本用法

    原文:http://blog.csdn.net/pathuang68/article/details/6692882 1.     简单介绍 有时候,需要将汉字编程对应的拼音,以方便数据的处理.比如在 ...

  3. 如何用PYTHON的CGIHTTPSERVER模块模拟POST请求?

    这次又要逼真一点点,可以弄POST请求啦. 在WEB根目录下新建cgi-bin目录(据说是规模要求),然后运行命令: python -m CGIHTTPServer CGI-BIN目录下,form.p ...

  4. [bzoj1055][HAOI2008]玩具取名_区间dp

    玩具取名 bzoj-1055 HAOI-2008 题目大意:给你一个用W,I,N,G组成的字符串,给你一些这四个字符之间的变换规则,每一个变换规则都是由一个字符变成两个字符,问这个字符串是否可能是由一 ...

  5. @Resource与@Autowired区别

    每次理解清楚,过段时间就忘了,还是记一下,方便之后再回看. @ Autowired 是spring提供,包含3种自动装配Bean形式 1.@Autowired默认按类型byType匹配,自动装配Bea ...

  6. POJ 2375

    BFS+强连通.输出max(缩点后出度为0的点数,缩点后入度为0的点数). #include <cstdio> #include <iostream> #include < ...

  7. iOS开发——定制圆形头像与照相机图库的使用

    如今的App都很流行圆形的头像,比方QQ右上角的头像,今日头条的头像等等.这已经成为App设计的趋势了.今天我们就来简单实现一下这个功能,我还会把从手机拍照中或者图库中取出作为头像的照片存储到应用程序 ...

  8. Project Euler:Problem 77 Prime summations

    It is possible to write ten as the sum of primes in exactly five different ways: 7 + 3 5 + 5 5 + 3 + ...

  9. 《从零開始学Swift》学习笔记(Day 56)—— Swift编码规范之命名规范

    原创文章,欢迎转载.转载请注明:关东升的博客 程序代码中到处都是自定义的名字,取一个有样而且符合规范的名字非常重要. 命名方法非常多,可是比較有名的,广泛接受命名法有: 匈牙利命名,一般仅仅是命名变量 ...

  10. 2016.04.06,英语,《Vocabulary Builder》Unit 10

    put, from the Latin verb putare, meaning 'to think, consider, or believe'. reputation: [ˌrepju'teɪʃn ...