标签:nginx反向代理tomcat(tomcat的安装方法)
实验环境:CentOS6.5
安装版本:jdk-6u16-dlj-linux-i586.bin、apache-tomcat-6.0.43.tar.gz(注意不是源码包,没有src)
1.安装JDK
chmod +x jdk-6u16-dlj-linux-i586.bin ./jdk-6u16-dlj-linux-i586.bin
编辑/etc/profile文件
vim /etc/profile JAVA_HOME="/usr/local/jdk" 安装路径 CLASS_PATH="$JAVE_HOME/lib:$JAVA_HOME/jre/lib" PATH=".:$PATH:$JAVE_HOME/bin" CATALINA_HOME="/usr/local/tomcat" export JAVA_HOME CATALINA_HOME source /etc/profile 使修改立刻生效
安装完JDK ,设定环境变量后出现这个错误:
[root@localhost lib]# javac Error occurred during initialization of VM java/lang/NoClassDefFoundError: java/lang/Object [root@localhost lib]# java Error occurred during initialization of VM java/lang/NoClassDefFoundError: java/lang/Object
解决办法:
[root@localhost lib]# unpack200 tools.pack tools.jar [root@localhost lib]# unpack200 rt.pack rt.jar [root@localhost ~]# java 输入java能出来选项则安装jdk成功
2.安装Tomcat并实现nginx方向代理tomat
tar xf apache-tomcat-6.0.43.tar.gz
mv apache-tomcat-6.0.43 /usr/local/tomcat
/usr/local/tomcat/bin/startup.sh 启动Tomcat 关闭为/usr/local/tomcat/bin/shutdown.sh
修改tomcat配置文件server.xml
vim /usr/local/tomcat/conf/server.xml
找到并修改为 appBase="网站所在路径" 重启tomcat
修改nginx.conf
在server{}内加入如下:
location ~\.(jsp|jspx|do)?$ { proxy_set_header Host $host; proxy_set_header X-Forwarded-For $remote_addr; proxy_pass http://localhost:8080; 默认tomcat监听在8080接口下 }
本文出自 “anka” 博客,请务必保留此出处http://anka0501.blog.51cto.com/10129669/1638651
Nginx之四:Nginx反向代理Tomcat(Tomcat的安装方法)
标签:nginx反向代理tomcat(tomcat的安装方法)
原文地址:http://anka0501.blog.51cto.com/10129669/1638651