linux 源码安装jdk tomcat

时间:2022-02-06 08:36:31

系统环境 centos 5.8

下载jdk

1.7版本下载地址
http://www.oracle.com/technetwork/cn/java/javase/downloads/jdk7-downloads-1880260.html
1.8版本下载地址
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
其它版本选择下载
http://www.oracle.com/technetwork/java/javase/archive-139210.html


jdk下载需要接受许可协议,wget下载时需要添加参数
>wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/7u79-b15/jdk-7u79-linux-x64.tar.gz
>tar -xzf  jdk-7u79-linux-x64.tar.gz
>mv jdk1.7.0_79 /usr/local/jdk17
配置环境变量
echo 'export JAVA_HOME=/usr/local/jdk17'  >> /etc/profile
echo 'export PATH=$JAVA_HOME/bin:$PATH'  >> /etc/profile
echo 'export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar'  >> /etc/profile
使配置生效
>source /etc/profile
查看配置是否正确
>java -version
正确打印java版本信息


tomcat安装:
下载tomcat(7)
>wget http://mirrors.hust.edu.cn/apache/tomcat/tomcat-7/v7.0.65/bin/apache-tomcat-7.0.65.zip
解压
>unzip apache-tomcat-7.0.65.zip
>mv apache-tomcat-7.0.65 /usr/local/tomcat7
>cd /usr/local/tomcat7/bin
给tomcat的bin目录下的.sh文件增加执行权限
>chmod 755 *.sh
启动
>./startup.sh 
Using CATALINA_BASE:   /usr/local/tomcat7
Using CATALINA_HOME:   /usr/local/tomcat7
Using CATALINA_TMPDIR: /usr/local/tomcat7/temp
Using JRE_HOME:        /usr/local/jdk17
Using CLASSPATH:       /usr/local/tomcat7/bin/bootstrap.jar:/usr/local/tomcat7/bin/tomcat-juli.jar
Tomcat started.
访问测试
>curl localhost:8080