您的位置:首页 > 运维架构 > Apache

CentOS 5.3上安装Apache+php+Mysql+phpMyAdmin

2011-11-25 17:22 537 查看
实验了一下nginx+tomcat去实现动静处理分离,对于使用rest风格的springmvc ,struts2等项目也适用,关键点就是静态资源交给nginx直接返回,所有静态以外的都交给tomcat处理,配置参数如下:

worker_processes  1;

events {
    worker_connections  1024;
}

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;

    sendfile        on;
    keepalive_timeout  65;
    gzip  on;

    server {
        listen       80;
        server_name  localhost;

        charset utf-8;

        #access_log  logs/host.access.log  main;

        root  E:\apache-tomcat-7.0.23\webapps\ROOT;

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

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

      location ~^/WEB-INF/* {#禁止访问被保护的目录 
           deny all; 
       }

     location /
      {
        proxy_pass http://localhost:8080;
     proxy_set_header        X-Real-IP $remote_addr;    
          proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for; 
          proxy_set_header        Host $http_host;          
      }

    }

 

}

 

把自己的java web项目放到tomcat的webapps\ROOT目录当中就可以了。

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: