实验环境: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 ,设定环境变量后出现这个错误:
[[email protected] lib]# javac Error occurred during initialization of VM java/lang/NoClassDefFoundError: java/lang/Object [[email protected] lib]# java Error occurred during initialization of VM java/lang/NoClassDefFoundError: java/lang/Object
解决办法:
[[email protected] lib]# unpack200 tools.pack tools.jar [[email protected] lib]# unpack200 rt.pack rt.jar [[email protected] ~]# 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接口下 }
时间: 2024-10-05 04:27:35