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
  • 相关阅读:
    数据库与ORM
    Django之Template
    Django路由配置系统、视图函数
    Django基本命令
    MVC和MTV模式
    转载:CSS实现三栏布局的四种方法示例
    转载:JSONObject.fromObject(map)(JSON与JAVA数据的转换)
    转载:CURL常用命令
    转载:详解CSS选择器、优先级与匹配原
    转载:Struts2.3.15.1升级总结
  • 原文地址:https://www.cnblogs.com/zooblogs/p/13468795.html
Copyright © 2011-2022 走看看