Jdk安装:
官网下载:
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
[root@localhost media]# tar zxvf jdk1.7.0_25.tar.gz #解压
[root@localhost media]# mv jdk1.7.0_25 /usr/local/#复制到/usr/local下
[root@localhost media]# vi ~/.bashrc #最末行添加以下五行 #添加java环境变量
export JAVA_HOME=/usr/local/jdk1.7.0_25/ #安装目录
export JAVA_BIN=$JAVA_HOME/bin
export JAVA_LIB=$JAVA_HOME/lib
export CLASSPATH=.:$JAVA_LIB/tools.jar:$JAVA_LIB/dt.jar
export PATH=$JAVA_BIN:$PATH
[root@localhost media]# source ~/.bashrc #使环境变量生效
[root@localhost media]# java -version #出现以下内容代表成功
java version "1.7.0_25"
Java(TM) SE Runtime Environment (build 1.7.0_25-b15)
Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode
安装tomcat:
官网下载:https://tomcat.apache.org/
[root@localhost media]# tar zxvf apache-tomcat-7.0.52.tar.gz
[root@localhost media]# cp -r apache-tomcat-7.0.52 /usr/local/ #复制到/usr/local下
[root@localhost ~]# /usr/local/apache-tomcat-7.0.52/bin/startup.sh #启动tomcat
[root@localhost ~]# /usr/local/apache-tomcat-7.0.52/bin/shutdown.sh #关闭tomcat
[root@localhost ~]# netstat -antup | grep 8080 #查看是否启动成功
tcp 0 0 :::8080 :::* LISTEN 8694/java
[root@localhost ~]# vi /etc/rc.d/rc.local #添加开机启动(生产环境不建议用root启tomcat)
export JAVA_HOME=/usr/local/jdk1.7.0_25/
/usr/local/apache-tomcat-7.0.52/bin/startup.sh start
root@localhost ~]# ls /usr/local/apache-tomcat-7.0.52/conf/server.xml
/usr/local/apache-tomcat-7.0.52/conf/server.xml #tomcat主配置文件
[root@localhost ~]# ls /usr/local/apache-tomcat-7.0.52/logs/catalina.out
/usr/local/apache-tomcat-7.0.52/logs/catalina.out #tomcat日志文件
[root@localhost ~]# ls /usr/local/apache-tomcat-7.0.52/webapps/
docs examples host-manager manager ROOT #tomcat部署项目文件夹
[root@localhost ~]# ls /usr/local/apache-tomcat-7.0.52/conf/tomcat-users.xml
/usr/local/apache-tomcat-7.0.52/conf/tomcat-users.xml # 后台tomcat用户及密码
Ps:
用普通用户启tomcat:
[root@localhost ~]#vi /bin/starttomcat.sh #创建一个启动脚本
#!/bin/bash
su - tmadmin -c "cd /usr/local/tomcat/bin/;./startup.sh"
1.[root@localhost]# vi /etc/rc.local[root@UAT-cfs-api-task ~]# vi /etc/rc.local #放入自启动文件
/bin/starttomcat.sh &>/var/log/starttm.log
本文出自 “Dream chaser” 博客,请务必保留此出处http://dreamchaser.blog.51cto.com/7756851/1773011
原文地址:http://dreamchaser.blog.51cto.com/7756851/1773011