1、下载JDK1.8、Tomcat8
2、解压文件
tar -zxvf xxxxxxxxxxxxx.gz
jdk放到 /usr/local/javajdk
tomcat放到 /usr/local/tomcat
3、设置jdk环境变量
vi /etc/profile
#在底部添加
JAVA_HOME=/usr/local/javajdk
PATH=$JAVA_HOME/bin:$PATH
CLASSPATH=$JAVA_HOME/jre/lib/ext:$JAVA_HOME/lib/tools.jar
export PATH JAVA_HOME CLASSPATH
source /etc/profile
4、启动tomcat
/usr/local/tomcat/bin/startup.sh
#/usr/local/tomcat/bin/shutdown.sh
可能要防火墙添加8080端口
firewall-cmd --zone=public --add-port=8080/tcp --permanent
sudo firewall-cmd --reload
5、设置开机自启动
如果要开机自启动tomcat,配置如下:
chmod +x /etc/rc.d/rc.local
-
vi /etc/rc.d/rc.local
在文件中添加下面几行:
export JAVA_HOME=/usr/local/javajdk
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=$JAVA_HOME/jre/lib/ext:$JAVA_HOME/lib/tools.jar
/usr/local/tomcat/bin/startup.sh
(完)