关闭

nginx多站点配置

219人阅读 评论(0) 收藏 举报

一:nginx.conf 主文件配置(/opt/nginx/conf/nginx.conf)

user  www www;

worker_processes  4;
worker_cpu_affinity 0001 0010 0100 1000;
#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;


pid        logs/nginx.pid;
#google_perftools_profiles /tmp/tcmalloc;
events {
    use epoll;
    worker_connections  65535;
}


http {
    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;


    server_names_hash_bucket_size 128;
    client_header_buffer_size 32k;
    large_client_header_buffers 4 32k;
    client_max_body_size 300m;
    sendfile        on;
    tcp_nopush     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;
    #keepalive_timeout  0;
    keepalive_timeout  60;
    tcp_nodelay on;
    server_tokens off;


    gzip  on;
    gzip_min_length  1k;
    gzip_buffers     4 16k;
    gzip_http_version 1.1;
    gzip_comp_level 2;
    gzip_types       text/plain application/x-javascript text/css application/xml;
    gzip_vary on;


    server
        {
     listen       80;
      server_name _;
     charset utf-8;
     #include  rewrite.conf;
     index index.php index.html index.htm;
     server_name_in_redirect off;
     #root  /var/www/;
     #location ~ .*\.(php|php5)?$
     #                   {
     #                           fastcgi_pass  unix:/tmp/php-cgi.sock;
     #                           fastcgi_index index.php;
     #                           include fcgi.conf;
     #                   }
     #           location /status {
     #                   stub_status on;
     #                   access_log   off;
     #           }
                      
     #           location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
     #                   {
     #                           expires      30d;
     #                   }
     #           location ~ .*\.(js|css)?$
     #                   {
     #                           expires      12h;
     #                   }
                          
     #           access_log off;
      }


include  /usr/local/nginx/conf/vhost/*.conf;

}

二:nginx_site.conf(/opt/nginx/conf/vhost/nginx_site.conf)

server{
listen  80;
server_name  www.88888888.com 88888888.com;
#include  rewrite.conf;
#charset  utf-8; 
root  /var/www/site;
index index.php index.html index.htm;


location ~ .*\.(php|php5)?$ {
fastcgi_pass  unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fcgi.conf;
#root /var/www/site;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index   index.php;
# fastcgi_param   SCRIPT_FILENAME /var/www/site$fastcgi_script_name;
# include      fastcgi_params;
}

location /status {
stub_status  on;
access_log  off;
}


location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
expires  30d;
}


location ~ .*\.(js|css)?$ {
expires  12h;
}


                access_log off;


        location ~ /\.ht {
deny all;
}
}


三:nginx_fly.conf(/opt/nginx/conf/vhost/nginx_fly.conf)


server{
listen  80;
server_name fly.88888888.com;
#include  rewrite.conf;
#charset  utf-8; 
root /var/www/union;
index index.php index.html index.htm;


location ~ .*\.(php|php5)?$ {
fastcgi_pass  unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fcgi.conf;


# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index   index.php;
# fastcgi_param   SCRIPT_FILENAME /var/www/site$fastcgi_script_name;
# include      fastcgi_params;
}

location /status {
stub_status  on;
access_log  off;
}


location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
expires  30d;
}


location ~ .*\.(js|css)?$ {
expires  12h;
}


                access_log off;


        location ~ /\.ht {
deny all;
}
}

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:2031405次
    • 积分:17151
    • 等级:
    • 排名:第591名
    • 原创:188篇
    • 转载:790篇
    • 译文:0篇
    • 评论:156条
    最新评论