全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

CeraNetworks网络延迟测速工具IP归属甄别会员请立即修改密码
查看: 6109|回复: 11

[nginx] nginx多站点设置..求实例

[复制链接]
发表于 2010-3-6 17:09:23 | 显示全部楼层 |阅读模式
要多增加几个,qoocn的方法只能增加两个……不知道增加第三个怎么搞
发表于 2010-3-6 17:19:40 | 显示全部楼层
多一个站点多加一个server配置就可以了
    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}
发表于 2010-3-6 17:48:33 | 显示全部楼层

回复 2# 的帖子

发表于 2010-3-6 18:12:32 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
发表于 2010-3-6 18:14:40 | 显示全部楼层
复制server段粘贴就是
 楼主| 发表于 2010-3-6 18:16:48 | 显示全部楼层
复制了,不行呀,所以才上来问问
 楼主| 发表于 2010-3-6 18:19:45 | 显示全部楼层
user  www www;
worker_processes 1;
error_log  /home/www/logs/nginx_error.log  crit;
pid        /usr/local/nginx/logs/nginx.pid;
#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 51200;
events
{
  use epoll;
  worker_connections 51200;
}
http
{
  include       mime.types;
  default_type  application/octet-stream;
  #charse  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;
  server_name www.yangtai.org;
  index index.html index.htm index.php;
  root  /home/www/www/;
  #limit_conn   crawler  20;
  #location /status {
  #stub_status on;
  #access_log 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      12h;
   }
  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  /home/www/logs/access.log  access;
}
server
{
  listen  80;
  server_name  status.lnmp.org;
  location / {
   stub_status on;
   access_log   off;
            
            }
  }
server

{

  listen       80;

  server_name  www.baidu.com;

  index index.html index.htm index.php;

  root  /home/www/;

  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      12h;

   }

  access_log   off;

}
}

server

{

  listen       80;

  server_name  www.baidu2.com;

  index index.html index.htm index.php;

  root  /home/www/;

  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      12h;

   }

  access_log   off;

}
}
 楼主| 发表于 2010-3-6 18:20:19 | 显示全部楼层
不知道这样有没有什么错误的
发表于 2010-3-6 18:49:56 | 显示全部楼层

回复 8# 的帖子

nginx -t 测试下是否有报错。
 楼主| 发表于 2010-3-6 18:57:47 | 显示全部楼层
改成上面的NGINX就没有启动……
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2024-5-7 01:10 , Processed in 0.062641 second(s), 8 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表