shell一键部署nginx+tomcat
Posted Security
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了shell一键部署nginx+tomcat相关的知识,希望对你有一定的参考价值。
1.首先拉取环境 tomcat需要用到jdk环境
提前准备好nginx源码包,放于指定目录下
vim test.sh
#!/bin/bash yum -y install gcc gcc-c++ zlib-devel pcre-devel tar zxf nginx-1.16.1.tar.gz cd nginx-1.16.1 && ./configure && make && make install cd /root && rpm -ivh jdk-8u20-linux-x64.rpm tar zxf apache-tomcat-7.0.96.tar.gz cp -r apache-tomcat-7.0.96 /opt/tomcat /usr/local/nginx/sbin/nginx /opt/tomcat/bin/startup.sh
判断nginx
shulian=`cat /usr/local/nginx/conf/nginx.conf|grep \'proxy_pass http://192.168.11.128:8080;\'|wc -l` if [ $shulian -ne 1 ];then sed -i \'s/index.htm;$/index.jsp;/\' /usr/local/nginx/conf/nginx.conf sed -i \'/404.html;/alocation ~ \\\\.jsp$ {\' /usr/local/nginx/conf/nginx.conf sed -i \'/location ~ \\\\.jsp$ {/aproxy_pass http://192.168.11.128:8080;\' /usr/local/nginx/conf/nginx.conf sed -i \'/proxy_pass http:\\/\\/192.168.11.128:8080;/a\\}\' /usr/local/nginx/conf/nginx.conf fi
判断是否在jdk环境
cishu=`cat /etc/profile|grep \'JAVA_HOME\'|wc -l` if [ $cishu -ne 4 ];then echo -e \'export JAVA_HOME=/usr/java/jdk1.8.0_20 export JAVA_BIN=/usr/java/jdk1.8.0_20/bin export PATH=$PATH:$JAVA_HOME/bin export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH\' >>/etc/profile fi
source /etc/profile
tomcat下载路径
wget http://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-7/v7.0.96/bin/apache-tomcat-7.0.96.tar.gz
2.访问ip,后缀添加index.jsp
successful test!!!
以上是关于shell一键部署nginx+tomcat的主要内容,如果未能解决你的问题,请参考以下文章
Docker Compose 一键部署Nginx代理Tomcat集群