1. 程式人生 > >Linux下Tomcat的安裝部署

Linux下Tomcat的安裝部署

Linux下Tomcat的安裝部署
一、 linux下安裝JDK1.6
JDK(Java Development Kit)是Sun Microsystems針對Java開發員的產品。自從Java推出以來,JDK已經成為使用最廣泛的Java SDK。JDK 是整個Java的核心,包括了Java執行環境,Java工具和Java基礎的類庫。下面我們就來學習如何在CentOS系統下安裝 JDK。
1. CentOS系統建立安裝目錄

mkdir /usr/java

  1. 下載(oracle官網下載,需要登入認證,無法直接下載,直接網站上下載上傳)
    先去 www.oracle.com 網站尋找到 最新jdk1.6(JDK 6 Update 30)的下載地址:
    http://download.oracle.com/otn-pub/java/jdk/6u30-b12/jdk-6u30-linux-i586-rpm.bin

    在當前目錄下(/usr/java)執行:
    wget http://download.oracle.com/otn-pub/java/jdk/6u30-b12/jdk-6u30-linux-i586-rpm.bin
    可以喝杯水,慢慢等待……
  2. 在CentOS系統中安裝
    下載完成之後執行命令,即可擁有對 .bin檔案的執行許可權
    chmod 777 *.bin
    然後輸入:
    ./*.bin
    安裝jdk時會顯示出JDK的安裝許可協議,按空格翻頁,最後程式會問你是不是同意上面的協議,當然同意啦,輸入“yes”之後開始解壓JDK到當前目錄。此時螢幕上會顯示解壓的進度。
    解壓完成後 /usr/java目錄下會新建一個名為“jdk**”的目錄,至此我們已經在CentOS系統下安裝好了JDK。
    如果是*.i586.bin的話

chmod a+x *-i586.bin

./*-i586.bin

  1. 配置
    安裝後之後需要配置環境變數。
    vi /etc/profile
    在最後加入以下幾行:
    export JAVA_HOME=/usr/java/jdk1.6.0_30
    export CLASSPATH=.: JAVAHOME/jre/lib/rt.jar: JAVA_HOME/lib/dt.jar: JAVAHOME/lib/tools.jarexportPATH=
    PATH:$JAVA_HOME/bin
    注意,需要把jdk名字修改成您所下載的JDK當前版本。
    設定好JDK,輸入 reboot 命令重啟即可。
  2. 刪除/解除安裝
    用 rm -rf jdk1.6.0_30 命令即可刪除JDK,切記需要把配置檔案的相關內容清空。
    這樣就可以在CentOS系統下安裝 JDK了。

二、 Linux下安裝Tomcat
1.下載安裝tomcat(http://tomcat.apache.org/
[[email protected] ~]# unzip apache-tomcat-6.0.30.zip
[[email protected] ~]# mv apache-tomcat-6.0.30/ /usr/local/
[[email protected] ~]cd /usr/local/
[[email protected] local]# ln -s /usr/local/apache-tomcat-6.0.30/ /usr/local/tomcat
[[email protected] local]# cd tomcat/bin/
[[email protected] bin]#ls
[[email protected] bin]#vim catalina.sh
新增以下內容:
CATALINA_HOME=/usr/local/apache-tomcat-6.0.30/
[[email protected] local]#chmod +x *.sh
2.啟動tomcat伺服器
[[email protected] tomcat]# /usr/local/tomcat /bin/catalina.sh start
Using CATALINA_BASE: /usr/local/apache-tomcat-6.0.30/
Using CATALINA_HOME: /usr/local/apache-tomcat-6.0.30/
Using CATALINA_TMPDIR: /usr/local/apache-tomcat-6.0.30//temp
Using JRE_HOME: /usr/local/jdk1.6.0_05
Using CLASSPATH: /usr/local/apache-tomcat-6.0.30//bin/bootstrap.jar
[[email protected] logs]# cd /usr/local/tomcat/logs/
[[email protected] logs]# tail -f catalina.out
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Jul 4, 2011 11:06:57 AM org.apache.coyote.http11.Http11Protocol pause
INFO: Pausing Coyote HTTP/1.1 on http-8080
Jul 4, 2011 11:06:58 AM org.apache.catalina.core.StandardService stop
INFO: Stopping service Catalina
Jul 4, 2011 11:06:58 AM org.apache.coyote.http11.Http11Protocol destroy
INFO: Stopping Coyote HTTP/1.1 on http-8080
3.在瀏覽器中輸入
http://localhost:8080/(如果不是本機,則輸入對應的ip地址)
測試出現tomcat頁面則測試成功
ps:需要說明的是tomcat的預設測試頁面是放在webapps下面,這個其實是在server.xml檔案中配置的,如下所示:

!/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/Stop Script for the CATALINA Server

#

Environment Variable Prerequisites

#

CATALINA_HOME May point at your Catalina “build” directory.

#

CATALINA_BASE (Optional) Base directory for resolving dynamic portions

of a Catalina installation. If not present, resolves to

the same directory that CATALINA_HOME points to.

#

CATALINA_OUT (Optional) Full path to a file where stdout and stderr

will be redirected.

Default is $CATALINA_BASE/logs/catalina.out

#

CATALINA_OPTS (Optional) Java runtime options used when the “start”,

or “run” command is executed.

#

CATALINA_TMPDIR (Optional) Directory path location of temporary directory

the JVM should use (java.io.tmpdir). Defaults to

$CATALINA_BASE/temp.

#

JAVA_HOME Must point at your Java Development Kit installation.

Required to run the with the “debug” argument.

#

JRE_HOME Must point at your Java Development Kit installation.

Defaults to JAVA_HOME if empty.

#

JAVA_OPTS (Optional) Java runtime options used when the “start”,

“stop”, or “run” command is executed.

#

JAVA_ENDORSED_DIRS (Optional) Lists of of colon separated directories

containing some jars in order to allow replacement of APIs

created outside of the JCP (i.e. DOM and SAX from W3C).

It can also be used to update the XML parser implementation.

Defaults to $CATALINA_HOME/endorsed.

#

JPDA_TRANSPORT (Optional) JPDA transport used when the “jpda start”

command is executed. The default is “dt_socket”.

#

JPDA_ADDRESS (Optional) Java runtime options used when the “jpda start”

command is executed. The default is 8000.

#

JPDA_SUSPEND (Optional) Java runtime options used when the “jpda start”

command is executed. Specifies whether JVM should suspend

execution immediately after startup. Default is “n”.

#

JPDA_OPTS (Optional) Java runtime options used when the “jpda start”

command is executed. If used, JPDA_TRANSPORT, JPDA_ADDRESS,

and JPDA_SUSPEND are ignored. Thus, all required jpda

options MUST be specified. The default is:

#

-agentlib:jdwp=transport=$JPDA_TRANSPORT,

address= JPDAADDRESS,server=y,suspend= JPDA_SUSPEND

#

CATALINA_PID (Optional) Path of the file which should contains the pid

of catalina startup java process, when start (fork) is used

#

LOGGING_CONFIG (Optional) Override Tomcat’s logging config file

Example (all one line)

LOGGING_CONFIG=”-Djava.util.logging.config.file=$CATALINA_BASE/conf/logging.properties”

#

LOGGING_MANAGER (Optional) Override Tomcat’s logging manager

Example (all one line)

LOGGING_MANAGER=”-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager”

#

Id:catalina.sh11460972011071315:25:05Zmarkt

—————————————————————————–

export JRE_HOME=/usr/java/jdk1.6.0_38
export CATALINA_HOME=/home/xrltest1/tomcat
JAVA_OPTS=”-server -Xms2048m -Xmx2048m -Xmn768m -XX:PermSize=128m -XX:MaxPermSize=256m -XX:+UseParallelOldGC -XX:+PrintGCDateStamps -XX:+PrintGCDetails -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/home/xrltest1/tomcat/dumpfile/heap.bin -Xloggc:/home/xrltest1/tomcat/logs/gc.log”

作者新增的環境申明,如果一臺伺服器中有多臺tomcat要使用不同版本的JVM,就可以直接這這邊新增JRE_HOME,不需要再/etc/profile.d中再配置JRE_HOME環境變數

OS specific support. $var must be set to either true or false.

此處語句判斷作業系統,同時對作業系統支援

os400是 IBM的AIX

darwin是MacOSX 操作環境的作業系統成份

Darwin是windows平臺上執行的類UNIX模擬環境

cygwin=false
os400=false
darwin=false
case “uname” in
CYGWIN*) cygwin=true;;
OS400*) os400=true;;
Darwin*) darwin=true;;
esac

resolve links - $0 may be a softlink

此處的RPG抓取的是檔名,因為可能是符號連結,所以下面迴圈語句的作用就是找到檔案真實源路徑

PRG=” 0while[h PRG” ]; do
ls=ls -ld "$PRG"
link=expr "$ls" : '.*-> \(.*\)$'
if expr “ link:/.>/dev/null;thenPRG= link”
else
PRG=dirname "$PRG"/”$link”
fi
done

獲取指令碼目錄真實目錄地址

Get standard environment variables

PRGDIR=dirname "$PRG"

Only set CATALINA_HOME if not already set

[ -z “$CATALINA_HOME” ] && CATALINA_HOME=cd "$PRGDIR/.." >/dev/null; pwd

Copy CATALINA_BASE from CATALINA_HOME if not already set

[ -z “CATALINA_BASE" ] && CATALINA_BASE="CATALINA_HOME”

上面兩個語句判斷變數 CATALINAHOME CATALINA_BASE是否存在,不存在則給予附值

CATALINA_BASE=”$CATALINA_HOME”

Ensure that any user defined CLASSPATH variables are not used on startup,

but allow them to be specified in setenv.sh, in rare case when it is needed.

CLASSPATH=

test –r File 檔案存在並且可讀

if [ -r “ CATALINABASE/bin/setenv.sh];then. CATALINA_BASE/bin/setenv.sh”
elif [ -r “ CATALINAHOME/bin/setenv.sh];then. CATALINA_HOME/bin/setenv.sh”
fi

預設的tomcat的bin目錄下沒有這個檔案,可以自行編寫setenv.sh這個檔案設定環境變數

For Cygwin, ensure paths are in UNIX format before anything is touched

if cygwin;then[n JAVA_HOME” ] && JAVA_HOME=cygpath --unix "$JAVA_HOME"
[ -n “$JRE_HOME” ] && JRE_HOME=cygpath --unix "$JRE_HOME"
[ -n “$CATALINA_HOME” ] && CATALINA_HOME=cygpath --unix "$CATALINA_HOME"
[ -n “$CATALINA_BASE” ] && CATALINA_BASE=cygpath --unix "$CATALINA_BASE"
[ -n “$CLASSPATH” ] && CLASSPATH=cygpath --path --unix "$CLASSPATH"
fi

For OS400

if os400; then  
  # Set job priority to standard for interactive (interactive - 6) by using  
  # the interactive priority - 6, the helper threads that respond to requests  
  # will be running at the same priority as interactive jobs.  
  COMMAND=’chgjob job(‘
JOBNAME’) runpty(6)’
system $COMMAND
# Enable multi threading
export QIBM_MULTI_THREADED=Y
fi

Get standard Java environment variables

if os400; then  
  # -r 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  
  BASEDIR=”
CATALINA_HOME”
. “CATALINA_HOME”/bin/setclasspath.sh  
else  
  #這點一定要注意了,本指令碼中沒有賦值卻突然冒出的變數  
  #都是在setclasspath.sh這個指令碼中執行賦值的。比如
_RUNJAVA
#作者會在下一篇文章中,分析setclasspath.sh這個指令碼
if [ -r “ CATALINAHOME/bin/setclasspath.sh];thenBASEDIR= CATALINA_HOME”
. “ CATALINAHOME/bin/setclasspath.shelse

相關推薦

Linuxvmware安裝部署

linux vmware 安裝部署 Linux下vmware下載:地址-Linux vmware : http://www.vmware.com/products/workstation/workstation-evaluation安裝依賴:yum -y install perl gcc kern

LinuxTomcat安裝配置

雲服務器 比較 ini rip mirrors /usr function connector 根據 買了臺阿裏雲服務器,因為配置比較低,所以用Linux系統,這裏記錄一下我在Linux系統中Tomcat的安裝配置。 前提JDK已經安裝好。 安裝 首先在/usr/local

Linux單機安裝部署kafka及代碼實現

{} edt serial integer exc height 復制 有一個 images 技術交流群:233513714 這幾天研究了kafka的安裝及使用,在網上找了很多教程但是均以失敗告終,直到最後想起網絡方面的問題最終才安裝部署成功,下面就介紹一下kaf

linuxtomcat安裝

tar.gz 設置 war 一點 http org 技術 iptable 保存 1、下載安裝包 官網地址:https://tomcat.apache.org/download-70.cgi 選擇合適的版本:我這裏選擇的是tomcat 7.0.85,可根據需要下載 apa

LINUXsvn安裝部署

rc.d -- 版本 mit sta 密碼 secret all ner 1.#安裝yum install subversion 2.#測試svnserve --version3.#創建庫根路徑mkdir /usr/local/svn4.#創建一個項目庫svnadmin c

linux Tomcat 安裝配置

前提先給jdk安裝好了在弄這個。 https://blog.csdn.net/qq_36921440/article/details/81605151 jdk。 下載 tomcat 上傳伺服器 ls 檢視 tar zxvf apache-tomcat-8.5.32.t

Linuxredis安裝部署

1、下載原始碼 http://code.google.com/p/redis/downloads/list 下載redis-1.2.6.tar.gz 將下載包拷貝到/usr/local/webserver/redis-1.2.6/下

linuxkettle安裝部署

登陸-linux-(切換到kettle部署的使用者下面) 第一:產看系統的java環境,cat .bash_profile 檔案 從上面可以看到,在cognos使用者下已經安裝了java jdk,版本是1.6.0_20,我們看一下kettle的最低版本要求,編

Linuxtomcat安裝並設定自啟動

Tomcat的安裝與自啟動解壓縮並重命名# cd /usr/local/ # tar -zxvf apache-tomcat-7.0.54.tar.gz # mv apache-tomcat-7.0.54 tomcat自啟動在init.d目錄下新建指令碼檔案進入到/etc/i

linuxElasticSearch安裝部署

1、安裝部署 在安裝部署elasticsearch之前,需要先安裝好Java JDK。 1.1 下載安裝 https://download.elastic.co 將軟體下載後解壓。 1.1.2修改elasticsearcy.yml 檔案:

LinuxTomcat安裝部署

Linux下Tomcat的安裝部署 一、 linux下安裝JDK1.6 JDK(Java Development Kit)是Sun Microsystems針對Java開發員的產品。自從Java推出以來,JDK已經成為使用最廣泛的Java SDK。JDK 是整個Java的核心,包括了

linux tomcat安裝

無法訪問 用戶 variable 瀏覽器中 sys exp 開始 col gin 寫在前面: 由於項目使用jdk1.6開發,所以對應服務器應安裝jdk1.6和tomcat6 1、環境變量的配置: 打開/etc/bashrc配置環境變量 JAVA_HOME=/us

centos/linux安裝Tomcat

con utf src jdk 關閉 配置 class 快速 star 1.啟動tomcat時候需要JDK依賴   如果沒有安裝的請移步到該鏈接Centos/linux下的JDK安裝 2.從官網上下載tomcat壓縮包    wget -c http://apache.f

Windowswar包部署LinuxTomcat出現的問題

width es2017 文件的 ls -l chm 可能 發的 問題解決 wan 最近,將Windows下開發的war包部署到Linux下的Tomcat時報了一個錯誤:tomcat error in opening zip file。按理說,如果正常,當把war包復制到w

LinuxTomcat安裝與配置

Linux Tomcat首先要確定你的Linux上已經安裝好了JDK,並在/etc/profile 中完成環境變量配置。 安裝Tomcat軟件訪問http://tomcat.apache.org/download-60.cgi 下載tar.gz版本 [root@localhost ~]# tar -zxvf

linux環境tomcat安裝

down 切換 onf 驗證 rtu .com shu 項目 pac 1.安裝tomcat前安裝jdk(前提下) 2.下載安裝包apache-tomcat-8.0.36.tar.gz 解壓:tar -zxvf apache-tomcat-8.0.36.tar.gz

linuxtomcat部署

本地 api tst boot content input util iptable load 一、安裝jdk 登錄服務器; 使用ftp或者其它linux傳輸工具以ssh會話方式遠程連接linux 下載jdk 將下載的 jdk-7u79-linux-i586.gz

linuxtomcat部署get請求亂碼問題解決方法

預設情況下,Tomcat對請求採用的預設編碼是ISO-8859-1, 這樣我們提交的漢字被認為是ISO-8859-1的編碼,所以在程式中接收時顯示亂碼 。  在過濾器中呼叫request.setCharacterEncoding("GBK"),那麼Post上來的漢字將被認為

LinuxTomcat安裝、啟動、關閉以及配置檔案的修改

安裝 前往tomcat官網https://tomcat.apache.org下載需要的版本。下面以 tomcat8 為例,下載過程如下: 設tomcat安裝包所在目錄為tomcat_download,使用如下命令解壓到資料夾中即完成安裝: tar -xvzf apache-

linuxtomcat部署注意點

    在linux下部署的時候,為了方便,直接從其他專案拷貝的tomcat過來,導致了一些比較奇怪的問題,浪費了不少時間,寫個記錄便於以後檢視。   1.將war包放入linux伺服器的tomcat/webapps目錄下     &nb