linux上配置jdk+Apache

一:安装jdk
下载将jdk加压后放到/usr/local目录下:

 [root@master ~]#chmod 755 jdk-6u5-linux-x64.bin

[root@master ~]# ./jdk-6u5-linux-x64.bin

[root@master ~]#mv jdk1.6.0_05 /usr/local

 

建立/usr/local/下的jdk软连接方便以后版本升级 :

 [root@master ~]# ln -s /usr/local/jdk1.6.0_05/ /usr/local/jdk

 

配置环境变量:

在 /etc/profile 中的文件末尾加入以下内容:

JAVA_HOME=/usr/local/jdk1.6.0_05

JAVA_BIN=/usr/local/jdk1.6.0_05/bin

PATH=$PATH:$JAVA_BIN

CLASSPATH=$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

export JAVA_HOME JAVA_BIN PATH CLASSPATH

保存退出

[root@master ~]source /etc/profile

 

查看java环境变量是否生效

[root@master ~]# java -version

java version "1.6.0_05"

Java(TM) SE Runtime Environment (build 1.6.0_05-b13)

Java HotSpot(TM) 64-Bit Server VM (build 10.0-b19, mixed mode)

测试成功

二:安装tomcat

二.下载安装tomcathttp://tomcat.apache.org/

[root@master ~]# unzip apache-tomcat-6.0.30.zip

[root@master ~]# mv apache-tomcat-6.0.30/ /usr/local/

[root@master ~]cd /usr/local/

[root@master local]# ln -s /usr/local/apache-tomcat-6.0.30/ /usr/local/tomcat

[root@master local]# cd tomcat/bin/

[root@master bin]#ls

[root@master bin]#vim catalina.sh

文件末尾添加以下内容:

CATALINA_HOME=/usr/local/apache-tomcat-6.0.41/

[root@master local]#chmod +x *.sh

三.启动tomcat服务器

[root@master tomcat]# /usr/local/tomcat /bin/catalina.sh start

Using CATALINA_BASE:   /usr/local/apache-tomcat-6.0.30/

Using CATALINA_HOME:   /usr/local/apache-tomcat-6.0.30/

Using CATALINA_TMPDIR: /usr/local/apache-tomcat-6.0.30//temp

Using JRE_HOME:        /usr/local/jdk1.6.0_05

Using CLASSPATH:       /usr/local/apache-tomcat-6.0.30//bin/bootstrap.jar

[root@master logs]# cd /usr/local/tomcat/logs/

[root@master logs]# tail -f catalina.out

Aug 25, 2014 10:50:16 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory host-manager
Aug 25, 2014 10:50:16 AM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
Aug 25, 2014 10:50:16 AM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
Aug 25, 2014 10:50:16 AM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/14  config=null
Aug 25, 2014 10:50:16 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 836 ms

四.在浏览器中输入

http://localhost:8080/(如果不是本机,则输入对应的ip地址)

测试出现tomcat页面则测试成功

参考网站:

http://blog.csdn.net/zhuying_linux/article/details/6583096

 

【附加:
四. 测试jdk
1. 用文本编辑器新建一个Test.java文件,在其中输入以下代码并保存:
public class test {
public static void main(String args[]) {
System.out.println("A new jdk test !");
}
}
2. 编译:在shell终端执行命令 javac Test.java
3. 运行:在shell终端执行命令 java Test
当shell下出现“A new jdk test !”字样则jdk运行正常。

五. 卸载jdk
·找到jdk安装目录的_uninst子目录
·在shell终端执行命令./uninstall.sh即可卸载jdk。】

 

posted @ 2014-08-25 11:01  kin2321  阅读(275)  评论(0编辑  收藏  举报