Tomcatjava
JDK:Java開發工具包
JRE: Java運行環境
SDK:輔助開發工具(短信商之列的)
J2EE:企業應用
J2SE:標準應用
J2ME:手機nginx
中間件:tomcat resin jboss weblogic websphere
查看是否安裝jdk
[root@minion ~]# rpm -qa|grep jdk
java-1.7.0-openjdk-1.7.0.45-2.4.3.3.el6.x86_64
java-1.6.0-openjdk-1.6.0.0-1.66.1.13.0.el6.x86_64
查找jdk安裝路徑,配置環境變量
[root@minion ~]# rpm -ql java-1.7.0-openjdk-1.7.0.45-2.4.3.3.el6.x86_64
/etc/.java
/etc/.java/.systemPrefs
/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.45.x86_64/jre/lib/amd64/libsaproc.so
/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.45.x86_64/jre/lib/amd64/libsctp.so
/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.45.x86_64/jre/lib/amd64/libsplashscreen.so
/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.45.x86_64/jre/lib/amd64/libunpack.so
/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.45.x86_64/jre/lib/amd64/libverify.so
/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.45.x86_64/jre/lib/amd64/libzip.soweb
設置環境變量
vim /etc/profile
#set java environment
JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.45.x86_64
JRE_HOME=$JAVA_HOME/jre
CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
export JAVA_HOME JRE_HOME CLASS_PATH PATHapache
讓修改生效
[root@localhost java]# source /etc/profilevim
修改tomcat配置文件,而後把開發的代碼放到/usr/local/tomcat/ROOT下
vim /etc/tomcat/server.xml 瀏覽器
<Host name="localhost" appBase="/usr/local/tomcat"
unpackWARs="true" autoDeploy="true">
mkdir /usr/local/tomcat/ROOT -p
vim index.jsp
Hello,tomcat home! The time is <%= new java.util.Date() %>tomcat
啓動apache服務
service tomcat start服務器
瀏覽器訪問
http://192.168.56.21:8080/app
++++++++++++++++++++++++++++++++++++++++++++
不用yum安裝,能夠源碼安裝
Tomcat/8.5.24webapp
useradd -u 601 tomcat
passwd tomcat
密碼也是tomcat
cd /usr/local/share
wget http://mirrors.hust.edu.cn/apache/tomcat/tomcat-8/v8.5.24/bin/apache-tomcat-8.5.24.tar.gz
tar -zxvf apache-tomcat-8.5.24.tar.gz
啓動tomcat
/usr/local/share/apache-tomcat-8.5.24/bin/startup.sh
關閉tomcat
/usr/local/share/apache-tomcat-8.5.24/bin/shutdown.sh
查看啓動日誌
/usr/local/share/apache-tomcat-8.5.24/logs/catalina.out
訪問tomcat
192.168.56.20:8080
修改配置文件位置
vim /usr/local/share/apache-tomcat-8.5.24/conf/server.xml
配置用戶名和密碼用於登陸管理界面
vim /usr/local/share/apache-tomcat-8.5.24/conf/tomcat-users.xml
<role rolename="manager-gui"/>
<role rolename="admin-gui"/>
<user username="admin" password="admin" roles="admin-gui,manager-gui" />
重啓服務器,刷新訪問的瀏覽器便可訪問管理頁面
優化vim /usr/local/share/apache-tomcat-8.5.24/conf/server.xml一、關閉8005端口否則能夠經過telnet 關閉tomcat二、關閉8009端口不進行AJP調用(nginx通常用http,不用AJP)三、更改webapp位置到tomcat之外的地方四、tomcat用tomcat用戶啓動,不用root啓動