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

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

2013-12-27阅读110 评论0

我的生产环境下的nginx.conf配置文件,做了虚拟主机设置的,大家可以根据需求更改,下载即可在自己的机器上使用了,本配置文件摘录自《构建高可用Linux服务器》(机械工业出版社),转载麻烦注明出处,谢谢,配置文件如下:

user  www www;
worker_processes 8;
error_log  /data/logs/nginx_error.log  crit;
pid        /usr/local/webserver/nginx/nginx.pid;
#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 65535;
events
{
  use epoll;
  worker_connections 65535;
}
http
{
  include       mime.types;
  default_type  application/octet-stream;
  #charset  gb2312;
  server_names_hash_bucket_size 128;
  client_header_buffer_size 32k;
  large_client_header_buffers 4 32k;
  client_max_body_size 8m;
  sendfile on;
  tcp_nopush     on;
  keepalive_timeout 60;
  tcp_nodelay on;
  fastcgi_connect_timeout 300;
  fastcgi_send_timeout 300;
  fastcgi_read_timeout 300;
  fastcgi_buffer_size 64k;
  fastcgi_buffers 4 64k;
  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;
  gzip_vary on;
  #limit_zone  crawler  $binary_remote_addr  10m;
  server
  {
    listen 80 default;
    server_name _;
    index index.html index.htm index.php;
    root /data/htdocs/www;
    #server_name_in_redirect off;
    location ~ .*\.(php|php5)?$
    {
      #fastcgi_pass  unix:/tmp/php-cgi.sock;
      fastcgi_pass  127.0.0.1:9000;
      fastcgi_index index.php;
      include fcgi.conf;
    }
    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
    {
      expires      30d;
    }
    location ~ .*\.(js|css)?$
    {
      expires      1h;
    }
    }
  server
  {
    listen       80;
    server_name  www.adongstudio.com;
    index index.html index.htm index.php;
    root  /data/htdocs/www/adongweb;
    #limit_conn   crawler  20;   
    location ~ .*\.(php|php5)?$
    {     
      #fastcgi_pass  unix:/tmp/php-cgi.sock;
      fastcgi_pass  127.0.0.1:9000;
      fastcgi_index index.php;
      include fcgi.conf;
    }
    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
    {
      expires      30d;
    }
    location ~ .*\.(js|css)?$
    {
      expires      1h;
    }   
    log_format  access  ‘$remote_addr - $remote_user [$time_local] "$request" ‘
              ‘$status $body_bytes_sent "$http_referer" ‘
              ‘"$http_user_agent" $http_x_forwarded_for‘;
    access_log  /data/logs/access.log  access;
      }
  server
  {
    listen       80;
    server_name  www.longfeistudio.com;
    index index.html index.htm index.php;
    root  /data/htdocs/www/ImageVue;
    #limit_conn   crawler  20;
    location ~ .*\.(php|php5)?$
    {
      #fastcgi_pass  unix:/tmp/php-cgi.sock;
      fastcgi_pass  127.0.0.1:9000;
      fastcgi_index index.php;
      include fcgi.conf;
    }
    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
    {
      expires      30d;
    }
    location ~ .*\.(js|css)?$
    {
      expires      1h;
    }
    access_log  off;
      }
  server
  {
    listen       80;
    server_name  www.hongyanbike.com;
    index index.html index.htm index.php;
    root  /data/htdocs/www/xhui/hybike;
    location ~ .*\.(php|php5)?$
    {     
      #fastcgi_pass  unix:/tmp/php-cgi.sock;
      fastcgi_pass  127.0.0.1:9000;
      fastcgi_index index.php;
      include fcgi.conf;
    }
    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
    {
      expires      30d;
    }
    location ~ .*\.(js|css)?$
    {
      expires      1h;
    }
    access_log  off;
  }
server
  {
    listen       80;
    server_name  www.very365.com mm.very365.com very365.com;   
    index index.html index.htm index.php;
    root  /data/htdocs/www/very365;  
  location /
  {    
  rewrite ^/(.*)/product/([0-9]+)/$ /seoproduct\.php\?spell=$1&productid=$2;
  rewrite ^/brand/(.*)/page/([0-9]+)/$ /seobrand\.php\?spell=$1&page=$2;
  rewrite ^/brand/(.*)/$ /seobrand\.php\?spell=$1;
    }
    location ~ .*\.(php|php5)?$
    {
      #fastcgi_pass  unix:/tmp/php-cgi.sock;
      fastcgi_pass  127.0.0.1:9000;
      fastcgi_index index.php;
      include fcgi.conf;
      fastcgi_param SCRIPT_FILENAME /data/htdocs/www/very365$fastcgi_script_name;
      fastcgi_param  SCRIPT_NAME  /data/htdocs/www/very365$fastcgi_script_name;
    }
    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
    {
      expires      30d;
    }
    location ~ .*\.(js|css)?$
    {
      expires      1h;
    }
    access_log  off;
  }
server
  {
    listen       80;
    server_name  www.wqueen.cn wqueen.cn;
    index index.html index.htm index.php;
    root  /data/htdocs/www/wqueen/bbs;
    location ~ .*\.(php|php5)?$
    {
      #fastcgi_pass  unix:/tmp/php-cgi.sock;
      fastcgi_pass  127.0.0.1:9000;
      fastcgi_index index.php;
      include fcgi.conf;
    }
    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
    {
      expires      30d;
    }
    location ~ .*\.(js|css)?$
    {
      expires      1h;
    }
    access_log  off;
    }
server
  {
    listen       80;
    server_name  baobei.wqueen.cn;
    index index.html index.htm index.php;
    root  /data/htdocs/www/baobei;
    location ~ .*\.(php|php5)?$
    {
      #fastcgi_pass  unix:/tmp/php-cgi.sock;
      fastcgi_pass  127.0.0.1:9000;
      fastcgi_index index.php;
      include fcgi.conf;
    }
    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
    {
      expires      30d;
    }
    location ~ .*\.(js|css)?$
    {
      expires      1h;
    }
    access_log  off;
    }
}

时间: 2024-08-12 03:22:25

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

生产环境监控系统Nginx+Nagios+Cacti+Nconf大整合(最新源码安装)【转载】

在此部署方案基础上可以加入对网络设备监控的组件NTOP,原Cacti运行环境标配的组件为Apache,另针对windows系统的监控插件为NSClient++ 文章转载自:https://blog.linuxeye.com/314.html 此文是成功在<Nginx下搭建Nagios监控平台>基础上继续,安装整合Cacti.Nconf.其中花了很多时间来排错.1.下载所需要最新稳定源码包 cd nagios-cacti wget http://www.cacti.net/downloads/c

virtualenv 环境下 Django + Nginx + Gunicorn+ Supervisor 搭建 Python Web

在这篇文章里,我们将搭建一个简单的 Web 应用,在虚拟环境中基于 Flask 框架,用 Gunicorn 做 wsgi 容器,用 Supervisor 管理进程,然后使用 OneAPM Python 探针来监测应用性能,形成一个「闭环」 !希望能对大家有所帮助,首先简单来介绍一下环境: 系统环境:ubuntu 14.04 Python 2.7.6 安装组件库 第一步安装所需要的存储库,因为打算用到虚拟环境,用到 pip 安装和管理 Python 组件,所以先更新本地包,然后安装组件: sudo

生产环境下ftp的迁移并构建高可用

说明:这是1个小项目就两台DELL的服务器,和一台IP SAN存储(DELL MD3200i).原来是4台小服务器,而且服务器太老了,经常有问题,这回相当于一次ftp的迁移,以前用的是proftp,这次换成了vsftp.数据量有2.5T. 拓扑很简单: 系统:CENTOS 6.4(64bit) 高可用软件:corosync+pacemaker host:ftp1 192.168.1.190 ftp2  192.168.1.191 stonith(ipmi):ftp1 192.168.1.180

Nginx(三):nginx.conf配置文件说明 【1】 配置参数说明

Nginx配置文件说明,不一定最全,但是最细,适合初学者或者概念不清晰者,如有理解错误的地方请指正. #nginx的worker进程用哪个用户和组进行登录,如果在编译时指定了,这里是禁用的,而且不会显示 #你的设置,为了便于识别,在保持禁用的同时你修改为实际用户和组 #user  nginx nginx; #[和优化有关] #启动几个worker进程,从Nginx1.9.10开始可以使用auto值,进行自动设置 #每个worker进程都是单线程进程,所以你叫它进程或者线程都行.这个值最大设置 #

读生产环境下go语言最佳实践有感

最近看了一篇关于go产品开发最佳实践的文章,go-in-procution.作者总结了他们在用go开发过程中的很多实际经验,我们很多其实也用到了,鉴于此,这里就简单的写写读后感,后续我也争取能将这篇文章翻译出来.后面我用soundcloud来指代原作者. 开发环境 在soundcloud,每个人使用一个独立的GOPATH,并且在GOPATH直接按照go规定的代码路径方式clone代码. $ mkdir -p $GOPATH/src/github.com/soundcloud $ cd $GOPA

生产环境下was不允许重启,怎么办?

前段时间上线,遇到一个jndi的故障问题,怎么个问题呢?就是原在测试环境下没有问题,而在生产环境下无法连接生产数据库,当时找到问题所在,就是ibm工具自动生成一个在测试环境下连接的jndi的资源文件resources.xml,当时删除了,重启了server,无效.后来我考虑到这肯定是was缓存造成,因此想象缓存造成的原因,最后在测试环境下重启了was,问题解决了,但后来说生产环境是不可能重启was的,因此暂时困老了本人,后来所谓的领导说,他去找总架构师看有没有办法解决,可是时间不等人,过了2天依

nginx.conf配置文件分析

#总结一下nginx.conf文件内容. #运行用户 user www-data; #启动进程,通常设置成和cpu的数量相等 worker_processes  1; #全局错误日志 error_log  /var/log/nginx/error.log; #进程文件 pid        /var/run/nginx.pid; #一个nginx进程打开的最多文件描述符数目,理论值应该是最多打开文件数(系统的值ulimit -n)与nginx进程数相除,但是nginx分配请求并不均匀,所以建议与

nginx.conf配置文件解析(http、server、location proxy_pass)

nginx.conf配置文件解析(http.server.location) 标签: nginxnginx-conf 2017-04-26 20:10 1031人阅读 评论(0) 收藏 举报 分类: Nginx(8) 版权声明:本文为博主原创文章,未经博主允许不得转载. nginx.conf文件在安装目录/conf目录下 1.定义Nginx运行的用户和用户组 user nginx nginx; 2.nginx进程数,建议设置为等于CPU总核心数 worker_processes 1; 3.全局错

Java生产环境下性能监控与调优详解

第1章 课程介绍(Java秒杀课程老师倾力打造)本章为大家介绍生产环境可能存在的问题和常用的性能监控工具,以及课程能学到什么,课程内容如何安排等,让大家对课程有个全貌的认识,从而更好的学习这门课程.1-1 为什么学习这门课程? 第2章 基于JDK命令行工具的监控本章带大家学习JDK的命令行监控工具的使用,包括jps.jinfo.jstat.jmap.jstack, 并结合MAT实战如何定位内存溢出,实战如何定位死循环和死锁.2-1 JVM的参数类型2-2 查看JVM运行时参数2-3 jstat查