标签:
设置环境变量
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
标签:
原文地址:http://www.cnblogs.com/Mrhuangrui/p/4563420.html