JSP环境搭建第一步、安装JDK
1)、从官网下载安装程序:http://java.sun.com/javase/downloads/index.jsp只要下载其中之一安装就可以了
2)、安装JDK包
- [root@linuxas src]cd /usr/local/src
- [root@linuxas src]# chmod u+x jdk-6u14-linux-i586.bin
- [root@linuxas src]#./jdk-6u14-linux-i586.bin
输入yes ,等待安装完成
- [root@linuxas src]# rm -f jdk-6u14-linux-i586.bin
- [root@linuxas src]# ls
- apache-tomcat-6.0.20.tar.gz jdk1.6.0_14
- [root@linuxas src]# pwd
- /usr/local/src
- [root@linuxas src]# cd jdk1.6.0_14/
- [root@linuxas jdk1.6.0_14]# ls
- bin jre README_ja.html sample
- COPYRIGHT lib README_zh_CN.html src.zip
- db LICENSE register.html THIRDPARTYLICENSEREADME.txt
- demo man register_ja.html
- include README.html register_zh_CN.html
- [root@linuxas jdk1.6.0_14]# pwd
- /usr/local/src/jdk1.6.0_14
3)设置环境变量
- [root@linuxas lib]# vi /etc/profile
添加以下内容
- export JAVA_HOME=/usr/local/src/jdk1.6.0_14
- export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin: $PATH
- exportCLASSPATH=.:/usr/local/src/jdk1.6.0_14/lib:/usr/local/src/jdk1.6.0_14/jre/lib:$CLASSPATH
4)、验证JAVA安装结果
- [root@linuxas ~]# source /etc/profile
- [root@linuxas ~]# java -version
- java version "1.6.0_14"
- Java(TM) SE Runtime Environment (build 1.6.0_14-b08)
- Java HotSpot(TM) Client VM (build 14.0-b16, mixed mode, sharing)
JSP环境搭建第二步、安装tomcat
1)、从官网下载安装程序http://tomcat.apache.org/download-60.cgi,选择.tar.gz安装包下载。
2)、安装tomcat
- [root@linuxas ~]#cd /usr/local/src
- [root@linuxas src]# tar -zxvf apache-tomcat-6.0.20.tar.gz
- [root@linuxas src]# ls
- apache-tomcat-6.0.20 apache-tomcat-6.0.20.tar.gz jdk1.6.0_14
- [root@linuxas src]# mv apache-tomcat-6.0.20 /
- [root@linuxas src]# cd /
- [root@linuxas /]# mv apache-tomcat-6.0.20 tomcat
- [root@linuxas /]# ls
- bin dev home lost+found misc net proc sbin srv tmp usr
- boot etc lib media mnt opt root selinux sys tomcat var
3)、设置环境变量
- [root@linuxas tomcat]# vi /etc/profile
加入以下语句:
- export CATALINA_BASE=/tomcat
- export CATALINA_HOME=/tomcat
同时更改以下设置:
- export PATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/jre/bin
增加后成为
- export PATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$CATALINA_HOME=/tomcat/bin
- [root@linuxas tomcat]# source /etc/profile
4)、启动服务
- [root@linuxas bin]# ./startup.sh
- Using CATALINA_BASE: /tomcat
- Using CATALINA_HOME: /tomcat
- Using CATALINA_TMPDIR: /tomcat/temp
- Using JRE_HOME: /usr/local/src/jdk1.6.0_14
- [root@linuxas bin]# ps aux | grep tomcat
- root 3468 7.6 10.4 219008 26772 pts/1 Sl 05:57 0:05 /usr/local/src/jdk1.6.0_14/bin/java -Djava.util.logging.config.file=/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/tomcat/endorsed -classpath :/tomcat/bin/bootstrap.jar -Dcatalina.base=/tomcat -Dcatalina.home=/tomcat -Djava.io.tmpdir=/tomcat/temp org.apache.catalina.startup.Bootstrap start
- root 3493 0.0 0.2 5152 696 pts/1 R+ 05:58 0:00 grep tomcat
5)、修改tomcat的基本配置
- [root@linuxas tomcat]# cd conf
- [root@linuxas conf]# vi server.xml
找到
- < Connector port="8080" protocol="HTTP/1.1"
- connectionTimeout="20000"
- redirectPort="8443" />
将端口改为80,增加以下语句URIEncoding="utf-8" useBodyEncodingForURI="true"以支持中文显示
6)、设置 tomcat 为默认启动
- [root@linuxas ~]# vi /etc/rc.d/rc.local
增加以下内容
- export JAVA_HOME=/usr/local/src/jdk1.6.0_14
- /tomcat/bin/startup.sh
修改iptables的设置后,检查效果如下:
- # useradd tomcat
- # chown -R tomcat:tomcat /tomcat
- #vi /etc/rc.local
修改
- /tomcat/bin/startup.sh
为
- su - tomcat -c '/tomcat/bin/startup.sh'
本文出自 “键盘系人生” 博客。