Ubuntu16.04 安装JDK Tomcat

Ubuntu16.04安装jdk,下载linux中的64版本

需要下载jdk,tomcat安装包 tar.gz版本的

http://pan.baidu.com/s/1mi4WVhA

安装JDK:

[email protected]:~$ sudo mkdir /java
[sudo] hongdada 的密码:
hongdada[email protected]:~$ cd /Downloads
bash: cd: /Downloads: 没有那个文件或目录
[email protected]:~$ cd Downloads/
[email protected]:~/Downloads$ sudo mv jdk-8u121-linux-x64.tar.gz /java
[email protected]:~/Downloads$ sudo tar -zxvf jdk-8u121-linux-x64.tar.gz
tar (child): jdk-8u121-linux-x64.tar.gz:无法 open: 没有那个文件或目录
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
[email protected]:~/Downloads$ cd java/
bash: cd: java/: 没有那个文件或目录
[email protected]:~/Downloads$ cd ~
[email protected]:~$ cd java/
bash: cd: java/: 没有那个文件或目录
[email protected]:~$ cd /java
[email protected]:/java$ sudo tar -zxvf jdk-8u121-linux-x64.tar.gz
jdk1.8.0_121/
jdk1.8.0_121/THIRDPARTYLICENSEREADME-JAVAFX.txt
jdk1.8.0_121/THIRDPARTYLICENSEREADME.txt
...............
jdk1.8.0_121/man/ja_JP.UTF-8/man1/jstat.1
[email protected]:/java$ sudo gedit /etc/environment

//修改/etc/environment中的内容

[email protected]:~$ sudo gedit /etc/environment
[sudo] hongdada 的密码: 

(gedit:3856): IBUS-WARNING **: The owner of /home/hongdada/.config/ibus/bus is not root!

(gedit:3856): Gtk-WARNING **: Calling Inhibit failed: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.gnome.SessionManager was not provided by any .service files

** (gedit:3856): WARNING **: Set document metadata failed: 不支持设置属性 metadata::gedit-spell-enabled

** (gedit:3856): WARNING **: Set document metadata failed: 不支持设置属性 metadata::gedit-encoding

** (gedit:3856): WARNING **: Set document metadata failed: 不支持设置属性 metadata::gedit-spell-enabled

** (gedit:3856): WARNING **: Set document metadata failed: 不支持设置属性 metadata::gedit-encoding

** (gedit:3856): WARNING **: Set document metadata failed: 不支持设置属性 metadata::gedit-spell-enabled

** (gedit:3856): WARNING **: Set document metadata failed: 不支持设置属性 metadata::gedit-encoding

** (gedit:3856): WARNING **: Set document metadata failed: 不支持设置属性 metadata::gedit-position
[email protected]:~$ source /etc/environment
[email protected]:~$ 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)

/etc/environment中文件修改为

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:$JAVA_HOME/bin"
export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
export JAVA_HOME=/java/jdk1.8.0_121

修改environment是修改系统的环境变量,还要修改登陆用户的环境变量,即修改/etc/profile的文件

[email protected]:~$ sudo gedit /etc/profile

/etc/profile修改为:

 # /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).

if [ "$PS1" ]; then
  if [ "$BASH" ] && [ "$BASH" != "/bin/sh" ]; then
    # The file bash.bashrc already sets the default PS1.
    # PS1=‘\h:\w\$ ‘
    if [ -f /etc/bash.bashrc ]; then
      . /etc/bash.bashrc
    fi
  else
    if [ "`id -u`" -eq 0 ]; then
      PS1=‘# ‘
    else
      PS1=‘$ ‘
    fi
  fi
fi

if [ -d /etc/profile.d ]; then
  for i in /etc/profile.d/*.sh; do
    if [ -r $i ]; then
      . $i
    fi
  done
  unset i
fi

#set java environment
export JAVA_HOME=/java/jdk1.8.0_121
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH

使用命令使环境变量立即生效

source /etc/profile

重启电脑,能正常进入系统,且java -version命令有效

安装Tomcat9:

在java文件夹下面创建文件夹tomcat,迁移Downloads中的apache-tomcat-9.0.0.M17.tar.gz文件到tomcat文件夹中,解压

修改/java/tomcat/apache-tomcat-9.0.0.M17/bin/startup.sh文件

在文件底部添加

#set java environment
export JAVA_HOME=/java/jdk1.8.0_121
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH

#tomcat
export TOMCAT_HOME=/java/tomcat/apache-tomcat-9.0.0.M17

添加之后的startup.sh文件

#!/bin/sh

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# -----------------------------------------------------------------------------
# Start Script for the CATALINA Server
# -----------------------------------------------------------------------------

# Better OS/400 detection: see Bugzilla 31132
os400=false
case "`uname`" in
OS400*) os400=true;;
esac

# resolve links - $0 may be a softlink
PRG="$0"

while [ -h "$PRG" ] ; do
  ls=`ls -ld "$PRG"`
  link=`expr "$ls" : ‘.*-> \(.*\)$‘`
  if expr "$link" : ‘/.*‘ > /dev/null; then
    PRG="$link"
  else
    PRG=`dirname "$PRG"`/"$link"
  fi
done

PRGDIR=`dirname "$PRG"`
EXECUTABLE=catalina.sh

# Check that target executable exists
if $os400; then
  # -x will Only work on the os400 if the files are:
  # 1. owned by the user
  # 2. owned by the PRIMARY group of the user
  # this will not work if the user belongs in secondary groups
  eval
else
  if [ ! -x "$PRGDIR"/"$EXECUTABLE" ]; then
    echo "Cannot find $PRGDIR/$EXECUTABLE"
    echo "The file is absent or does not have execute permission"
    echo "This file is needed to run this program"
    exit 1
  fi
fi

exec "$PRGDIR"/"$EXECUTABLE" start "[email protected]"

#set java environment
export JAVA_HOME=/java/jdk1.8.0_121
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH

#tomcat
export TOMCAT_HOME=/java/tomcat/apache-tomcat-9.0.0.M17

启动Tomcat

[email protected]:~$ cd /java
[email protected]:/java$ cd tomcat
[email protected]:/java/tomcat$ cd apache-tomcat-9.0.0.M17
[email protected]:/java/tomcat/apache-tomcat-9.0.0.M17$ cd bin
bash: cd: bin: 权限不够
[email protected]:/java/tomcat/apache-tomcat-9.0.0.M17$ sudo cd bin
sudo: cd:找不到命令
[email protected]:/java/tomcat/apache-tomcat-9.0.0.M17$ sudo bin
sudo: bin:找不到命令
[email protected]:/java/tomcat/apache-tomcat-9.0.0.M17$ sudo ./bin/startup.sh
Using CATALINA_BASE:   /java/tomcat/apache-tomcat-9.0.0.M17
Using CATALINA_HOME:   /java/tomcat/apache-tomcat-9.0.0.M17
Using CATALINA_TMPDIR: /java/tomcat/apache-tomcat-9.0.0.M17/temp
Using JRE_HOME:        /java/jdk1.8.0_121
Using CLASSPATH:       /java/tomcat/apache-tomcat-9.0.0.M17/bin/bootstrap.jar:/java/tomcat/apache-tomcat-9.0.0.M17/bin/tomcat-juli.jar
Tomcat started.

虚拟机的ip地址为192.168.1.202

查看tomcat

为了每次能够在开机的时候自动启动tomcat

修改/etc/rc.local文件

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

#set java environment
export JAVA_HOME=/java/jdk1.8.0_121
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH

#tomcat
export TOMCAT_HOME=/java/tomcat/apache-tomcat-9.0.0.M17

#configuration
/java/tomcat/apache-tomcat-9.0.0.M17/bin/startup.sh

特别是configuration下面的,用于自启动。

http://www.linuxidc.com/Linux/2017-02/140908.htm

http://www.linuxdiyf.com/linux/27852.html

时间: 2025-01-31 07:38:35

Ubuntu16.04 安装JDK Tomcat的相关文章

Ubuntu server12.04安装JDK+Tomcat+mysql

一.安装JDK 1.首先到官网上下载jdk-7u79-linux-x64.tar.gz. 2.将jdk-7u79-linux-x64.tar.gz拷贝到/usr/lib/jdk/目录下面,这里如果没有jdk文件夹,则创建该文件夹,命令: 1 cd /usr/lib 2 sudo mkdir jdk 我的jdk是U盘拷的,先得挂载,然后拷贝: 1 sudo mount /dev/sdc4 /mnt/ //挂载U盘 2 sudo cp -a /mnt/jdk-7u79-linux-x64.tar.g

Ubuntu16.04安装JDK

转载请注明源出处:http://www.cnblogs.com/lighten/p/6105463.html 1.简单的安装方法 安装JDK的最简单方法应该就是使用apt-get来安装了,但是源一般是OpenJDK,如果需要安装oracle的JDK这种方法就不合适了,直接跳过看下面的章节. 1.使用ctrl+alt+t打开终端,你可以添加一个含有OpenJDK源的仓库,一般是不需要,因为一般都有. 备份原始源文件:cp /etc/apt/sources.list /etc/apt/sources

ubuntu16.04 安装 jdk 和 tomcat

首先确认系统中没有安装openJDK,有的话先卸载 下载jdk Linux x64   172.95 MB       jdk-8u101-linux-x64.tar.gz 拷贝到/usr/jdk cp /home/lg/jdk.tar.gz /usr/jdk 解压缩 sudo tar -xf jdk.tar.gz 配置环境变量 使环境变量生效 查看jdk安装是否成功 下载tomcat gz包 解压缩到/usr/tomcat或其他位置 在 bin/startup.sh  追加 CATALINA_

Ubuntu16.04安装后开发环境配置和常用软件安装

Ubuntu16.04安装后1.安装常用软件搜狗输入法+编辑器Atom+浏览器Chome+视频播放器vlc+图像编辑器GIMP Image Editor安装+视频录制软件RcordMyDesktop安装.2.开发环境配置.JDK环境配置+Scala环境配置+nodejs环境配置+开发工具intellij IDEA安装+Python数据分析环境配置+Jupyter开发工具安装+Python多版同时支持. 1.Ubuntu16.04安装常用软件(搜狗输入法+编辑器Atom+浏览器Chome+视频播放

Ubuntu16.04安装Hadoop2.7.3教程

Ubuntu16.04安装Hadoop2.7.3 教程 参考厦门大学数据库实验室 http://dblab.xmu.edu.cn/blog/install-hadoop/,遇到相关的地方有改动. 作者:秦景坤 日期:2017-4-20 主要内部包括 环境配置和本地和伪分布 本文档适合于原生Hadoop2,参考相关文档,亲自动手实践来一步一步搭建环境.转载请指明出处. 环境 本教程使用Ubuntu16.04 64位作为系统环境,包括桌面版和server版,其他版本系统,若有差异请自行百度安装教程系

Ubuntu16.04安装tensorflow+安装opencv+安装openslide+安装搜狗输入法

Ubuntu16.04在cuda以及cudnn安装好之后,安装tensorflow,tensorflow以及opencv可以到网上下载对应的安装包并且直接在安装包所在的路径下直接通过pip与conda进行安装,如下图所示: 前提是要下载好安装包.安装好tensorflow之后还需要进行在~/.bashrc文件中添加系统路径,如下图所示 Openslide是医学图像一个重要的库,这里给出三条命令进行安装 sudo apt-get install openslide-tools sudo apt-g

Ubuntu16.04安装opencv for python/c++

Ubuntu16.04安装opencv for python/c++ 网上关于opencv的安装已经有了不少资料,但是没有一篇资料能让我一次性安装成功,因此花费了大量时间去解决各种意外,希望这篇能给一些人带去便利,节省时间. 1.安装OpenCV所需的库 1 sudo apt-get install build-essential 2 sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavforma

Linux入门(9)——Ubuntu16.04安装flash player

打开网页经常提示安装flash player,不安装flash player很多网页的视频都看不了. Ubuntu16.04安装flash player 打开终端,输入: sudo apt-get install flashplugin-installer

ubuntu16.04安装部署监控系统zabbix2.4

Ubuntu16.04安装部署监控系统Zabbix2.4 第一部分,php+mysql+nginx组件安装 1.系统更新 sudo apt-get update && sudo apt-get upgrade 2.安装php-fpm 检索系统当前自带的PHP版本:apt-cache search php-fpm 安装依赖包:sudo apt-get install make  bison g++ build-essential libncurses5-dev cmake 安装php-fpm