nginx config的多个config配置
在我们的一台服务器上,一个nginx服务器下面可能跑着许多许多的项目;
那么就需要配置多个对应的配置 端口号 已经文件入库目录等等
那么项目多了以后,把这些项目都写到一个文件里 到后期难以查看与管理
我们只需要新建一个文件夹,下面全部存放 我们的子配置 然后在主配置中把这个子目录引入即可

然后我们的主配置文件如下
user www www;
worker_processes 8; error_log /www/logs/error.log info;
#access_log /www/logs/nginx.access.log main;
pid /var/run/nginx.pid; worker_rlimit_nofile 51200; events {
use epoll;
worker_connections 51200;
} http {
include /etc/nginx/mime.types;
default_type application/octet-stream; log_format main '"$time_local","$remote_addr","$http_x_forwarded_for","$http_host","$request","refer:$http_referer","$http_user_agent","$status","$request_time","$upstream_response_time","$body_bytes_sent","$upstream_addr","$upstream_status","$upstream_response_time","$http_cookie_pgv_pvi","$request_body","$uid_got"'; server_names_hash_bucket_size 128;
client_header_buffer_size 128k;
large_client_header_buffers 4 128k;
client_max_body_size 100m;
client_body_buffer_size 1024k; sendfile on;
tcp_nopush on; keepalive_timeout 30;
tcp_nodelay on; fastcgi_intercept_errors on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 128k;
user www www;
worker_processes 8; error_log /www/logs/error.log info;
#access_log /www/logs/nginx.access.log main;
pid /var/run/nginx.pid; worker_rlimit_nofile 51200; events {
use epoll;
worker_connections 51200;
} http {
include /etc/nginx/mime.types;
default_type application/octet-stream; log_format main '"$time_local","$remote_addr","$http_x_forwarded_for","$http_host","$request","refer:$http_referer","$http_user_ag
ent","$status","$request_time","$upstream_response_time","$body_bytes_sent","$upstream_addr","$upstream_status","$upstream_response
_time","$http_cookie_pgv_pvi","$request_body","$uid_got"'; server_names_hash_bucket_size 128;
client_header_buffer_size 128k;
large_client_header_buffers 4 128k;
client_max_body_size 100m;
client_body_buffer_size 1024k; sendfile on;
tcp_nopush on; keepalive_timeout 30;
tcp_nodelay on; fastcgi_intercept_errors on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 128k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k; gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml image/jpeg image/gif image/png;
gzip_vary on; #server {
# listen 80;
# server_name localhost;
# location / {
# proxy_next_upstream http_502 http_504 http_404 error timeout invalid_header;
# proxy_pass http://78list.cn;
#proxy_set_header Host www.yourdomain.com;
# proxy_set_header X-Forwarded-For $remote_addr;
# } #}
#upstream 78list.cn {
# server 192.168.8.113:8080;
#} include /etc/nginx/default.conf;
include /etc/nginx/upstream/*.conf;
include /etc/nginx/conf.d/*.conf; // 这里就是引入的子配置文件夹
}
一个范例 子配置的conf
server
{
listen 832; // 端口号
server_name localhost; // 域名
index index.html index.htm index.php;
root /home/www/ai/crm/web/public; //项目的入口文件夹 location ~ /.svn/ {
deny all;
} location / {
rewrite ^/$ /index.php last;
rewrite ^/(?!index\.php|index\.html|layui|css|js|bootstrap|robots\.txt)(.*)$ /index.php/$1 last;
} location ~ \.php {
fastcgi_pass 127.0.0.1:9002;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
} location ~/uploads/.*\.(php|php5)?$ {
deny all;
}
location ~/public/.*\.(php|php5)?$ {
deny all;
} location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
} location ~ .*\.(js|css)?$
{
expires 8d;
} #access_log /www/logs/access.log main; }
nginx config的多个config配置的更多相关文章
- 9.Spring Cloud Config统一管理微服务配置
Spring Cloud Config统一管理微服务配置 9.1. 为什么要统一管理微服务配置 9.2. Spring Cloud Config简介 Spring Cloud Config为分布式系统 ...
- C#微信开发-微信JS-SDK(1)之通过config接口注入权限验证配置
官方文档是微信JS-SDK的使用步骤http://mp.weixin.qq.com/wiki/7/aaa137b55fb2e0456bf8dd9148dd613f.html#JSSDK.E4.BD.B ...
- web.config中sessionState节点的配置方案
web.config中sessionState节点的配置方案 web.config关于sessionState节点的配置方案,sessionState有五种模式:Custom,off,inProc,S ...
- 程序集、应用程序配置及App.config和YourSoft.exe.config .
转自:http://www.cnblogs.com/luminji/archive/2010/10/21/1857339.html 什么是程序集 程序集标识属性 强名称的程序集 强名称工作原理 配置文 ...
- 使用配置文件(.settings、.config)存储应用程序配置
原文:使用配置文件(.settings..config)存储应用程序配置 引言 我不知大家早先是如何保存应用程序配置,以备下次打开时使用的,反正我开始学.Net的时候就去研究序列化,以二进制或XML格 ...
- 在web.Config文件中添加数据库连接配置
新建一个网站,打开web.config文件,在connectionString配置节点添加add节点进行数据库进行数据库连接配置代码如下: <connectionStrings> < ...
- 结合jquery的前后端加密解密 适用于WebApi的SQL注入过滤器 Web.config中customErrors异常信息配置 ife2018 零基础学院 day 4 ife2018 零基础学院 day 3 ife 零基础学院 day 2 ife 零基础学院 day 1 - 我为什么想学前端
在一个正常的项目中,登录注册的密码是密文传输到后台服务端的,也就是说,首先前端js对密码做处理,随后再传递到服务端,服务端解密再加密传出到数据库里面.Dotnet已经提供了RSA算法的加解密类库,我们 ...
- Spring Cloud Config 使用Bus的动态配置中心
server端配置 POM文件 <dependency> <groupId>org.springframework.boot</groupId> <artif ...
- C#项目 App.config 配置文件不同使用环境配置
问题 部署项目时,常常需要根据不同的环境使用不同的配置文件.例如,在部署网站时可能希望禁用调试选项,并更改连接字符串以使其指向不同的数据库.在创建 Web 项目时,Visual Studio 自动生成 ...
- Vue、webpack中默认的config.js、index.js 配置详情
在vue.js 框架搭建好后,其vue-cli 自动构建的目录里面相关环境变量及其基本变量配置,如下代码所示: module.exports = { build: { index: path.reso ...
随机推荐
- ThinkPHP3.2添加scws中文分词
前言 前一段时间,公司网站做站内搜索,只简单针对输入的文字进行搜索,作全匹配检索,搜索出来的内容很少.如何达到模糊搜索,匹配到更多的内容成了需要解决的问题.于是,今天想到可以做分词检索,如何对输入的一 ...
- 安装pysqlite2
1. 从https://github.com/msabramo/pysqlite2 下载源码. 2.安装python-dev: sudo apt-get install python-dev 否则在 ...
- LeetCode第[3]题(Java):Longest Substring Without Repeating Characters 标签:Linked List
题目中文:没有重复字符的最长子串 题目难度:Medium 题目内容: Given a string, find the length of the longest substring without ...
- mysql学习笔记(window下简单使用+Navict)
之前安装过mysql.最近刚好要重新翻出来看看 发现又忘记了那些命令.还是要百度.所以不如自己整理下 尽管网上有很多相关的介绍.当时想对的不如自己整理出来的舒服 首先是下载安装.网上有很多就不一一罗列 ...
- StringUtils在commons-lang3和commons-lang中的区别【转】
http://blog.csdn.net/eden_m516/article/details/75042439 最近经常需要对String做一些判断和处理,于是就用到了Apache提供的StringU ...
- C++(十八) — 内存模式、堆和栈
1.内存模式 一个程序执行时,先复制到内存,然后CPU逐句读取指令执行. 每个存储单元存放一个字节(8bit)数据,每个有一个唯一的地址,地址是顺序编码的.比如:一台计算机256MB内存,则有256* ...
- APP耗电量专项测试整理
Android: (使用batterystats) 方法: 手机自带的电量监控.GT 命令(5.0以上系统才可以): 1.下载historian.py脚本,下载地址:https://github.co ...
- git rm -r --cached 去掉已经托管在git上的文件
1.gitignore文件 在git中如果想忽略掉某个文件,不让这个文件提交到版本库中,可以使用修改 .gitignore 文件的方法.这个文件每一行保存了一个匹配的规则例如: # 此为注释 – 将被 ...
- 012-对象——魔术常量__CLASS__ __METHOD__ __FUNCTION__ __DIR__ __FILE__
<?php /** *魔术常量__CLASS__ __METHOD__ __FUNCTION__ __DIR__ __FILE__ */ //魔术常量:__CLASS__ 得到类名. /*cla ...
- MSSQL旋转和反旋转的例子
1.旋转 ;WITH CTE AS ( AS VAL UNION ALL UNION ALL UNION ALL UNION ALL UNION ALL UNION ALL UNION ALL ) S ...