Tomcat,jdk安装包以及脚本文档
链接 https://pan.baidu.com/s/1w4VmOv-Re1MsPmAZ_Kik4Q
提取码:5t6v
上传两个刚才下载的压缩包
[root@localhost ~]# ls
jdk-7u80-linux-x64.tar.gz
apache-tomcat-8.5.29.zip
编辑脚本文件
[root@localhost ~]# vim tomcat.sh
#/bin/bash
echo "
##############################
# Filename:tomcat.sh #
# Author:唯以 #
# Edition:1.0.0 #
# Function:自动安装tomcat #
############################## "
echo "hello word"
tar -zxf jdk-7u80-linux-x64.tar.gz
mv jdk1.7.0_80/ /usr/local/jdk1.7
echo "export JAVA_HOME=/usr/local/jdk1.7
export CLASSPATH=./:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$JAVA_HOME/bin:$PATH" >> /etc/profile
. /etc/profile
java -version
useradd -M -s /sbin/nologin tomcat
unzip apache-tomcat-8.5.29.zip
mv apache-tomcat-8.5.29 /opt/tomcat
cd /opt/tomcat/
chown -R tomcat:tomcat /opt/tomcat/
echo "/lib/systemd/system/tomcat.service
[Unit]
Description=Apache Tomcat 8
After=network.target
[Service]
Type=forking
User=tomcat
Group=tomcat
Environment=CATALINA_PID=/opt/tomcat/temp/tomcat.pid
Environment=CATALINA_HOME=/opt/tomcat
Environment=CATALINA_BASE=/opt/tomcat
Environment='CATALINA_OPTS=-Xms512M -Xmx4096M -server -XX:+UseParallelGC'
Environment='CATALINA_OPTS=-Dfile.encoding=UTF-8 -server -Xms2048m -Xmx2048m -Xmn1024m -XX:SurvivorRatio=10 -XX:MaxTenuringThreshold=15 -XX:NewRatio=2 -XX:+DisableExplicitGC'
Environment='JAVA_OPTS=-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom'
ExecStart=/opt/tomcat/bin/startup.sh
ExecStop=/bin/kill -15 $MAINPID
Restart=on-failure
[Install]
WantedBy=multi-user.target
" >> /lib/systemd/system/tomcat.service
chmod +x /opt/tomcat/bin/*.sh
systemctl enable tomcat
systemctl start tomcat
systemctl status tomcat
firefox 127.0.0.1:8080
授权执行脚本
[root@localhost ~]# chmod +x tomcat.sh
[root@localhost ~]# ./tomcat.sh
到这里Tomcat自动安装就完成了