会动的耳朵  

配置的是CentOS 6.3

改装了下nginx.conf

nginx.conf

 1 user www;
 2 #user  nobody;
 3 worker_processes  1;
 4 
 5 #error_log  /data1/logs/nginx/server_error.log;
 6 #error_log  logs/error.log  notice;
 7 #error_log  logs/error.log  info;
 8 
 9 10 #pid        logs/nginx.pid;
11 
12 
13 events {
14     worker_connections  1024;
15 }
16 
17 
18 http {
19     include       mime.types;
20     default_type  application/octet-stream;
21 
22     #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
23     #                  '$status $body_bytes_sent "$http_referer" '
24     #                  '"$http_user_agent" "$http_x_forwarded_for"';
25 
26     #access_log  logs/access.log  main;
27 
28     sendfile        on;
29     #tcp_nopush     on;
30 
31     #keepalive_timeout  0;
32     keepalive_timeout  65;
33 
34     #gzip  on;
35 
36     include vhosts/*.conf;
37 }

其他的虚拟主机配置在vhosts目录下的conf文件里

举一个例子:

 1 server {
 2     listen       80;
 3     listen       8080;
 4     server_name  domain.cn;
 5     access_log  /data1/logs/nginx/domain.cn.access.log;
 6     location / {
 7         root   /data1/www/domain.cn/webroot;
 8         index  index.php index.html index.htm;
 9         try_files $uri $uri/ /index.php?$args;
10     }
11 
12     error_page   500 502 503 504  /50x.html;
13     location = /50x.html {
14         root   html;
15     }
16 
17     location ~ \.php$ {
18         root   /data1/www/domain.cn/webroot;
19         fastcgi_pass   127.0.0.1:9000;
20         fastcgi_index  index.php;
21         fastcgi_param  SCRIPT_FILENAME          /data1/www/domain.cn/webroot$fastcgi_script_name;
22         include        fastcgi_params;
23         #nginx 设置环境变量,apache好像是SetEnv
24         fastcgi_param SRV_CACHE_DIR      "/data1/logs/cache/domain.cn";  
25         #下面这些代码设置的好处是route,url重写,未求证apache是怎么设置的
26         set $path_info $request_uri;
27 
28         if ($request_uri ~ "^(.*)(\?.*)$") {
29             set $path_info $1;
30         }
31         fastcgi_param PATH_INFO $path_info;
32     }
33 }

 

 

posted on 2013-04-09 14:16  会动的耳朵  阅读(271)  评论(0编辑  收藏  举报