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!!!

posted @ 2019-12-07 11:22  Security  阅读(326)  评论(0编辑  收藏  举报