k668 发表于 2018-10-20 10:53:24

【TOMACT】install and setup tomcat server-12016767

  1 检查是否已安装JAVA
  # java -version
  java version "1.8.0_121"
  Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
  Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)
  没有的话去安装如下:
  从http://www.oracle.com/technetwork/java/javase/downloads/index.html下载JDK的tar.gz版本
  # tar zxvfjdk-8u121-linux-x64.tar.gz
  # cd jdk1.8.0_121/
  # export JAVA_HOME=/application/jdk1.8.0_121
  # export PATH=$JAVA_HOME/bin:$PATH

  # export>  使系统变量立即生效
  # source /etc/profile
  # java -version
  java version "1.8.0_121"
  Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
  Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)
  2.下载并解压最新版本的Tomcat,http://tomcat.apache.org
  2.1 解压缩 apache-tomcat-9.0.0.M4.tar.gz:
  tar -zxvf apache-tomcat-9.0.0.M4.tar.gz
  2.2 将通过解压得到的 apache-tomcat-9.0.0.M4 文件复制到 /usr/local/tomcat 目录中:
  mv apache-tomcat-9.0.0.M4 ../tomcat/
  2.3 打开文件 /etc 目录下的 profile 文件:
  vim /etc/profile
  将如下代码追加到 profile 文件末尾:

  #>  CATALINA_HOME=/usr/local/tomcat/apache-tomcat-9.0.0.M18
  CATALINA_BASE=/usr/local/tomcat/apache-tomcat-9.0.0.M18
  PATH=$PATH:$CATALINA_BASE/bin
  export PATH CATALINA_BASE

  #>  保持并推出:wq!
  2.4 修改 tomcat 的端口号和字符编码:
  进入到 /usr/local/tomcat/apache-tomcat-9.0.0.M4/conf 目录中:
  cd ../tomcat/apache-tomcat-9.0.0.M4/conf
  打开 tomcat 服务的配置文件 server.xml:
  vi server.xml
  2.5 增加 manager-gui 图形化管理界面的访问权限(不需要的话,此步骤可忽略):
  打开 tomcat 的用户配置文件 tomcat-users.xml:
  vi tomcat-users.xml
  在 标签前加入如下代码:
  这里设置的 username 和 password 都是 password,角色为 manager-gui;
  键入 Esc 并输入“:wq!”保持并退出;
  2.6 进入到 /usr/local/tomcat/apache-tomcat-9.0.0.M4/bin 目录中:
  cd ../bin/
  2.8 启动 tomcat 服务:
  ./startup.sh
  打印如下信息则表明启动 Tomcat 服务成功:
  Using CATALINA_BASE: /usr/local/tomcat/apache-tomcat-9.0.0.M18
  Using CATALINA_HOME: /usr/local/tomcat/apache-tomcat-9.0.0.M18
  Using CATALINA_TMPDIR: /usr/local/tomcat/apache-tomcat-9.0.0.M418temp
  Using JRE_HOME: /usr/local/jdk/jdk1.8.0_91/jre

  Using>  Tomcat started.
  打开浏览器输入 IP 地址看看吧!
  2.9 关闭 tomcat 服务:
  ./shutdown.sh
  打印如下信息则表明关闭 Tomcat 服务成功:
  Using CATALINA_BASE: /usr/local/tomcat/apache-tomcat-9.0.0.M18
  Using CATALINA_HOME: /usr/local/tomcat/apache-tomcat-9.0.0.M18
  Using CATALINA_TMPDIR: /usr/local/tomcat/apache-tomcat-9.0.0.M18/temp
  Using JRE_HOME: /usr/local/jdk/jdk1.8.0_91/jre

  Using>  注意:不可连续执行多次 ./shutdown.sh 命令,多次后报如下错误:
  SEVERE: Catalina.stop:
  java.net.ConnectException: Connection refused
  at java.net.PlainSocketImpl.socketConnect(Native Method)
  at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
  at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
  at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
  at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
  at java.net.Socket.connect(Socket.java:589)
  at java.net.Socket.connect(Socket.java:538)
  at java.net.Socket.(Socket.java:434)
  at java.net.Socket.(Socket.java:211)
  at org.apache.catalina.startup.Catalina.stopServer(Catalina.java:476)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:498)
  at org.apache.catalina.startup.Bootstrap.stopServer(Bootstrap.java:408)
  at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:497)


页: [1]
查看完整版本: 【TOMACT】install and setup tomcat server-12016767