上传软件包
JDK
powershell
#man bash
#PATH 存放命令的路径
## ls
#加入环境变量,注意:'EOF'的单引号的意思就是追加到文件中的内容带有变量的不做解析,否则会被解析
cat >>/etc/profile <<'EOF'
export JAVA_HOME=/application/jdk
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$JAVA_HOME/lib/tools.jar
EOF
#环境变量生效
. /etc/profile
[root@web01 ~]# mkdir -p /application
[root@web01 ~]# cd /application/
[root@web01 /application]# tar xf jdk-8u60-linux-x64.tar.gz -C /application/
[root@web01 /application]# ln -s /application/jdk1.8.0_60/ /application/jdk
[root@web01 /application]# cat >>/etc/profile <<'EOF'
> export JAVA_HOME=/application/jdk
> export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
> export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$JAVA_HOME/lib/tools.jar
> EOF
[root@web01 /application]# . /etc/profile
[root@web01 /application]# java -version
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)
配置jdk完成
tomcat
powershell
[root@web01 /application]# tar xf apache-tomcat-8.0.27.tar.gz
[root@web01 /application]# ln -s /application/apache-tomcat-8.0.27 /application/tomcat
#检车jdk和tomcat是否ok,只使用一次
[root@web01 /application]# /application/tomcat/bin/version.sh
Using CATALINA_BASE: /application/tomcat
Using CATALINA_HOME: /application/tomcat
Using CATALINA_TMPDIR: /application/tomcat/temp
Using JRE_HOME: /application/jdk
Using CLASSPATH: /application/tomcat/bin/bootstrap.jar:/application/tomcat/bin/tomcat-juli.jar
Server version: Apache Tomcat/8.0.27
Server built: Sep 28 2015 08:17:25 UTC
Server number: 8.0.27.0
OS Name: Linux
OS Version: 3.10.0-957.el7.x86_64
Architecture: amd64
JVM Version: 1.8.0_60-b27
JVM Vendor: Oracle Corporation
启动与管理
- startup.sh 启动
- shutdown.sh 关闭
- catelina.sh 核心脚本
powershell
PRG="$0" #表示脚本名称
PRGDIR=`dirname "$PRG"` #dirname 路径
#[root@web01 ~]# dirname /etc/sysconfig/iptables-config
#/etc/sysconfig
#[root@web01 ~]# basename /etc/sysconfig/iptables-config
#iptables-config
# E
XECUTABLE=catalina.sh
exec "$PRGDIR"/"$EXECUTABLE" start "$@"
#$@表示脚本的所有
#/application/tomcat/bin/catalina.sh start
启动tomcat
powershell
[root@web01 /application/tomcat/bin]# /application/tomcat/bin/startup.sh
Using CATALINA_BASE: /application/tomcat
Using CATALINA_HOME: /application/tomcat
Using CATALINA_TMPDIR: /application/tomcat/temp
Using JRE_HOME: /application/jdk
Using CLASSPATH: /application/tomcat/bin/bootstrap.jar:/application/tomcat/bin/tomcat-juli.jar
Tomcat started.
[root@web01 /application/tomcat/bin]# ss -lntup|grep java
tcp LISTEN 0 100 :::8009 :::* users:(("java",pid=10487,fd=51))
tcp LISTEN 0 100 :::8080 :::* users:(("java",pid=10487,fd=46))
tcp LISTEN 0 1 ::ffff:127.0.0.1:8005 :::* users:(("java",pid=10487,fd=68))
[root@web01 /application/tomcat/bin]# ps -ef |grep java
root 10487 1 15 13:29 pts/1 00:00:02 /application/jdk/bin/java -Djava.util.logging.config.file=/application/tomcat/conf/logging.properties -Djava.util.logging
.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/application/tomcat/endorsed -classpath /application/tomcat/bin/bootstrap.jar:/application/tomcat/bin/tomcat-juli.jar -Dcatalina.base=/application/tomcat -Dcatalina.home=/application/tomcat -Djava.io.tmpdir=/application/tomcat/temp org.apache.catalina.startup.Bootstrap startroot 10532 9528 0 13:29 pts/1 00:00:00 grep --color=auto java
#进程内容
/application/jdk/bin/java
#日志配置文件
-Djava.util.logging.config.file=/application/tomcat/conf/logging.properties
#管理配置文件
-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
-Djava.endorsed.dirs=/application/tomcat/endorsed
-classpath /application/tomcat/bin/bootstrap.jar:/application/tomcat/bin/tomcat-juli.jar
#tomcat的路径,不同的tomcat就不同的路径
-Dcatalina.base=/application/tomcat
-Dcatalina.home=/application/tomcat
-Djava.io.tmpdir=/application/tomcat/temp org.apache.catalina.startup.Bootstrap start