### 全局块开始###

#配置允许运行nginx服务器的用户和用户组
user nobody; #配置允许nginx进程生成的worker process 数
worker_processes 1; #配置nginx服务器运行对错误日志的存放路径
error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info; #配置nginx服务器运行时的pid文件存放路径和名称
pid logs/nginx.pid; ### 全局块结束### ### events块开始### events {
#配置事件驱动模型
use epoll;
#配置最大连接数
worker_connections 1024;
} ### events块结束### ### 全局块结束### ### HTTP块开始###
http {
# 定义MIME-Type ,查看mime.types文件
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方式传输
sendfile on; #tcp_nopush on; #配置连接超时时间
keepalive_timeout 65; #gzip on; ### server块开始###
### 配置虚拟主机myServer1###
server {
# 配置监听端口和主机名称(基于名称)
listen 80;
server_name myServer1; #charset koi8-r; #配置请求处理日志存放路径
access_log logs/host.access.log main; # 配置处理/service1/location1 请求的location
location /service1/location1 {
root /myweb;
index index1.html;
} # 配置处理/service1/location2 请求的location
location /service1/location2 {
root /myweb;
index index2.html;
} # 配置错误页面
error_page 404 /404.html; # redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
### 配置虚拟主机myServer2###
server {
# 配置监听端口和主机名称(基于ip)
listen 8082;
server_name 192.168.1.3; #charset koi8-r; #配置请求处理日志存放路径
access_log logs/host.access.log; # 配置处理/service2/location1 请求的location
location /service2/location1 {
root /myweb;
index index2.html;
} # 对location的uri进行更改
location /svr2/loc2 {
alias /myweb/server2/location2;
index index.svr2-loc2.htm;
} # 错误页面404.html 做了重定向
error_page 404 /404.html; location = /404.html {
root /myweb;
index 404.htm;
}
}
### server块结束### }
### HTTP块结束###

  

nginx.conf 基础配置的更多相关文章

  1. nginx 的基础配置[转]

    nginx 的基础配置 分类: 工具软件2013-11-13 23:26 11人阅读 评论(0) 收藏 举报   目录(?)[-] 管理配置文件 全局配置 虚拟机server配置 location配置 ...

  2. 2.4 Nginx服务器基础配置指令

    2.4.1 nginx.conf文件的结构 2.4.2配置运行Nginx服务器用户(组) 2.4.3配置允许生成的worker process数 2.4.4 配置Nginx进程PID存放路径 2.4. ...

  3. 大神教你Nginx常用基础配置方案

    Nginx的fastcgi模块参数设置 Nginx 有两个配置文件fastcgi_params.fastcgi.conf,两者唯一的区别是,fastcgi.conf 多一个参数 SCRIPT_FILE ...

  4. nginx.conf中配置laravel框架站点

    nginx.conf配置如下: user nginx nginx;worker_processes 4; error_log logs/error.log error; pid logs/nginx. ...

  5. nginx入门篇----nginx服务器基础配置

    1.nginx.conf文件结构...                         #全局块  events{  ...  }  http                      #http块{ ...

  6. Nginx配置文件(nginx.conf)配置详解(2)

    Nginx的配置文件nginx.conf配置详解如下: user nginx nginx ; Nginx用户及组:用户 组.window下不指定 worker_processes 8; 工作进程:数目 ...

  7. Nginx配置文件(nginx.conf)配置详解

    Nginx的配置文件nginx.conf配置详解如下: user nginx nginx ; Nginx用户及组:用户 组.window下不指定 worker_processes 8; 工作进程:数目 ...

  8. Nginx 1.10.1 版本nginx.conf优化配置及详细注释

    Nginx 1.10.1 的nginx.conf文件,是调优后的,可以拿来用,有一些设置无效,我备注上了,不知道是不是版本的问题,回头查一下再更正. #普通配置 #==性能配置 #运行用户 user ...

  9. 虚拟主机ip配置,nginx.conf文件配置及日志文件切割

    今天粗略整理了一下虚拟主机配置,nginx.conf文件的配置,及日志文件的切割,记录如下: nginx虚拟主机配置:1.IP地址配置,2.绑定ip地址和虚拟主机详情:1.ip地址的配置:ifconf ...

随机推荐

  1. sed ,awk , cut三剑客的区别

    sed: sed只能截取文件中以行的来截取数据,,(grep命令可以过滤到某一行) 例如: [root@localhost ~]# sed  -n  '2,3p'  /etc/passwd       ...

  2. 增加kms计数

    @echo offset skms=10.15.68.62for %%i in (. . . . . . . . . . . . . . . . . . . . . . . . . .) do cal ...

  3. .net对Redis集群的调用(FrameWork版本4.0)

    使用 StackExchange.Redis 实现.net对Redis集群的调用,方法如下: 1.打开 项目-管理NuGet程序包 2.在打开界面搜索StackExchange.Redis,找到Sta ...

  4. servletActionContext.getContext默认获取contextmap 数据默认存储在contextmap的request中

  5. Shell脚本创建Nginx的upstream及location配置文件

    #!/bin/sh ##################################################### # Name: create_nginx_conf.sh # Versi ...

  6. Power Strings POJ - 2406(next水的一发 || 后缀数组)

    后缀数组专题的 emm.. 就next 循环节../ 有后缀数组也可以做 从小到大枚举长度i,如果长度i的子串刚好是重复了len/i次,应该满足len % i == 0和rank[0] - rank[ ...

  7. uoj259 & 独立集问题的一些做法

    很早以前就做了一遍这题,当时好像啥都不会,今天重做一下. 这个题题意简单地说就是输入k.p和一个图,求图大小为k的独立集个数mod p. subset1.in  n=24,m=19,k=8 subse ...

  8. attention、self-attention、transformer和bert模型基本原理简述笔记

    attention 以google神经机器翻译(NMT)为例 无attention: encoder-decoder在无attention机制时,由encoder将输入序列转化为最后一层输出state ...

  9. 学习Spring Boot:(四)应用日志

    前言 应用日志是一个系统非常重要的一部分,后来不管是开发还是线上,日志都起到至关重要的作用.这次使用的是 Logback 日志框架. 正文 Spring Boot在所有内部日志中使用Commons L ...

  10. 【bzoj2733】 HNOI2012—永无乡

    http://www.lydsy.com/JudgeOnline/problem.php?id=2733 (题目链接) 题意 给出图上$n$个点,每个点有一个点权,每次询问一个连通块中点权第$K$小的 ...