tomcat环境变量导致启动失败 \版本隐藏

环境变量缺少导致启动失败

/etc/profile 中配置了环境变量但是启动tomcat仍然显示缺少环境变量。

  export JAVA_HOME=/usr/java/jdk1.8.0_162
  export JRE_HOME=$JAVA_HOME/jre
  export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib
  export PATH=$JAVA_HOME/bin:$PATH

解决方法:在tomcat启动脚本catalina.sh开始补位添加环境变量:

  export JAVA_HOME=/usr/java/jdk1.8.0_162
  export JRE_HOME=$JAVA_HOME/jre
  export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib
  export PATH=$JAVA_HOME/bin:$PATH

启动任务./dir/bin/start.sh

 

隐藏版本:

  a 进入tomcat的lib目录找到catalina.jar文件
  b unzip catalina.jar之后会多出两个文件夹
  c 进入org/apache/catalina/util 编辑配置文件ServerInfo.properties,修改配置
    server.info=zkui
    server.number=0.0.0.0
  d 将修改后的信息压缩回jar包
    cd /tomcat/lib
    jar uvf catalina.jar org/apache/catalina/util/ServerInfo.properties
  e 重启服务

    ./dir/bin/shutdown.sh

    ./dir/bin/start.sh

 

脚本

#-*- coding:utf-8 -*-
import os,re,commands,time,zipfile,shutil,optparse
parser=optparse.OptionParser()
parser.add_option("-p","--path",dest="path",help="alter path")
parser.add_option("-s","--ssh",dest="ssh",action="store_true",help="ssh alter")
parser.add_option("-n","--nginx",dest="nginx",action="store_true",help="nginx alter")
parser.add_option("-a","--apache",dest="apache",action="store_true",help="apache alter")
parser.add_option("-t","--tomcat",dest="tomcat",action="store_true",help="tomcat alter")
parser.add_option("-r","--redis",dest="redis",action="store_true",help="redis alter")
options,args=parser.parse_args()
if options.path:
    search_path=options.path
    file_list=os.listdir(search_path)
    for every_file in file_list:
        if os.path.isdir(os.path.join(search_path,every_file)):
            if options.nginx:
                if re.findall('nginx',every_file):#判断是否包含nginx字符
                    if os.path.exists(os.path.join(search_path,every_file)):
                        nginx_path=os.path.join(search_path,every_file,'sbin/nginx')
                        result=commands.getstatusoutput(nginx_path+' -v')
                        if result[1]:
                            line_list=result[1].split('\n')
                            sub_list=line_list[0].split()#分割输出内容的第一行
                            shutil.copyfile(nginx_path,nginx_path+str(time.time()))
                            nginx_options=open(nginx_path,'r')
                            nginx_content=nginx_options.read()
                            nginx_options.close()
                            os.remove(nginx_path)
                            write_nginx=re.sub(sub_list[2],'6'*len(sub_list[2]),nginx_content)
                            new_nginx=open(nginx_path,'w')
                            new_nginx.write(write_nginx)
                            new_nginx.close()
                            os.system('chmod 755 '+nginx_path)
            if options.apache:
                if re.findall('apache',every_file):
                    if os.path.exists(os.path.join(search_path,every_file)):
                        apache_path=os.path.join(search_path,every_file,'bin/httpd')
                        apache_result=commands.getstatusoutput(apache_path+' -v')
                        print(apache_result)
                        if apache_result[1]:
                            line_list=apache_result[1].split('\n')
                            sub_list=line_list[0].split()
                            shutil.copyfile(apache_path,apache_path+str(time.time()))
                            apache_options=open(apache_path,'r')
                            apache_content=apache_options.read()
                            apache_options.close()
                            os.remove(apache_path)
                            write_apache=re.sub(sub_list[2],'6'*len(sub_list[2]),apache_content)
                            new_apache=open(apache_path,'w')
                            new_apache.write(write_apache)
                            new_apache.close()
                            os.system('chmod 755 '+apache_path)

 

posted @ 2020-05-16 16:28  zk01  阅读(300)  评论(0)    收藏  举报