下載這個jdk-8u151-linux-x64.tar.gzhtml
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 JAVA_HOME=/usr/local/jdk1.8/ //JDK的主目錄 JAVA_BIN=/usr/local/jdk1.8/bin //JDK的主目錄下的bin目錄 JRE_HOME=/usr/local/jdk1.8/jre //JDK的主目錄下的jre目錄 PATH=$PATH:/usr/local/jdk1.8/bin:/usr/local/jdk1.8/jre/bin //添加JDK的bin目錄和jre的bin目錄到PATH中 CLASSPATH=/usr/local/jdk1.8/jre/lib:/usr/local/jdk1.8/lib:/usr/local/jdk1.8/jre/lib/charsets.jar //Java類文件的路徑
[root@aminglinux-01 local]# source /etc/profile [root@aminglinux-01 local]# java -version java version "1.8.0_151" Java(TM) SE Runtime Environment (build 1.8.0_151-b12) Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)
cd /usr/local/srcjava
[root@aminglinux-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@aminglinux-01 src]#
查看是否啓動成功,ps aux |grep tomcatmysql
關閉服務 /usr/local/tomcat/bin/shutdown.shlinux
[root@aminglinux-01 src]# netstat -lntp |grep java tcp6 0 0 :::8080 :::* LISTEN 5058/java tcp6 0 0 127.0.0.1:8005 :::* LISTEN 5058/java tcp6 0 0 :::8009 :::* LISTEN 5058/java
三個端口8080爲提供web服務的端口,8005爲管理端口,8009端口爲第三方服務調用的端口,好比httpd和Tomcat結合時會用到web
echo "/usr/local/tomcat/bin/startup.sh" >> /etc/rc.d/rc.localsql
chmod a+x /etc/rc.d/rc.local //默認該文件沒有x權限,因此須要加一下數據庫
搜索8080 ,找到apache
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
改爲80bootstrap
/usr/local/tomcat/bin/shutdown.shvim
/usr/local/tomcat/bin/startup.sh
[root@aminglinux-01 ~]# !net netstat -lntp |grep java tcp6 0 0 :::80 :::* LISTEN 2406/java tcp6 0 0 127.0.0.1:8005 :::* LISTEN 2406/java tcp6 0 0 :::8009 :::* LISTEN 2406/java
若是80端口被其餘服務佔用,先停掉佔用服務,而後重啓tomcat
搜到host
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true"> <!-- SingleSignOn valve, share authentication between web applications Documentation at: /docs/config/valve.html --> <!-- <Valve className="org.apache.catalina.authenticator.SingleSignOn" /> --> <!-- Access log processes all example. Documentation at: /docs/config/valve.html Note: The pattern used is equivalent to using pattern="common" --> <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log" suffix=".txt" pattern="%h %l %u %t "%r" %s %b" /> </Host>
appBase定義應用的目錄,Java的應用一般是一個war的壓縮包,你只須要將war的壓縮包放到appBase目錄下面便可。剛剛阿銘訪問的Tomcat默認頁其實就是在appBase目錄下面,不過是在它子目錄ROOT裏。
<Host name="www.123.cn" appBase="" unpackWARs= "true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false"> <Context path="" docBase="/data/wwwroot/123.cn/" debug="0" reloadable="true" crossContext="true"/> </Host>
上面的docBase,這個參數用來定義網站的文件存放路徑,若是不定義,默認是在appBase/ROOT下面,定義了docBase就以該目錄爲主了,其中appBase和docBase能夠同樣。在這一步操做過程當中不少同窗遇到過訪問404的問題,其實就是docBase沒有定義對。
appBase爲應用存放目錄,一般是須要把war包直接放到該目錄下面,它會自動解壓成一個程序目錄
檢查mysql 有沒有啓動 ps aux |grep mysql
進入mysql
建立一個叫zrlog的數據庫: create database zrlog;
建立用戶: grant all on zrlog.* to 'zrlog'@127.0.0.1 identified by 'aminglinux1';
檢查用戶是否建立,用新建用戶進入mysql,show databases;看下下面有沒有zrlog
[root@aminglinux-01 ~]# ls /usr/local/tomcat/logs/ catalina.2017-11-07.log host-manager.2017-11-07.log localhost_access_log.2017-11-07.txt catalina.out localhost.2017-11-07.log manager.2017-11-07.log [root@aminglinux-01 ~]#
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/1109263
JAR、WAR包區別 http://blog.csdn.net/lishehe/article/details/41607725
tomcat常見配置彙總 http://blog.sina.com.cn/s/blog_4ab26bdd0100gwpk.html
1 tomcat 單機多實例 http://www.ttlsa.com/tomcat/config-multi-tomcat-instance/
2 tomcat的jvm設置和鏈接數設置 http://www.cnblogs.com/bluestorm/archive/2013/04/23/3037392.html
3 jmx監控tomcat http://blog.csdn.net/l1028386804/article/details/51547408