Linux Tomcat JDK安装
- 安装jdk
# yum search java | grep -i --color JDK
yum install java-1.7.0-openjdk java-1.7.0-openjdk-devel -
设置环境变量
vi /etc/profile
添加:
JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.71.x86_64
JRE_HOME=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.71.x86_64/jre
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
export JAVA_HOME JRE_HOME PATH CLASSPATH
-
测试 JDK
#vi hello.java
public class hello { public static void main(String args []) { System.out.println("Hello World!"); } }
# javac hello.java
# java hello
-
安装Tomcat
开启防火墙8080端口
# cd /tmp
# wget http://www.us.apache.org/dist/tomcat/tomcat-7/v7.0.56/bin/apache-tomcat-7.0.56.tar.gz
# tar xzf apache-tomcat-7.0.56.tar.gz
# mv apache-tomcat-7.0.56 /usr/local/tomcat7
# cd /usr/local/tomcat7
# ./bin/startup.sh
修改tomcat路径下conf/tomcat-users.xml文件,添加登陆账号
注意文件添加位置
<!-- user manager can access only manager section -->
<role rolename="manager-gui" />
<user username="manager" password="_SECRET_PASSWORD_" roles="manager-gui" />
<!-- user admin can access manager and admin section both -->
<role rolename="admin-gui" />
<user username="admin" password="_SECRET_PASSWORD_" roles="manager-gui,admin-gui" />
会默认安装Apache
Apache默认目录为:/var/www/html
Tomcat程序默认目录为:/usr/local/tomcat7/webapps
-
自动启动tomcat
在/etc/init.d/文件中添加 tomcat文件并添加执行权限。
#!/bin/bash # chkconfig: 234 20 80 # description: Tomcat Server basic start/shutdown script # processname: tomcat JAVA_HOME=/usr/java/jdk1.7.0_60 export JAVA_HOME TOMCAT_HOME=/usr/local/tomcat/bin START_TOMCAT=/usr/local/tomcat/bin/startup.sh STOP_TOMCAT=/usr/local/tomcat/bin/shutdown.sh start() { echo -n "Starting tomcat: " cd $TOMCAT_HOME ${START_TOMCAT} echo "done." } stop() { echo -n "Shutting down tomcat: " cd $TOMCAT_HOME ${STOP_TOMCAT} echo "done." } case "$1" in start) start ;; stop) stop ;; restart) stop sleep 10 start ;; *) echo "Usage: $0 {start|stop|restart}" esac exit 0
chomd +R tomcat
添加开机启动
chkconfig --add tomcat
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。