CentOS下安裝Tomcat7

1.檢查java版本信息html

#java -version
java version "1.7.0_65"
OpenJDK Runtime Environment (rhel-2.5.1.2.el6_5-x86_64 u65-b17)
OpenJDK 64-Bit Server VM (build 24.65-b04, mixed mode)

若是沒有則安裝,則安裝jdkjava

1.一、(如下方式強烈不建議,由於有時候會缺乏jar包,致使tomcat啓動不成功):linux

yum -y install java-1.7.0-openjdk

1.二、強烈建議安裝oracle的jdk包,此處安裝jdk7,到以下網站下載:http://www.oracle.com/technetwork/cn/java/javase/downloads/jdk7-downloads-1880260.htmlapache

下載:jdk-7u79-linux-x64.tar.gz到/tmp
解壓:tar xzf jdk-7u79-linux-x64.tar.gz
移動:mv jdk1.7.0_79 /usr/local/java

添加環境變量 vim /etc/profile  ,在文件末尾添加:bootstrap

export JAVA_HOME=/usr/local/java
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin

立馬生效:source /etc/profilevim

2. 下載並解壓縮tomcattomcat

# cd /tmp
# wget http://apache.fayea.com/tomcat/tomcat-7/v7.0.72/bin/apache-tomcat-7.0.72.tar.gz

# tar xzf apache-tomcat-7.0.72.tar.gz
# mv apache-tomcat-7.0.72 /usr/local/tomcat7

3. 啓動tomcatoracle

# cd /usr/local/tomcat7
# ./bin/startup.sh
若是以上命令不行,則進入bin文件夾運行 sh startup.sh

[輸出樣例]網站

Using CATALINA_BASE:   /usr/local/tomcat7
Using CATALINA_HOME:   /usr/local/tomcat7
Using CATALINA_TMPDIR: /usr/local/tomcat7/temp
Using JRE_HOME:        /usr/local/java
Using CLASSPATH:       /usr/local/tomcat7/bin/bootstrap.jar:/usr/local/tomcat7/bin/tomcat-juli.jar
Tomcat started.

4. 訪問http://ip:8080ui

5. 設置用戶帳戶(可暫時忽略)

<role rolename="admin-gui"/>
<role rolename="admin-script"/>
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<role rolename="manager-jmx"/>
<role rolename="manager-status"/>
<user username="tomcat" password="tomcat" roles="manager-gui,manager-script,manager-jmx,manager-status,admin-script,admin-gui"/>

6. 重啓tomcat服務,進入/usr/local/tomcat7目錄

 # ./bin/shutdown.sh
 # ./bin/startup.sh
若是以上命令不行,則進入bin文件夾運行 sh shutdown.sh 或者 sh startup.sh
相關文章
相關標籤/搜索