One: Install JDK
To view system Information:
[Email protected] ~]# uname-alinux node120 3.10.0-327.10.1.el7.x86_64 #1 SMP Tue Feb 17:03:50 UTC x86_64 x86_64 x86_64 Gnu/linux[[email protected] ~]# cat/etc/redhat-release CentOS Linux release 7.2.1511 (Core)
To install the JDK:
[Email protected] ~]# RPM-IVH jdk-8u73-linux-x64.rpm[[email protected] ~]# vim/etc/profileexport java_home=/usr/java/ Jdk1.8.0_73export java_bin=/usr/java/jdk1.8.0_73/binexport path=${java_home}/bin: $PATHexport CLASSPATH=.:${JAVA_ Home}/lib/dt.jar:${java_home}/lib/tools.jar
[[email protected] ~]# source/etc/profile[[email protected] ~]# Java-versionjava version "1.8.0_73" Java (TM) SE Runtime E Nvironment (build 1.8.0_73-b02) Java HotSpot (TM) 64-bit Server VM (build 25.73-b02, Mixed mode)
II: Deploying Tomcat
[Email protected] ~]# wget http://mirrors.cnnic.cn/apache/tomcat/tomcat-8/v8.0.32/bin/apache-tomcat-8.0.32.tar.gz
Unzip rename
[Email protected] ~]# tar-xf apache-tomcat-8.0.32.tar.gz-c/usr/local/[[email protected] ~]# MV/USR/LOCAL/APACHE-TOMC at-8.0.32//usr/local/tomcat
Add a user running Tomcat
[Email protected] ~]# useradd-u 8002-m Tomcat #注意tomcat用户要可以切换
To add a service startup script
#!/bin/bash## chkconfig: - 95 15 # description: tomcat start/stop/ status script#location of java_home (bin files) java_home=/usr/java/jdk1.8.0_73export JAVA_HOME #Add java binary files to pathpath= $JAVA _home/bin: $PATHexport path#catalina_home is the location of the configuration files of this instance of TomcatCATALINA_HOME=/usr/local/tomcat#TOMCAT_USER is the Default user of tomcattomcat_user=tomcat#tomcat_usage is the message if this script is called without any optionstomcat_usage= "Usage: $0 {\e[00;32mstart\e[00m|\e[00;31mstop\e[00m|\e[00;32mstatus\e[00m|\e[00;31mrestart\e[00m} "#SHUTDOWN_WAIT is wait time in seconds for java proccess to stopshutdown_ Wait=20tomcat_pid () { echo ' ps -ef | grep $CATALINA _home | grep -v grep | tr -s " " |cut -d " -f2 '}start () { pid=$ (tomcat_pid) if [ -n "$pid" ];then echo -e "\e[00;31mtomcat is already running (pid: $pid) \e[00m" else echo -e "\e[00;32mstarting tomcat\e[00m" if [ ' user_exists $TOMCAT _user ' = "1" ];then su $TOMCAT _user -c $CATALINA _home/bin/startup.sh else $CATALINA _home/bin/startup.sh fi status fi return 0}status () { pid=$ (tomcat_pid) if [ -n "$ pid " ];then echo -e "\e[00;32mtomcat is running with pid: $pid \e[00m " else echo -e " \e[00;31mtomcat is not running\e[ 00m " fi}stop () { pid=$ (tomcat_pid) if [ -n " $pid " ]; then echo -e "\e[00;31mstoping tomcat\e[00m" $CATALINA _home/bin/shutdown.sh let kwait= $SHUTDOWN _wait count=0; until [ ' ps -p $pid | grep -c $pid ' = ' 0 ' ] | | [ $count -gt $kwait ] do echo -n -e "\e[00;31mwaiting for processes to exit\e[00m\n"; sleep 1 let count= $count +1; done if [ $count -gt $kwait ];then echo -n -e "\n\e[00;31mkilling processes which didn ' t stop after $SHUTDOWN _wait seconds\e[00m " kill -9 $pid fi else echo -e "\e[00;31mtomcat is not running\e[00m" fi return 0}user_ Exists () { if id -u $1 >/dev/null 2>&1; then echo "1" else echo "0" fi}case $1 in start) start ;; stop) stop ;; restart) stop start ;; status) status ;; *) echo -e $TOMCAT _usage ;; Esac exit 0
[Email protected] ~]# chmod +x/etc/init.d/tomcat
[[email protected] ~]# chkconfig Tomcat on
To configure the Tomcat Web Administration page:
To be safe, remove all of your own default pages
[Email protected] ~]# mkdir/opt/tomcat-web[[email protected] ~]# mv/usr/local/tomcat/webapps/*/opt/tomcat-web/
Simple configuration of JVM parameters:
[Email protected] ~]# vim/usr/local/tomcat/bin/catalina.sh java_opts= "-djava.awt.headless=true-dfile.encoding= UTF-8-server-xms512m-xmx512m-xx:newsize=128m-xx:maxnewsize=128m-xx:permsize=128m-xx:maxpermsize=128m-xx:+disab LEEXPLICITGC "
To start Tomcat:
[[email protected] ~]# chown-r tomcat:tomcat/usr/local/tomcat/[[email protected] ~]# service Tomcat startstarting Tomcat Using catalina_base:/usr/local/tomcatusing catalina_home:/usr/local/tomcatusing catalina_tmpdir:/usr/local/tomcat /tempusing jre_home:/usr/java/jdk1.8.0_73using CLASSPATH:/usr/local/tomcat/bin/bootstrap.jar:/usr/local/tom Cat/bin/tomcat-juli.jartomcat started. Tomcat is running with pid:12127
[[email protected] ~]# lsof-i: 8080COMMAND PID USER FD TYPE DEVICE size/off NODE namejava 12127 Tomcat 46u IPv6 33591 0t0 TCP *:webcache (LISTEN)
This article from "one step carefully break the red Dust" blog, please be sure to keep this source http://lorne.blog.51cto.com/9062483/1776035
CENTOS7---Tomcat