用nginx+tomcat来代替apache+jk+tomcat

[root@test nginx-0.6.26]# rpm -qa|grep pcre 
pcre-6.6-1.1 
[root@test  suantop]#  rpm  -ivh  pcre-devel-6.6-1.1.i386.rpm   
warning:  pcre-devel-6.6-1.1.i386.rpm:  Header  V3  DSA  signature:  NOKEY,  key  ID  37017186 
Preparing...                                ###########################################  [100%] 
      1:pcre-devel                          ###########################################  [100%] 

[root@test suantop]# rpm -qa|grep pcre 
pcre-6.6-1.1 
pcre-devel-6.6-1.1 

等再次执行./configure 
[root@test nginx-0.6.26]# ./configure --with-http_stub_status_module 
[root@test nginx-0.6.26]# make 
[root@test nginx-0.6.26]# make install 
修改配置文件  /usr/local/nginx/conf/nginx.conf 
给出一些主要更改的地方 
user    nobody  nobody; 
worker_processes    2; 
error_log    logs/error.log    notice; 
pid                logs/nginx.pid; 
events  { 
        worker_connections    1024; 

http  { 
        include              mime.types; 
        default_type    application/octet-stream; 
        include        /usr/local/nginx/conf/proxy.conf; 
#上面这行是增加的 
        server  { 
                listen              81; 
                server_name    localhost;     
                charset  gb2312; 
#  serve  static  files 
                location  ~  ^/(images|pages|javascript|js|css|flash|media|static)/    { 
                                root        /usr/local/www; 
                                expires  30d; 
                location  /  { 
                        root  /usr/local/www;                       
                        index    index.jsp  index.htm; 
                        proxy_pass  [url]http://192.168.1.250:8080; [/url]
                    } 

location  /NginxStatus  { 
                                                stub_status                          on; 
                                                access_log                            on; 
                                                auth_basic                            "NginxStatus"; 
                                } 


说明配置文件中有提到proxy.conf  这个文件可以VI一个如下文件 
[root@test  conf]#  cat  proxy.conf   
#!nginx  (-) 
#  proxy.conf 
proxy_redirect                    off; 
proxy_set_header                Host                        $host; 
proxy_set_header                X-Real-IP              $remote_addr; 
proxy_set_header                X-Forwarded-For  $proxy_add_x_forwarded_for; 
client_max_body_size        10m; 
client_body_buffer_size  128k; 
proxy_connect_timeout      90; 
proxy_send_timeout            90; 
proxy_read_timeout            90; 
proxy_buffers                      32  4k; 
测试配置文件 
[root@test conf]# /usr/local/nginx/sbin/nginx -t 
2008/05/04  15:40:02  [info]  2363#0:  the  configuration  file  /usr/local/nginx/conf/nginx.conf  syntax  is   

ok 
2008/05/04  15:40:02  [info]  2363#0:  the  configuration  file  /usr/local/nginx/conf/nginx.conf  was  tested   

successfully 
启动 
[root@test conf]# /usr/local/nginx/sbin/nginx 
[root@test conf]# ps fax 
9400  ?                Ss          0:00  nginx:  master  process  /usr/local/nginx/sbin/nginx 
  9401  ?                S            0:00    \_  nginx:  worker  process             
  9402  ?                S            0:00    \_  nginx:  worker  process     

你可能感兴趣的:(nginx,职场,休闲)