nginx + tomcat初步学习,安装配置

来源:互联网 发布:蛇精脸拍照软件 编辑:程序博客网 时间:2024/05/20 19:18

1、http://nginx.org/ 下载nginx源码包

2、wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.10.tar.gz 下载PCRE 到/opt下

     因为在编译nginx时需要PCRE环境

     tar xzvf pcre-8.10.tar.gz   解压后的路径为/opt/pcre-8.10

3、开始编译安装nginx

     cd nginx-0.8.54

     ./configure --with-pcre=/opt/pcre-8.10

     make

     make install

4、默认安装的路径为/usr/local/nginx

5、最简单配置

     在/usr/local/nginx/conf/nginx.conf 文件中加入

 

include    /usr/local/nginx/conf/proxy.conf;


然后在 /usr/local/nginx/conf/ 目录中建立文件 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;



6、在 nginx.conf 中描述哪些 url 是由 nginx 来处理,哪些由 nginx转发给tomcat进行处理

     location / {


            root   html;
            index  index.html index.htm;
        }


       location ~*.(jsp|action)$ {
            proxy_pass   http://127.0.0.1:8080;
        }

 7、启动nginx

    cd /usr/local/nginx/sbin

    ./nginx

    用ip地址访问80端口有以下提示,表示配置成功

 

Welcome to nginx!

 

参考:http://www.iteye.com/topic/965884

        http://sudone.com/nginx/nginx_new_install.html

        http://nginx.org/


原创粉丝点击