• tomcat+jdk安装


    一、下载jdk

    https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

    下载tomcat

    http://tomcat.apache.org/download-80.cgi

     2、安装jdk

    yum install glibc.i686
    mkdir -p /usr/java
    tar xf jdk-8u201-linux-x64.tar.gz  -C /usr/java

    3、配置环境变量

    vim  /etc/profile

    export JAVA_HOME=/usr/java/jdk1.8.0_201
    export JAVA_PATH=$JAVA_HOME
    export PATH=$PATH:$JAVA_HOME/bin
    export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

    生效

    source /etc/profile

    4、验证

    [root@tomcat ~]# java -version
    java version "jdk1.8.0_201"
    Java(TM) SE Runtime Environment (build 1.8.0_191-b12)
    Java HotSpot(TM) Client VM (build 25.191-b12, mixed mode)

    5、安装tomcat

    tar xf apache-tomcat-8.5.35.tar.gz -C /usr/local/
    cd  /usr/local/
    mv  apache-tomcat-8.5.35 tomcat

    6、设置开启自启动

    (1)方法一

    cp -p /usr/local/tomcat/bin/catalina.sh /etc/init.d/tomcat
    
    vim /etc/init.d/tomcat 
    第二行添加
    # chkconfig: 112 63 37
    # description: tomcat server init script
    # Source Function Library
    . /etc/init.d/functions
    JAVA_HOME=/usr/local/jdk1.8.0_191/
    CATALINA_HOME=/usr/local/tomcat/

    修改setclasspath.sh这个文件(不然会报错)
    vim /usr/local/tomcat/bin/setclasspath.sh (添加两行)

       export JAVA_HOME=/usr/java/jdk1.8.0_191
       export JAVA_HOME=/usr/java/jdk1.8.0_191/jre

       

      添加完了以后

      chmod 755 /etc/init.d/tomcat

      chkconfig --add tomcat

      chkconfig tomcat on

     (2)方法二

    添加文件
    vim /lib/systemd/system/tomcat.service [Unit] Description=Tomcat After=syslog.target network.target remote-fs.target nss-lookup.target [Service] Type=oneshot ExecStart=/usr/local/tomcat/bin/startup.sh ExecStop=/usr/local/tomcat/bin/shutdown.sh ExecReload=/bin/kill -s HUP $MAINPID RemainAfterExit=yes [Install] WantedBy=multi-user.target
    修改文件
    vim /usr/local/tomcat/bin/setclasspath.sh   (添加两行)
    
    

       export JAVA_HOME=/usr/java/jdk1.8.0_191
       export JAVA_HOME=/usr/java/jdk1.8.0_191/jre




    设置开机自启 systemctl enable tomcat.service

    6、启动tomcat

    /etc/init.d/tomcat  start   或者 systemctl start tomcat.service

    访问 ip+8080端口访问
    
    

     7、tomcat启动慢(解决办法)

    yum install rng-tools # 安装rngd服务(熵服务,增大熵池)
    systemctl start rngd # 启动服务
  • 相关阅读:
    Cygwin配置总结
    javap 指令集
    超好用的Vim配置
    超过 130 个你需要了解的 vim 命令
    21、面向对象
    20、MySQLdb
    深入java字符串原理及其效率分析
    数据库执行计划
    SQL中EXISTS的用法
    mybatis之foreach用法
  • 原文地址:https://www.cnblogs.com/wangyong-blog/p/9921452.html
Copyright © 2020-2023  润新知