1.先看一下我的项目结构,由于项目间业务模块较多、依赖性较强,也为了方便项目的拓展,所以用maven。
(1)项目结构

(2)template pom.xml配置
2.打包
(1)将medicine-template依赖包,打成jar(maven install)
(2)将medicine-template打成jar包
(3)确定打包成功后,maven build:medicine-war,这样项目就达成了war包
3.部署
确定war打包成功后,就部署到linux服务器上,步骤如下:
(1)配置项目数据库及其applicationContext-dao.xml、applicationContext.xml、dev.properties、logback.xml、velocity-toolbox.xml相关配置信息;
(2)将打包后的项目代码拷贝到指定文件夹下
(3)配置代理服务器nginx相关信息(包括域名、端口号、静态文件目录)
配置完成后,重启nginx ,命令如下:nginx -s reload
(3)配置tomcat相关信息,包括tomcat端口,<host></host>配置
配置tomcat端口时,要保证tomcat端口不被占用。判断端口是否被占用命令:
查看指定端口是否被占用:
netstat -an|grep 端口号
查看tomcat被占用端口:
netstat -an|grep tomcat
ps -ef|grep tomcat
(4)开放服务器端口号,修改 /etc/sysconfig/iptables
保存成功,运行如下命令:service iptables save
(5)重启tomcat
关闭命令:./bin/shutdown.sh
重启命令:./bin/startup.sh
查看命令:tail -f logs/catalina.out