### 全局块开始###

#配置允许运行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. vsftpd的配置文件说明

    vsftpd的配置文件说明: vsftpd.ftpusers:位于/etc目录下.它指定了哪些用户账户不能访问FTP服务器,例如root等. vsftpd.user_list:位于/etc目录下.该文 ...

  2. [转帖]紧急预警:Globelmposter3.0变种来袭,多行业中招

    紧急预警:Globelmposter3.0变种来袭,多行业中招 https://www.csdn.net/article/a/2018-09-04/15959658   CSDN 转载深信服...   ...

  3. vue使用axios发送数据请求

    本文章是基于vue-cli脚手架下开发 1.安装 npm install axios --s npm install vue-axios --s 2.使用.在index.js中(渲染App组件的那个j ...

  4. 用SQL查询方式显示GROUP BY中的TOP解决方法[转]

    用SQL查询方式显示GROUP BY中的TOP怎样用一个SQL语句来显示 分组后每个组的前几位 比如把一个学校所有学生的成绩按班级分组,再显示每个班级前五名的信息. 班级     学生   成绩 一班 ...

  5. iOS 字符串NSString 的一些常用方法

    一.字符串创建 1. NSString *str1 = [NSString new]; 2. NSString *str2 = @"字符串内容"; 二.字符串拼接 1. NSStr ...

  6. 03.基于IDEA+Spring+Maven搭建测试项目--常用dependency

    <!--常用的依赖配置--> <!--未展示完整的pom.xml文件内容--> <properties> <java.version>1.8</j ...

  7. BZOJ5092 分割序列(贪心)

    设si为该序列的异或前缀和,则显然相当于求Σmax{sj+sj^si} (i=1~n,j=0~i).从高位到低位考虑,如果该位si为1,无论sj怎么填都是一样的:如果该位si为0,则sj该位应尽量为1 ...

  8. 015 反射中的 Class.forName() 与 ClassLoader.loadClass() 的区别

    作者:nnngu GitHub:https://github.com/nnngu 博客园:http://www.cnblogs.com/nnngu 简书:https://www.jianshu.com ...

  9. WampServer3.0允许局域网访问配置教程

    wamp server 下的Apache默认设置是不允许外网访问和局域网访问的,而直接搜索 wamp局域网访问配置,出现都是一些旧版本的wamp的配置信息,最新版本3.0.X需要使用以下配置方法: 配 ...

  10. MT【161】韦恩图

    (清华2017.4.29标准学术能力测试25) 若$N$的三个子集$A,B,C$满足$|A\cap B|=|B\cap C|=|C\cap A|=1$,且$A\cap B\cap C=\varnoth ...