1.1 下载安装jdk1.7.0_79
JDK7
链接:https://pan.baidu.com/s/1Z5Yyl27T6eFrHzhRnjwwlg
提取码:4kdh
JDK8
链接:https://pan.baidu.com/s/1Bx-AIo3KMOxJ8z7OmbM30A
提取码:m28l
cd /usr/local vim /etc/profile #加入Java环境变量 eexport JAVA_HOME=/usr/local/jdk1.7.0_79 export JAVA_BIN=$JAVA_HOME/bin export JAVA_LIB=$JAVA_HOME/lib export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/tools.jar export PATH=$PATH:$JAVA_HOME/bin export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/apr/lib source /etc/profile java –version 检查jdk版本号 java version "1.7.0_79" Java(TM) SE Runtime Environment (build 1.7.0_79-b15) Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)
1.2 下载安装tomcat-7.0.62
链接:https://pan.baidu.com/s/1sFO1-SqkU7IJD8MutXdSuw
提取码:ig5n
tar xf apache-tomcat-7.0.62.tar.gz
1.2.1 编辑server.xml配置文件
vim /usr/local/apache-tomcat-7.0.62/conf/server.xml <Connector port="80" protocol="HTTP/1.1" #port 端口配置 connectionTimeout="20000" #connectionTimeout指定超时的时间数(以毫秒为单位) redirectPort="8443" /> #指定服务器正在处理http请求时收到了一个SSL传输请求后重定向的端口号 <Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true"> <Context path="" docBase="amol-main" debug="0" reloadable="false"></Context>添加配置默认主页
1.2.2 内存配置:(根据服务器实际内存大小配置)
vim /usr/local/tomcat/bin/catalina.sh JAVA_OPTS="-server -Xms1024m -Xmx13312m -XX:PermSize=1024m -XX:MaxNewSize=512m -XX:MaxPermSize=2048m -Djava.awt.headless=true"Xms取实际内存的80%
1.2.3 清除缓存
vim /usr/local/apache-tomcat-7.0.62/bin/startup.sh rm -rf /usr/local/apache-tomcat-7.0.62/work/Catalina
1.3 Webapps下配置文件
用rz上传或者用scp远程拉取项目文件至wabapps
[root@AMOLserverwebapps]# tree -L 1 amol-back/WEB-INF/classes/ amol-back/WEB-INF/classes/ ├── activeMq.properties MQ配置文件 ├── com ├── cooperation.properties 定义API ├── file.properties 上传下载及共享存储配置 ├── jdbc.properties 连接mysql配置 ├── log4j.properties 定义日志 ├── MessageResources_en_US.properties ├── MessageResources_zh_CN.properties ├── parameter.properties 定义项目url └── redis.propertiesRedis redis配置
1.4 Tomcat启动脚本
#!/bin/sh #chkconfig: 2345 74 44 #description: Tomcat . /etc/profile S1=tomcat TOMCAT_HOME=/usr/local/tomcat S2=`$TOMCAT_PID|wc -l` start () { TOMCAT_PID=`ps -ef |grep "$TOMCAT_HOME" |grep -v "grep" |awk '{print $2}'` if [ -z $TOMCAT_PID ];then /bin/bash $TOMCAT_HOME/bin/startup.sh else echo "$S1 is running" fi } stop () { TOMCAT_PID=`ps -ef |grep "$TOMCAT_HOME" |grep -v "grep" |awk '{print $2}'` if [ -z $TOMCAT_PID ];then echo "$S1 is not running" else echo "shutting down $S1" kill "$TOMCAT_PID" fi } status () { TOMCAT_PID=`ps -ef |grep "$TOMCAT_HOME" |grep -v "grep" |awk '{print $2}'` if [ -z $S2 ];then echo "$S1 is not running" else echo "$S1 is running PID is $TOMCAT_PID" fi } case $1 in start) start ;; stop) stop ;; status) status ;; restart) stop start ;; *) echo "Usage:$0 {start|stop|status|restart}." ;;
esac
1.5 加入定时任务
Crontab –e
##tomcat log##
59 23 * * * /usr/sbin/logrotate -f /data/logrotate/tomcat_log.conf 日志切割
00 00 * * * /bin/sh /data/scripts/log_polling.sh 日志打包备份