### 全局块开始###

#配置允许运行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. LeetCode题解:(19) Remove Nth Node From End of List

    题目说明 Given a linked list, remove the nth node from the end of list and return its head. For example, ...

  2. java 调用 oracle的function 和 procedure

    1.调用函数 CallableStatement cs=con.prepareCall("{?=call get_pname(?,?,?)}"); 第一个?表示返回的值,后面的?可 ...

  3. Windows 常用快捷方式

    gpedit.msc-----组策略sndrec32-----录音机nslookup----- ip地址侦测器explorer------ 打开资源管理器logoff-------注销命令tsshut ...

  4. Find non-overlap jobs with max cost

    Given a set of n jobs with [start time, end time, cost] find a subset so that no 2 jobs overlap and ...

  5. poj 1966(顶点连通度)

    题意:给出一个n个节点和m条边的图,求该图的顶点连通度. 分析: 顶点连通度的求解可以转换为网络最大流问题. (1)原图G中的每个顶点v变成网络中的两个顶点v‘和v’‘,顶点v’至v''有一个条弧(有 ...

  6. mybatis的mapper参数传递

    简单参数传递 简单参数传递是指: 传递单个基本类型参数,数字类型.String 传递多个基本类型参数 parameterType 属性可以省略: 传递单个基本类型参数  SQL语句中参数的引用名称并不 ...

  7. mock测试SpringMVC controller报错

    使用mock测试Controller时报错如下 java.lang.NoClassDefFoundError: javax/servlet/SessionCookieConfig at org.spr ...

  8. 【题解】HDU4336 Card Collector

    显然,这题有一种很简单的做法即直接状压卡牌的状态并转移期望的次数.但我们现在有一个更加强大的工具——min-max容斥. min-max 容斥(对期望也成立):\(E[max(S)] = \sum_{ ...

  9. 【BZOJ1914】数三角形(组合数,极角排序)

    [BZOJ1914]数三角形(组合数,极角排序) 题面 BZOJ权限题 良心洛谷 题解 这种姿势很吼啊,表示计算几何啥的一窍不通来着. 题目就是这样,正难则反,所以我们不考虑过原点的三角形, 反过来, ...

  10. POJ 3348 Cows | 凸包——童年的回忆(误)

    想当年--还是邱神给我讲的凸包来着-- #include <cstdio> #include <cstring> #include <cmath> #include ...