#nginx 监听原理 先监听端口 --> 再配置域名 -->匹配到就访问local  否则  没有匹配到域名就默认访问第一个监听端口的local地址

# vi nginx.conf
user nobody nobody; # 运 nginx的所属组和所有者
worker_processes ; # 开启两个 nginx工作进程,一般几个 CPU核心就写几
error_log logs/error.log notice; # 错误日志路径
pid logs/nginx.pid; # pid 路径
events {
worker_connections ; # 一个进程能同时处理1024个请求
}
http {
  include mime.types;
  default_type application/octet-stream;   log_format main $remote_addr – $remote_user [$time_local] “$request” $status $body_bytes_sent “$http_referer” $http_user_agent” “$http_x_forwarded_for” ;
  access_log logs/access.log main; # 默认访问日志路径
  sendfile on;
  keepalive_timeout ; # keepalive超市时间
  # 开始配置一个域名,一个server配置段一般对应一个域名
  server {
    listen ; # 监听端口()
    # 在本机所有ip上监听80,也可以写为192.168.1.202:80,这样的话,就只监听192.168.1.202 上的80口
    server_name www.heytool.com; # 域名
    root /www/html/www.heytool.com; # 站点根目录(程序目录)
    index index.html index.htm; # 索引文件
    #  可以有多个 location 
    location / { 
      #proxy_pass www.baidu.com # 跳到 百度页面 (网址)
      root /www/html/www.heytool.com; # 站点根目录(程序目录) (本地的路径)
    }
    error_page /50x.html;
    # 定义错误页面,如果是500错误,则把站点根目录下的50x.html返回给用户
    location = /50x.html {
    root /www/html/www.heytool.com;
  }
}
#nginx 监听原理 先监听端口 --> 再配置域名 -->匹配到就访问local  否则  没有匹配到域名就默认访问第一个监听端口的local地址

//看到ok和successful,说明配置文件没问题

# /usr/local/nginx-1.0.6/sbin/nginx –t 
nginx: the configuration file /usr/local/ nginx-1.0.6/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/ nginx-1.0.6/conf/nginx.conf test is successful

#启动 nginx
# /usr/local/nginx-1.0.6/sbin/nginx

#重启 nginx
# /usr/local/nginx-1.0.6/sbin/nginx  -s reload

nginx.conf配置文件的简单说明的更多相关文章

  1. [原]生产环境下的nginx.conf配置文件(多虚拟主机)

    [原]生产环境下的nginx.conf配置文件(多虚拟主机) 2013-12-27阅读110 评论0 我的生产环境下的nginx.conf配置文件,做了虚拟主机设置的,大家可以根据需求更改,下载即可在 ...

  2. Nginx入门讲解——初步认识了解nginx.conf配置文件以及配置多个虚拟主机

    本文引自网络进攻学习之用https://blog.csdn.net/weixin_38111957/article/details/81080539 一. 引言上节文章讲述了如何用信号控制Nginx服 ...

  3. Nginx(二)------nginx.conf 配置文件

    上一篇博客我们将 nginx 安装在 /usr/local/nginx 目录下,其默认的配置文件都放在这个目录的 conf 目录下,而主配置文件 nginx.conf 也在其中,后续对 nginx 的 ...

  4. nginx.conf配置文件里的upstream加入健康检查

    查看NGINX启用了那些模块: # ./nginx -V Tengine version: Tengine/ (nginx/) built by gcc (Red Hat -) (GCC) TLS S ...

  5. Nginx.conf 配置文件详细说明

    在此记录下Nginx服务器nginx.conf的配置文件说明, 部分注释收集与网络. #运行用户user www-data;    #启动进程,通常设置成和cpu的数量相等worker_process ...

  6. Nginx -- nginx.conf 配置文件详讲

    Nginx服务器配置,nginx.conf文件代码详讲,结合不同楼主的博文得到: #关掉访问日志可以优化服务器 #定义Nginx运行的用户和用户组 #user nobody; #nginx进程数 #如 ...

  7. Nginx nginx.conf配置文件详细说明

    在此记录下Nginx服务器nginx.conf的配置文件说明, 部分注释收集与网络. #运行用户user www-data;    #启动进程,通常设置成和cpu的数量相等worker_process ...

  8. Nginx的nginx.conf配置文件中文注释说明

    #运行用户    user www-data;        #启动进程,通常设置成和cpu的数量相等    worker_processes  1;    #全局错误日志及PID文件    erro ...

  9. /etc/nginx/nginx.conf配置文件详解

    user nginx; #数值和cpu核数个数一致worker_processes 8; #worker与cpu绑定 worker_cpu_affinity 0001 0010 0100 1000 1 ...

随机推荐

  1. Swift学习之元组(Tuple)

    定义 元组是由若干个类型的数据组成,组成元组的数据叫做元素,每个元素的类型都可以是任意的. 用法一 let tuples1 = ("Hello", "World" ...

  2. node调用phantomjs-node爬取复杂页面

    什么是phantomjs phantomjs官网是这么说的,'整站测试,屏幕捕获,自动翻页,网络监控',目前比较流行用来爬取复杂的,难以通过api或正则匹配的页面,比如页面是通过异步加载.phanto ...

  3. linux指令大全

    系统信息 arch 显示机器的处理器架构(1) uname -m 显示机器的处理器架构(2) uname -r 显示正在使用的内核版本 dmidecode -q 显示硬件系统部件 - (SMBIOS ...

  4. 头文件string.h里的函数

    .strcpy 函数名: stpcpy 功 能: 拷贝一个字符串到另一个 用 法: char *stpcpy(char *destin, char *source); 程序例: #include &l ...

  5. Git时光机穿梭之删除文件

    在Git中,删除也是一个修改操作,我们实战一下,先添加一个新文件test.txt到Git并且提交: $ git add test.txt $ git commit -m "add test. ...

  6. 阿里消息队列中间件 RocketMQ 源码分析 —— Message 拉取与消费(上)

  7. Trailing Zeroes (III)

    You task is to find minimal natural number N, so that N! contains exactly Q zeroes on the trail in d ...

  8. 【技术干货】听阿里云CDN安防技术专家金九讲tengine+lua开发

    一.介绍 二.安装 三.运行 四.开发 1.介绍 Tengine:轻量级.高性能.高并发.配置化.模块化.可扩展.可移植的Web和反向代理 服务器,Tengine是nginx超集,但做了很多优化,包含 ...

  9. uiautomator +python 实现安卓自动化

    很多人看到这个题目我相信他们可能会说,uiautomator不是java开发的吗?python怎么用呢,其实呢 ,一开始我也是这么想的,看了金阳光老师的视频,也是用java写的,我表示不服,我要科学上 ...

  10. Dom的增删查改以及常用事件

    dom的增删查改 // 查 var _input = document.getElementById('_input'); var _div = document.getElementsByClass ...