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. windows 2003一个网卡绑定多个IP地址

    1.打开“网络连接”,选中需要添加多个IP的“本地连接”-->右键-->“属性”: 2.从“常规”中找到“Internet 协议(TCP/IP)属性”: 3.选择手动设置IP地址.网关.掩 ...

  2. WinRTXamlToolkit在Win8.1实现统计图

    [注1]WinRTXamlToolkit是免费控件,不过很久不更新了,而且网上的资源很少.后来我发现syncfusion控件有免费的community版本,并且有详细文档,所以就转过去使用syncfu ...

  3. [bzoj3717][PA2014]Pakowanie_动态规划_状压dp

    Pakowanie bzoj-3717 PA-2014 题目大意:给你n个物品m个包,物品有体积包有容量,问装下这些物品最少用几个包. 注释:$1\le n\le 24$,$1\le m\le 100 ...

  4. Apache Shiro教程

    跟开涛学系列: 来自开涛的Apache Shiro教程:http://jinnianshilongnian.iteye.com/blog/2018398 附带的代码例子:https://github. ...

  5. AutoSharedLibrary -- 基于模板元编程技术的跨平台C++动态链接载入库

    基于模板元编程技术的跨平台C++动态链接载入库.通过模板技术,使用者仅需通过简单的宏,就可以使编译器在编译期自己主动生成载入动态链接库导出符号的代码,无不论什么额外的执行时开销. extern &qu ...

  6. 黑马day07 登录注冊案例(一)

    简单介绍:依据三层架构的思想设计本案例. 1.搭建好开发环境 准备好须要的包和模拟数据库配置文件users.xml -->cn.itheima.dao -->cn.itheima.serv ...

  7. PHP独立操作符

    & 与 ^ 位逻辑异或 $ # ! 逻辑或 ~  按位取反

  8. PHP之实现双向链表(代码篇)

    <?php/** * PHP之实现双向链表 */class Hero{ public $pre=null; public $no; public $name; public $next=null ...

  9. 在linux下怎么安装.bin的文件

    *.bin文件安装方法: 1.运行终端到文件目录下2.在终端输入:sudo chmod +x *.bin3.再输入:sudo ./*.bin可安装到任意目录,./*.bin可安装到当前用户有权限的目录

  10. 搜索分析(DFS、BFS、递归、记忆化搜索)

    搜索分析(DFS.BFS.递归.记忆化搜索) 1.线性查找 在数组a[]={0,1,2,3,4,5,6,7,8,9,10}中查找1这个元素. (1)普通搜索方法,一个循环从0到10搜索,这里略. (2 ...