https://blog.51cto.com/shunzi115/2063275
1、安装jdk
cd /tmp
tar -zxvf jdk-7u79-linux-x64.tar.gz -C /usr/local
cd /usr/local/
ln -sv jdk1.7.0_79 java
vim /etc/profile.d/java.sh
--------------------------
export JAVA_HOME
=/usr/local/java
export CLASSPATH
=.:
$JAVA_HOME/lib/tools.jar:
$JAVA_HOME/lib/dt.jar
export PATH
=$JAVA_HOME/bin:
$JAVA_HOME/jre/bin:
$PATH
--------------------------
source /etc/profile
java -version
2、安装tomcat
cd /tmp
tar -zxvf apache-tomcat-7.0.70.tar.gz -C /usr/local/
cd /usr/local/
ln -sv apache-tomcat-7.0.70 tomcat
vim /etc/profile.d/tomcat.sh
------------
export CATALINA_HOME
=/usr/local/tomcat
export PATH
=$CATALINA_HOME/bin:
$PATH
------------
source /etc/profile
catalina.sh version
3、tomcat.service 自启动
[Unit
]
Description
=Tomcat
After
=syslog.target network.target remote-fs.target nss-lookup.target
[Service
]
Type
=forking
Environment
='JAVA_HOME=/usr/local/java'
Environment
='CATALINA_PID=/usr/local/apache-tomcat-7.0.70/bin/tomcat.pid'
Environment
='CATALINA_HOME=/usr/local/apache-tomcat-7.0.70/'
Environment
='CATALINA_BASE=/usr/local/apache-tomcat-7.0.70/'
Environment
='CATALINA_OPTS=-Xms1024M -Xmx1024M -server -XX:+UseParallelGC'
WorkingDirectory
=/usr/local/apache-tomcat-7.0.70/
ExecStart
=/usr/local/apache-tomcat-7.0.70/bin/startup.sh
ExecReload
=/bin/kill -s HUP
$MAINPID
ExecStop
=/bin/kill -s QUIT
$MAINPID
PrivateTmp
=true
[Install
]
WantedBy
=multi-user.target
4、设置自启动
systemctl
enable tomcat.service
systemctl start tomcat.service
systemctl status tomcat.service
查看服务状态
ps -ef
| grep tomcat
netstat -antp