zoukankan      html  css  js  c++  java
  • centos 安装java和tomcat

    一、yum环境

      1、查看yum是否安装

    rpm -qa | grep yum

    二、Java环境

      1、查看java是否安装,若没有,进行安装

    rpm -qa | grep java

      2、查找java-1.8.0的可以使用的安装包

    yum list | grep java-1.8.0-openjdk

      3、安装java-1.8.0-openjdk所有的文件

    yum -y install java-1.8.0-openjdk*

      4、查看版本号

    java -version

      5、输入javac,如果能看到内容输出就说明已经安装好了

    [root@VM-0-15-centos ~]# javac
    Usage: javac <options> <source files>
    where possible options include:
      -g                         Generate all debugging info
      -g:none                    Generate no debugging info
      -g:{lines,vars,source}     Generate only some debugging info
      -nowarn                    Generate no warnings
      -verbose                   Output messages about what the compiler is doing
      -deprecation               Output source locations where deprecated APIs are used
      -classpath <path>          Specify where to find user class files and annotation processors

    三、tomcat

      1、安装:yum在线安装tomcat(-y 代表遇到询问都选 y,这样安装过程中就不需要手动输入y了)

    yum -y install tomcat

      2、查看tomcat服务状态:Active: inactive (dead)  服务处于挂了的状态

    [root@VM-0-15-centos tomcat]# systemctl status tomcat
    ● tomcat.service - Apache Tomcat Web Application Container
       Loaded: loaded (/usr/lib/systemd/system/tomcat.service; disabled; vendor preset: disabled)
       Active: inactive (dead)
    [root@VM-0-15-centos tomcat]# 

      3、启动tomcat服务,查看状态:Active: active (running) 服务运行中

    [root@VM-0-15-centos tomcat]# systemctl start tomcat
    [root@VM-0-15-centos tomcat]# systemctl status tomcat
    ● tomcat.service - Apache Tomcat Web Application Container
    Loaded: loaded (/usr/lib/systemd/system/tomcat.service; disabled; vendor preset: disabled)
    Active: active (running) since Mon 2020-08-10 10:27:53 CST; 9s ago
    Main PID: 27930 (java)
    CGroup: /system.slice/tomcat.service
    └─27930 /usr/lib/jvm/jre/bin/java -classpath /usr/share/tomcat/bin/bootstrap.jar:/usr/share/t...

    Aug 10 10:27:54 VM-0-15-centos server[27930]: Aug 10, 2020 10:27:54 AM org.apache.catalina.startup.C...load
    Aug 10 10:27:54 VM-0-15-centos server[27930]: INFO: Initialization processed in 515 ms
    Aug 10 10:27:54 VM-0-15-centos server[27930]: Aug 10, 2020 10:27:54 AM org.apache.catalina.core.Stan...rnal
    Aug 10 10:27:54 VM-0-15-centos server[27930]: INFO: Starting service Catalina
    Aug 10 10:27:54 VM-0-15-centos server[27930]: Aug 10, 2020 10:27:54 AM org.apache.catalina.core.Stan...rnal
    Aug 10 10:27:54 VM-0-15-centos server[27930]: INFO: Starting Servlet Engine: Apache Tomcat/7.0.76
    Aug 10 10:27:54 VM-0-15-centos server[27930]: Aug 10, 2020 10:27:54 AM org.apache.coyote.AbstractPro...tart
    Aug 10 10:27:54 VM-0-15-centos server[27930]: INFO: Starting ProtocolHandler ["ajp-bio-8009"]
    Aug 10 10:27:54 VM-0-15-centos server[27930]: Aug 10, 2020 10:27:54 AM org.apache.catalina.startup.C...tart
    Aug 10 10:27:54 VM-0-15-centos server[27930]: INFO: Server startup in 34 ms
    Hint: Some lines were ellipsized, use -l to show in full.
    [root@VM-0-15-centos tomcat]# 

      4、访问:浏览器访问http://服务器公网ip:8080, 就可以打开tomcat的地址了

      5、配置用户:进入 tomcat 安装目录(cd /usr/share/tomcat),进入 conf 目录,打开 tomcat-users.xml 文件,在 标签下,添加如下配置:

    <role rolename="manager-gui"/>
    <user username="root" password="root" roles="manager-gui"/>

      6、tomcat相关命令

    停止tomcat服务
    
    systemctl stop tomcat
    
    重启tomcat
    
    systemctl restart tomcat
    
    开机启动
    
    systemctl enable tomcat
    
    查看tomcat状态
    
    systemctl status tomcat
    
    启动tomcat
    
    systemctl start tomcat
  • 相关阅读:
    SQL Server 2005中的分区表(一):什么是分区表?为什么要用分区表?如何创建分区表?
    SQL Server 分区表
    SQL Server表分区
    Red Gate系列之一 SQL Compare 10.4.8.87 Edition 数据库比较工具 完全破解+使用教程
    C# WinForm开发系列
    C# WinForm开发系列
    富文本编辑器 CKeditor 配置使用
    C# ListView用法详解
    C# WinForm给Button或其它控件添加快捷键响应
    WebApi安全性 使用TOKEN+签名验证
  • 原文地址:https://www.cnblogs.com/zooblogs/p/13468795.html
Copyright © 2011-2022 走看看