[CentOS] JDK+tomcat集群+nginx一键安装脚本
[CentOS] JDK+tomcat集群+nginx一键安装脚本
整理了一下在CentOS下JDK+tomcat集群+nginx的安装脚本. 支持CentOS6.x/7.x
1.安装前准备
# is root user if [ "$(whoami)" != 'root' ]; then echo "install need root user" exit fi |
2.下载必要的安装文件
echo "========================preparing install packages======================" file1=./jdk-8u144-linux-x64.tar.gz if [ ! -f "$file1" ]; then echo "need jdk-8u144-linux-x64.tar.gz,try to downloading." curl -L -C - -b "oraclelicense=accept-securebackup-cookie" -O http://download.oracle.com/otn-pub/java/jdk/8u144-b01/090f390dda5b47b9b721c7dfaa008135/jdk-8u144-linux-x64.tar.gz fi file2=./apache-tomcat-8.0.45.tar.gz if [ ! -f "$flie2" ]; then echo "need apache-tomcat-8.0.45.tar.gz, try to downloading." curl -O http://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-8/v8.0.45/bin/apache-tomcat-8.0.45.tar.gz fi file3=./nginx-1.13.4.tar.gz if [ ! -f "$flie3" ]; then echo "need nginx-1.13.4.tar.gz, try to downloading." curl -O http://nginx.org/download/nginx-1.13.4.tar.gz fi |
3.安装JDK
#)install JDK echo "========================jdk is installing======================" tar zxvf jdk-8u144-linux-x64.tar.gz mv jdk1.8.0_144 /usr/local/jdk1.8.0_144 echo "jdk1.8.0_144 is rename to /usr/local/jdk1.8.0_144" ln -s /usr/local/jdk1.8.0_144 /usr/local/jdk echo "jdk1.8.0_144 is link to /usr/local/jdk" ; #)Add the environment variable to /etc/profile echo "export JAVA_HOME=/usr/local/jdk" >> /etc/profile echo "export PATH=$JAVA_HOME/bin:$PATH" >> /etc/profile echo "export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar" >> /etc/profile ; source /etc/profile |
4.安装Tomcat,此处使用单独实例方式安装多个Tomcat实例
#)Install tomcat echo "====================apache-tomcat is installing===================" tar zxvf apache-tomcat-8.0.45.tar.gz mv apache-tomcat-8.0.45 /usr/local/tomcat1 cp -p /usr/local/tomcat1/bin/catalina.sh /etc/init.d/tomcat1 #)Configure tomcat sed -i '1a\. /etc/init.d/functions' /etc/init.d/tomcat1 sed -i '2a\:' /etc/init.d/tomcat1 sed -i '3a\JAVA_HOME=/usr/local/jdk' /etc/init.d/tomcat1 sed -i '4a\CATALINA_BASE=/usr/local/tomcat1' /etc/init.d/tomcat1 sed -i '5a\CATALINA_HOME=/usr/local/tomcat1' /etc/init.d/tomcat1 ; #/etc/init.d/tomcat1 #chkconfig --add tomcat1 #chkconfig tomcat1 on tar zxvf apache-tomcat-8.0.45.tar.gz mv apache-tomcat-8.0.45 /usr/local/tomcat2 cp -p /usr/local/tomcat2/bin/catalina.sh /etc/init.d/tomcat2 #)Configure tomcat sed -i '1a\. /etc/init.d/functions' /etc/init.d/tomcat2 sed -i '2a\:' /etc/init.d/tomcat2 sed -i '3a\JAVA_HOME=/usr/local/jdk/' /etc/init.d/tomcat2 sed -i '4a\CATALINA_BASE=/usr/local/tomcat2' /etc/init.d/tomcat2 sed -i '5a\CATALINA_HOME=/usr/local/tomcat2' /etc/init.d/tomcat2 ; /etc/init.d/tomcat2 #chkconfig --add tomcat2 #chkconfig tomcat2 on #/usr/local/tomcat1/bin/startup.sh #/usr/local/tomcat1/bin/startup.sh |
5.安装nginx
#install nginx echo "====================nginx is installing===================" yum install -y make gcc yum install -y pcre* yum install -y openssl* yum install -y zlib zlib-devel tar zxvf nginx-1.13.4.tar.gz cd nginx-1.13.4 ./configure --prefix=/usr/local/nginx-1.13.4 \ --with-http_ssl_module \ --with-http_stub_status_module \ --with-pcre make install #make symbol links ln -s /usr/local/nginx-1.13.4 /usr/local/nginx |
6.安装svn,管理代码和应用发布
echo "====================install subversion===================" #install subversion yum install -y subversion |
7.启动应用
echo "====================startup application===================" #tomcat1 /etc/init.d/tomcat1 stop /etc/init.d/tomcat1 start #tomcat2 /etc/init.d/tomcat1 stop /etc/init.d/tomcat2 start #nginx /usr/local/nginx/sbin/nginx -s stop /usr/local/nginx/sbin/nginx |
完整的安装脚本
# is root user if [ "$(whoami)" != 'root' ]; then echo "install need root user" exit fi echo "========================preparing install packages======================" file1=./jdk-8u144-linux-x64.tar.gz if [ ! -f "$file1" ]; then echo "need jdk-8u144-linux-x64.tar.gz,try to downloading." curl -L -C - -b "oraclelicense=accept-securebackup-cookie" -O http://download.oracle.com/otn-pub/java/jdk/8u144-b01/090f390dda5b47b9b721c7dfaa008135/jdk-8u144-linux-x64.tar.gz fi file2=./apache-tomcat-8.0.45.tar.gz if [ ! -f "$flie2" ]; then echo "need apache-tomcat-8.0.45.tar.gz, try to downloading." curl -O http://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-8/v8.0.45/bin/apache-tomcat-8.0.45.tar.gz fi file3=./nginx-1.13.4.tar.gz if [ ! -f "$flie3" ]; then echo "need nginx-1.13.4.tar.gz, try to downloading." curl -O http://nginx.org/download/nginx-1.13.4.tar.gz fi #)install JDK echo "========================jdk is installing======================" tar zxvf jdk-8u144-linux-x64.tar.gz mv jdk1.8.0_144 /usr/local/jdk1.8.0_144 echo "jdk1.8.0_144 is rename to /usr/local/jdk1.8.0_144" ln -s /usr/local/jdk1.8.0_144 /usr/local/jdk echo "jdk1.8.0_144 is link to /usr/local/jdk" ; #)Add the environment variable to /etc/profile echo "export JAVA_HOME=/usr/local/jdk" >> /etc/profile echo "export PATH=$JAVA_HOME/bin:$PATH" >> /etc/profile echo "export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar" >> /etc/profile ; source /etc/profile #)Install tomcat echo "====================apache-tomcat is installing===================" tar zxvf apache-tomcat-8.0.45.tar.gz mv apache-tomcat-8.0.45 /usr/local/tomcat1 cp -p /usr/local/tomcat1/bin/catalina.sh /etc/init.d/tomcat1 #)Configure tomcat sed -i '1a\. /etc/init.d/functions' /etc/init.d/tomcat1 sed -i '2a\:' /etc/init.d/tomcat1 sed -i '3a\JAVA_HOME=/usr/local/jdk' /etc/init.d/tomcat1 sed -i '4a\CATALINA_BASE=/usr/local/tomcat1' /etc/init.d/tomcat1 sed -i '5a\CATALINA_HOME=/usr/local/tomcat1' /etc/init.d/tomcat1 ; #/etc/init.d/tomcat1 #chkconfig --add tomcat1 #chkconfig tomcat1 on tar zxvf apache-tomcat-8.0.45.tar.gz mv apache-tomcat-8.0.45 /usr/local/tomcat2 cp -p /usr/local/tomcat2/bin/catalina.sh /etc/init.d/tomcat2 #)Configure tomcat sed -i '1a\. /etc/init.d/functions' /etc/init.d/tomcat2 sed -i '2a\:' /etc/init.d/tomcat2 sed -i '3a\JAVA_HOME=/usr/local/jdk/' /etc/init.d/tomcat2 sed -i '4a\CATALINA_BASE=/usr/local/tomcat2' /etc/init.d/tomcat2 sed -i '5a\CATALINA_HOME=/usr/local/tomcat2' /etc/init.d/tomcat2 ; /etc/init.d/tomcat2 #chkconfig --add tomcat2 #chkconfig tomcat2 on #/usr/local/tomcat1/bin/startup.sh #/usr/local/tomcat1/bin/startup.sh #install nginx echo "====================nginx is installing===================" yum install -y make gcc yum install -y pcre* yum install -y openssl* yum install -y zlib zlib-devel tar zxvf nginx-1.13.4.tar.gz cd nginx-1.13.4 ./configure --prefix=/usr/local/nginx-1.13.4 \ --with-http_ssl_module \ --with-http_stub_status_module \ --with-pcre make install #make symbol links ln -s /usr/local/nginx-1.13.4 /usr/local/nginx echo "====================install subversion===================" #install subversion yum install -y subversion echo "====================startup application===================" #tomcat1 /etc/init.d/tomcat1 stop /etc/init.d/tomcat1 start #tomcat2 /etc/init.d/tomcat1 stop /etc/init.d/tomcat2 start #nginx /usr/local/nginx/sbin/nginx -s stop /usr/local/nginx/sbin/nginx |
Recent Comments