16.1 Tomcat介紹
16.2 安裝jdk
16.3 安裝Tomcat
擴展
java容器比較 http://my.oschina.net/diedai/blog/271367
http://www.360doc.com/content/11/0618/21/16915_127901371.shtml
j2ee、j2se、ejb、javabean、serverlet、jsp之間關係 http://bbs.csdn.net/topics/50015576
tomcat server.xml配置詳解 http://blog.csdn.net/yuanxuegui2008/article/details/6056754
tomcat經常使用數據庫鏈接的方法 http://wjw7702.blog.51cto.com/5210820/1109263php
LNMP架構針對的開發語言是PHP語言,php 是一門開發web程序很是流行的語言,早些年流行的是asp,在Windows平臺上運行的一種編程語言,但安全性差,就網站開發人員就開始轉到php,並且php相對的比較安全html
java是一門比較龐大的開發語言,不只能夠開發建站,也能夠開發大型軟件工具和遊戲java
Tomcat介紹linux
JAVA_HOME=/usr/local/jdk1.8/ JAVA_BIN=/usr/local/jdk1.8/bin JRE_HOME=/usr/local/jdk1.8/jre PATH=$PATH:/usr/local/jdk1.8/bin:/usr/local/jdk1.8/jre/bin CLASSPATH=/usr/local/jdk1.8/jre/lib:/usr/local/jdk1.8/lib:/usr/local/jdk1.8/jre/lib/charsets.jar
安裝tomcat和jdk,首先須要安裝jdk,由於tomcat要想啓動,依賴於jdk的環境變量web
jdk版本目前有1.六、1.七、1.8,簡稱爲六、七、8數據庫
這裏使用的是JDK的1.8版本,官網地址 apache
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
用瀏覽器打開jdk的官網,而後將手動將jdk下載到windows上,打開官網後,首先點贊成 Accept License Agreement ,再選擇一個對應的版本,即 tar.gz 的(選擇的時候要看清本身的系統是多少位的,在centos6以前是區分32位或64位的,但在centos7中不在區分的,雖然有32位的版本,可是是基於64位的版本的基礎上編譯出來的,因此最終仍是一個64位的),因此再用centos7的系統,那下載的jdk版本確定是 x86 的編程
選擇以下版本,而後點擊下載bootstrap
下載好jdk後,在linux系統中切換到 /usr/local/src 目錄下 而且上傳上去vim
[root@yong-01 ~]# cd /usr/local/src/ [root@yong-01 src]# ls jdk-8u171-linux-x64.tar.gz jdk-8u171-linux-x64.tar.gz
[root@yong-01 src]# tar zxvf jdk-8u171-linux-x64.tar.gz [root@yong-01 src]# du -sh jdk1.8.0_171/ 374M jdk1.8.0_171/
[root@yong-01 src]# mv jdk1.8.0_171/ /usr/local/jdk1.8
[root@yong-01 src]# vim /etc/profile 在文件最下方加上如下配置,主要用於定義環境變量 JAVA_HOME=/usr/local/jdk1.8/ JAVA_BIN=/usr/local/jdk1.8/bin JRE_HOME=/usr/local/jdk1.8/jre PATH=$PATH:/usr/local/jdk1.8/bin:/usr/local/jdk1.8/jre/bin CLASSPATH=/usr/local/jdk1.8/jre/lib:/usr/local/jdk1.8/lib:/usr/local/jdk1.8/jre/lib/charsets.jar
[root@yong-01 src]# source /etc/profile
[root@yong-01 src]# java -version java version "1.8.0_171" Java(TM) SE Runtime Environment (build 1.8.0_171-b11) Java HotSpot(TM) 64-Bit Server VM (build 25.171-b11, mixed mode)
[root@yong-01 src]# wget https://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-8/v8.5.31/bin/apache-tomcat-8.5.31.tar.gz
[root@yong-01 src]# tar zxvf apache-tomcat-8.5.31.tar.gz [root@yong-01 src]# ls apache-tomcat-8.5.31 bin conf lib LICENSE logs NOTICE RELEASE-NOTES RUNNING.txt temp webapps work
[root@yong-01 src]# mv apache-tomcat-8.5.31 /usr/local/tomcat
[root@yong-01 src]# /usr/local/tomcat/bin/startup.sh Using CATALINA_BASE: /usr/local/tomcat Using CATALINA_HOME: /usr/local/tomcat Using CATALINA_TMPDIR: /usr/local/tomcat/temp Using JRE_HOME: /usr/local/jdk1.8 Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar Tomcat started.
[root@yong-01 src]# ps aux |grep java root 2586 12.5 4.4 2511904 83108 pts/1 Sl 23:24 0:02 /usr/local/jdk1.8/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Dorg.apache.catalina.security.SecurityListener.UMASK=0027 -Dignore.endorsed.dirs= -classpath /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar -Dcatalina.base=/usr/local/tomcat -Dcatalina.home=/usr/local/tomcat -Djava.io.tmpdir=/usr/local/tomcat/temp org.apache.catalina.startup.Bootstrap start root 2630 0.0 0.0 112676 984 pts/1 R+ 23:24 0:00 grep --color=auto java
[root@yong-01 src]# /usr/local/tomcat/bin/shutdown.sh Using CATALINA_BASE: /usr/local/tomcat Using CATALINA_HOME: /usr/local/tomcat Using CATALINA_TMPDIR: /usr/local/tomcat/temp Using JRE_HOME: /usr/local/jdk1.8 Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar [root@yong-01 src]# ps aux |grep java root 2662 0.0 0.0 112676 984 pts/1 R+ 23:25 0:00 grep --color=auto java
[root@yong-01 src]# /usr/local/tomcat/bin/startup.sh Using CATALINA_BASE: /usr/local/tomcat Using CATALINA_HOME: /usr/local/tomcat Using CATALINA_TMPDIR: /usr/local/tomcat/temp Using JRE_HOME: /usr/local/jdk1.8 Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar Tomcat started.
[root@yong-01 src]# netstat -lntp |grep java tcp6 0 0 :::8080 :::* LISTEN 2678/java tcp6 0 0 127.0.0.1:8005 :::* LISTEN 2678/java tcp6 0 0 :::8009 :::* LISTEN 2678/java
[root@yong-01 src]# systemctl stop firewalld [root@yong-01 src]# systemctl disable firewalld Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service. Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
打開以下的界面就是訪問成功了