码迷,mamicode.com
首页 > 其他好文 > 详细

nginx配置

时间:2015-06-30 20:26:25      阅读:139      评论:0      收藏:0      [点我收藏+]

标签:

 1 #
 2 # The default server
 3 #
 4 server {
 5     listen 80;
 6     server_name localhost;
 7     location / {
 8         root /usr/local/nginx/html;
 9         index index.php index.html index.htm;
10         if (!-e $request_filename) {
11         rewrite ^(.*)$ /index.php?s=$1 last;
12         break;
13         }
14 
15         #if (-f $request_filename/index.php){
16         #        rewrite (.*) $1/index.php;
17         #}
18         #if (!-f $request_filename){
19         #        rewrite (.*) /index.php;
20         #}
21     }
22     error_page 404 /404.html;
23     location = /404.html {
24         root /usr/local/nginx/html;
25     }
26     limit_rate_after 5m;
27     limit_rate 512k;
28     location ~ \.mp4$ {
29         mp4;
30         mp4_buffer_size 5m;
31         mp4_max_buffer_size 20m;
32     }
33     location = /50x.html {
34         root /usr/local/nginx/html;
35     }
36 
37     location ~  ^/files/.*\.(php|php5)$ {
38         deny all;
39     }
40 
41     location ~* \.(jpg|jpeg|gif|png|ico|swf)$ {
42         expires 10y;
43         access_log off;
44         gzip off;
45     }
46 
47     location ~* \.(css|js)$ {
48         expires 10y;
49         access_log off;
50     }
51 
52     location ~ \.php$ {
53         fastcgi_pass 127.0.0.1:9000;
54         fastcgi_split_path_info ^(.+\.php)(/.*)$;
55         include fastcgi_params;
56         fastcgi_param  SCRIPT_FILENAME                   $document_root$fastcgi_script_name;
57         fastcgi_param  HTTPS              off;
58         fastcgi_buffer_size 128k;
59         fastcgi_buffers 8 128k;
60     }
61 
62 
63 }

去掉了index.php,rewrite规则在第10行,如果多个php共存的话,改一下每个php的php-fpm.conf配置,将商品设置不同,再在这里面的fastcgi_pass里更改下需要运行的服务器及端口号。

nginx1.9.2的配置文件,安装目录在/usr/local/nginx.默认是在/usr/local/nginx/conf.d/default.conf里,不要修改/usr/local/nginx/nginx.conf.default

nginx配置

标签:

原文地址:http://www.cnblogs.com/xuxiang/p/4611383.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!