Nginx+tomcat整合安装配置

2017-02-04 16:48:58 5711

Nginx+tomcat整合安装配置

安装JRE

到http://www.landui.com下载JRE软件。

wget http://www.landui.com/otn-pub/java/jdk/7u2-b13/jre-7u2-linux-i586.tar.gz
tar xzf jre-7u2-linux-i586.tar.gz
mv jre1.7.0_02/ /usr/local/jre

tomcat安装

到http://www.landui.com/下载tomcat

wget http://www.landui.com/apache-mirror/tomcat/tomcat-7/v7.0.23/bin/apache-tomcat-7.0.23.tar.gz
tar xzf apache-tomcat-7.0.23.tar.gz
mv apache-tomcat-7.0.23 /usr/local/tomcat

设置环境变量

vi /etc/profile

在文件末尾增加:

export JRE_HOME=/usr/local/jre

执行source命令使生效

source /etc/profile

tomcat根目录设置

1.打开tomcat安装目录下面conf目录下的server.xml文件。

2.找到如下文字:

<Host name="localhost" appBase="webapps"
       unpackWARs="true" autoDeploy="true">

3.在上面找到的文字后面添加如下内容

<Context path="" docBase="/usr/local/nginx/html" debug="0" reloadable="true" />

/usr/local/nginx/html即为根目录地址。


安装nginx

yum install pcre-devel zlib-devel
cd /tmp
wget http://www.landui.com/download/nginx-1.0.14.tar.gz
tar xzf nginx-1.0.14.tar.gz
cd nginx-1.0.14
./configure --prefix=/usr/local/nginx
make && make install

在nginx.conf中的server区块中加入:

location ~ .(jsp|jspx|do){
            proxy_set_header Host $host;
            proxy_set_header X-Forwarded-For $remote_addr;
            proxy_pass http://www.landui.com:8080;
        }

程序启动

/usr/local/nginx/sbin/nginx
/usr/local/tomcat/bin/startup.sh

提交成功!非常感谢您的反馈,我们会继续努力做到更好!

这条文档是否有帮助解决问题?

非常抱歉未能帮助到您。为了给您提供更好的服务,我们很需要您进一步的反馈信息:

在文档使用中是否遇到以下问题: