Java應用伺服器之tomcat部署 - IT人
文章推薦指數: 80 %
一、相關術語簡介首先我們來了解下tomcat是什麼,tomcat是apache軟體基金會中的一個專案,由apache、Sun 和其他一些公司及個人共同開發而成。
Togglenavigation
IT人
IT人
Java應用伺服器之tomcat部署
1874發表於
2020-07-15
Java
Tomcat
一、相關術語簡介
首先我們來了解下tomcat是什麼,tomcat是apache軟體基金會中的一個專案,由apache、Sun和其他一些公司及個人共同開發而成。
主要作用是提供servlet和jsp類庫;tomcat是一個免費開源的web伺服器,它和nginx、httpd服務不同的是,它不擅長處理HTML程式碼,更多的是處理JSP程式;有點類似fpm服務專門處理php程式;
jdk:java開發工具箱(JavaDevelopmentKit ),主要提供java開發相關工具包,庫檔案以及jre和jvm相關元件,可以理解為java程式語言的一個基礎標準庫環境相關元件包和開發公具相關元件。
jre:java執行時環境(Javaruntimeenvironment),該軟體主要提供執行Java程式的環境;我們可以理解jre就是jvm和一些標準類庫組成的一個Java程式執行環境;
提示:從上面的圖可以瞭解到JDK包含JRE,JRE包含jvm;
jvm:Java虛擬機器(Javavirtualmachine)主要作用是讓Java程式實現跨平臺,我們可以理解Java虛擬機器的作用就是在轉換不同作業系統底層的API;這樣一來Java程式設計師就直接面向jvm提供的API進行程式設計,從而不用考慮其他作業系統底層API的不同;如下圖
提示:從上圖就可以瞭解到jvm的重要性,它可以實現程式設計師一次編碼,到處執行,正是jvm解決了底層作業系統不同API問題,使得java程式可以在任何具有jvm的裝置上執行;
二、JDK安裝
1、oraclejdk安裝
oraclejdk是oracle官方提供的一個jdk,安裝我們可以直接去官方下載對應版本的包,到本地伺服器即可;官方下載地址https://www.oracle.com/cn/java/technologies/javase-downloads.html;
提示:我這裡是提前下載好了的,上面官方地址還需要註冊挺麻煩的;下載好rpm,然後直接使用yum安裝即可
[[email protected]java]#yuminstall./jdk-8u211-linux-x64.rpm
Loadedplugins:fastestmirror
Examining./jdk-8u211-linux-x64.rpm:2000:jdk1.8-1.8.0_211-fcs.x86_64
Marking./jdk-8u211-linux-x64.rpmtobeinstalled
ResolvingDependencies
-->Runningtransactioncheck
--->Packagejdk1.8.x86_642000:1.8.0_211-fcswillbeinstalled
-->FinishedDependencyResolution
DependenciesResolved
====================================================================================================
PackageArchVersionRepositorySize
====================================================================================================
Installing:
jdk1.8x86_642000:1.8.0_211-fcs/jdk-8u211-linux-x64297M
TransactionSummary
====================================================================================================
Install1Package
Totalsize:297M
Installedsize:297M
Isthisok[y/d/N]:y
Downloadingpackages:
Runningtransactioncheck
Runningtransactiontest
Transactiontestsucceeded
Runningtransaction
Installing:2000:jdk1.8-1.8.0_211-fcs.x86_641/1
UnpackingJARfiles...
tools.jar...
plugin.jar...
javaws.jar...
deploy.jar...
rt.jar...
jsse.jar...
charsets.jar...
localedata.jar...
Verifying:2000:jdk1.8-1.8.0_211-fcs.x86_641/1
Installed:
jdk1.8.x86_642000:1.8.0_211-fcs
Complete!
[[email protected]java]#
提示:當然直接使用rpm-ivh也是可以直接安裝的,這個jdk幾乎沒有依賴關係,所以可以直接通過rpm安裝;通常有依賴關係的包建議還是使用yum去解決依賴關係;
檢視jdk-8u211-linux-x64.rpm生成的檔案
[[email protected]java]#rpm-qpi./jdk-8u211-linux-x64.rpm
warning:./jdk-8u211-linux-x64.rpm:HeaderV3RSA/SHA256Signature,keyIDec551f03:NOKEY
Name:jdk1.8
Epoch:2000
Version:1.8.0_211
Release:fcs
Architecture:x86_64
InstallDate:(notinstalled)
Group:Development/Tools
Size:311820630
License:https://java.com/bc_license
Signature:RSA/SHA256,Tue02Apr201912:06:57AMEDT,KeyID72f97b74ec551f03
SourceRPM:jdk1.8-1.8.0_211-fcs.src.rpm
BuildDate:Mon01Apr201911:55:52PMEDT
BuildHost:java.com
Relocations:/usr/java
Vendor:OracleCorporation
URL:http://www.oracle.com/technetwork/java/javase/overview/index.html
Summary:JavaPlatformStandardEditionDevelopmentKit
Description:
TheJavaPlatformStandardEditionDevelopmentKit(JDK)includesboth
theruntimeenvironment(Javavirtualmachine,theJavaplatformclasses
andsupportingfiles)anddevelopmenttools(compilers,debuggers,
toollibrariesandothertools).
TheJDKisadevelopmentenvironmentforbuildingapplications,applets
andcomponentsthatcanbedeployedwiththeJavaPlatformStandard
EditionRuntimeEnvironment.
[[email protected]java]#rpm-qljdk1.8
/usr
/usr/java
/usr/java/jdk1.8.0_211-amd64
/usr/java/jdk1.8.0_211-amd64/.java
/usr/java/jdk1.8.0_211-amd64/.java/.systemPrefs
/usr/java/jdk1.8.0_211-amd64/.java/.systemPrefs/.system.lock
/usr/java/jdk1.8.0_211-amd64/.java/.systemPrefs/.systemRootModFile
/usr/java/jdk1.8.0_211-amd64/.java/init.d
/usr/java/jdk1.8.0_211-amd64/.java/init.d/jexec
/usr/java/jdk1.8.0_211-amd64/COPYRIGHT
/usr/java/jdk1.8.0_211-amd64/LICENSE
/usr/java/jdk1.8.0_211-amd64/README.html
/usr/java/jdk1.8.0_211-amd64/THIRDPARTYLICENSEREADME-JAVAFX.txt
/usr/java/jdk1.8.0_211-amd64/THIRDPARTYLICENSEREADME.txt
/usr/java/jdk1.8.0_211-amd64/bin
/usr/java/jdk1.8.0_211-amd64/bin/ControlPanel
/usr/java/jdk1.8.0_211-amd64/bin/appletviewer
/usr/java/jdk1.8.0_211-amd64/bin/extcheck
……省略部分內容
提示:下載好的rpm包安裝後,如果要查詢其對應安裝了那些檔案,我們首先要知道它的名稱是什麼,用rpm-qpi命令可以檢視到對應名稱,然後我們再通過rpm-ql檢視對應名稱的軟體安裝生成了那些檔案;從上面的資訊可以看到jdk1.8生成的檔案都在/usr/java/目錄下;
提示:從上面的截圖可以瞭解到在/usr/java/目錄下有兩個軟連線,default預設指向了latest這個軟連線,latest軟連線指向了jdk1.8;這意味著jdk可以同時存在多個版本,我們只需要把對應軟連線修改了即可更新到新的版本;這裡需要提醒下,如果多版本並存的情況,我們可以使用alternatives工具來切換;
alternatives工具多版本相互切換
切換前,預設使用1.8.0.211版本
[[email protected]java]#alternatives--configjava
Thereis1programthatprovides'java'.
SelectionCommand
-----------------------------------------------
*+1/usr/java/jdk1.8.0_211-amd64/jre/bin/java
Entertokeepthecurrentselection[+],ortypeselectionnumber:1
[[email protected]java]#alternatives--install/usr/bin/javajava/usr/java/jdk1.7.0_79/bin/java2
[[email protected]java]#alternatives--configjava
Thereare2programswhichprovide'java'.
SelectionCommand
-----------------------------------------------
*+1/usr/java/jdk1.8.0_211-amd64/jre/bin/java
2/usr/java/jdk1.7.0_79/bin/java
Entertokeepthecurrentselection[+],ortypeselectionnumber:2
[[email protected]java]#java-version
javaversion"1.7.0_79"
Java(TM)SERuntimeEnvironment(build1.7.0_79-b15)
JavaHotSpot(TM)64-BitServerVM(build24.79-b02,mixedmode)
[[email protected]java]#alternatives--configjava
Thereare2programswhichprovide'java'.
SelectionCommand
-----------------------------------------------
*1/usr/java/jdk1.8.0_211-amd64/jre/bin/java
+2/usr/java/jdk1.7.0_79/bin/java
Entertokeepthecurrentselection[+],ortypeselectionnumber:1
[[email protected]java]#java-version
javaversion"1.8.0_211"
Java(TM)SERuntimeEnvironment(build1.8.0_211-b12)
JavaHotSpot(TM)64-BitServerVM(build25.211-b12,mixedmode)
[[email protected]java]#
提示:可以看到可以根據自己需要來回切換jdk的版本;到此oraclejdk的安裝就完成了;
2、openjdk安裝
[[email protected]_node01~]#yuminstalljava-1.8.0-openjdk
Loadedplugins:fastestmirror
base|3.6kB00:00:00
docker-ce-stable|3.5kB00:00:00
epel|4.7kB00:00:00
extras|2.9kB00:00:00
updates|2.9kB00:00:00
(1/4):epel/x86_64/updateinfo|1.0MB00:00:00
(2/4):extras/7/x86_64/primary_db|205kB00:00:00
(3/4):updates/7/x86_64/primary_db|3.0MB00:00:01
(4/4):epel/x86_64/primary_db|6.8MB00:00:01
Loadingmirrorspeedsfromcachedhostfile
*base:mirror.bit.edu.cn
*extras:mirror.bit.edu.cn
*updates:mirror.bit.edu.cn
ResolvingDependencies
-->Runningtransactioncheck
--->Packagejava-1.8.0-openjdk.x86_641:1.8.0.252.b09-2.el7_8willbeinstalled
-->ProcessingDependency:java-1.8.0-openjdk-headless(x86-64)=1:1.8.0.252.b09-2.el7_8forpackage:1:java-1.8.0-openjdk-1.8.0.252.b09-2.el7_8.x86_64
-->ProcessingDependency:xorg-x11-fonts-Type1forpackage:1:java-1.8.0-openjdk-1.8.0.252.b09-2.el7_8.x86_64
-->ProcessingDependency:libjvm.so(SUNWprivate_1.1)(64bit)forpackage:1:java-1.8.0-openjdk-1.8.0.252.b09-2.el7_8.x86_64
……省略部分內容
Installed:
java-1.8.0-openjdk.x86_641:1.8.0.252.b09-2.el7_8
DependencyInstalled:
atk.x86_640:2.28.1-2.el7
cairo.x86_640:1.15.12-4.el7
copy-jdk-configs.noarch0:3.3-10.el7_5
cups-libs.x86_641:1.6.3-43.el7
fribidi.x86_640:1.0.2-1.el7_7.1
gdk-pixbuf2.x86_640:2.36.12-3.el7
giflib.x86_640:4.1.6-9.el7
graphite2.x86_640:1.3.10-1.el7_3
gtk-update-icon-cache.x86_640:3.22.30-5.el7
gtk2.x86_640:2.24.31-1.el7
harfbuzz.x86_640:1.7.5-2.el7
hicolor-icon-theme.noarch0:0.12-7.el7
jasper-libs.x86_640:1.900.1-33.el7
java-1.8.0-openjdk-headless.x86_641:1.8.0.252.b09-2.el7_8
javapackages-tools.noarch0:3.4.1-11.el7
jbigkit-libs.x86_640:2.0-11.el7
libICE.x86_640:1.0.9-9.el7
libSM.x86_640:1.2.2-2.el7
libXcomposite.x86_640:0.4.4-4.1.el7
libXcursor.x86_640:1.1.15-1.el7
libXdamage.x86_640:1.1.4-4.1.el7
libXext.x86_640:1.3.3-3.el7
libXfixes.x86_640:5.0.3-1.el7
libXft.x86_640:2.3.2-2.el7
libXi.x86_640:1.7.9-1.el7
libXinerama.x86_640:1.1.3-2.1.el7
libXrandr.x86_640:1.5.1-2.el7
libXrender.x86_640:0.9.10-1.el7
libXtst.x86_640:1.2.3-1.el7
libXxf86vm.x86_640:1.1.4-1.el7
libfontenc.x86_640:1.1.3-3.el7
libglvnd.x86_641:1.0.1-0.8.git5baa1e5.el7
libglvnd-egl.x86_641:1.0.1-0.8.git5baa1e5.el7
libglvnd-glx.x86_641:1.0.1-0.8.git5baa1e5.el7
libthai.x86_640:0.1.14-9.el7
libtiff.x86_640:4.0.3-32.el7
libwayland-client.x86_640:1.15.0-1.el7
libwayland-server.x86_640:1.15.0-1.el7
libxshmfence.x86_640:1.2-1.el7
lksctp-tools.x86_640:1.0.17-2.el7
mesa-libEGL.x86_640:18.3.4-7.el7_8.1
mesa-libGL.x86_640:18.3.4-7.el7_8.1
mesa-libgbm.x86_640:18.3.4-7.el7_8.1
mesa-libglapi.x86_640:18.3.4-7.el7_8.1
pango.x86_640:1.42.4-4.el7_7
pcsc-lite-libs.x86_640:1.8.8-8.el7
pixman.x86_640:0.34.0-1.el7
python-javapackages.noarch0:3.4.1-11.el7
python-lxml.x86_640:3.2.1-4.el7
ttmkfdir.x86_640:3.0.9-42.el7
tzdata-java.noarch0:2020a-1.el7
xorg-x11-font-utils.x86_641:7.5-21.el7
xorg-x11-fonts-Type1.noarch0:7.5-9.el7
DependencyUpdated:
glib2.x86_640:2.56.1-5.el7libdrm.x86_640:2.4.97-2.el7
Complete!
[[email protected]_node01~]#
提示:安裝openjdk使用yum安裝需要注意命名,通常是java-版本號-openjdk;到此openjdk就安裝好了,後續的版本切換也可以使用alternatives命令來切換即可和oraclejdk使用沒有特別的不同;除了以上方式安裝,當然我們也可以去下載二進位制包,直接展開就可以,二進位制包安裝需要注意建立環境變數檔案;好了安裝jdk就不過多闡述了;接下來我們就可以安裝tomcat了;
三、tomcat安裝
[[email protected]_node01~]#yuminfotomcat
Loadedplugins:fastestmirror
Loadingmirrorspeedsfromcachedhostfile
*base:mirror.bit.edu.cn
*extras:mirror.bit.edu.cn
*updates:mirror.bit.edu.cn
AvailablePackages
Name:tomcat
Arch:noarch
Version:7.0.76
Release:12.el7_8
Size:92k
Repo:updates/7/x86_64
Summary:ApacheServlet/JSPEngine,RIforServlet3.0/JSP2.2API
URL:http://tomcat.apache.org/
License:ASL2.0
Description:TomcatistheservletcontainerthatisusedintheofficialReference
:ImplementationfortheJavaServletandJavaServerPagestechnologies.
:TheJavaServletandJavaServerPagesspecificationsaredevelopedby
:SunundertheJavaCommunityProcess.
:
:Tomcatisdevelopedinanopenandparticipatoryenvironmentand
:releasedundertheApacheSoftwareLicenseversion2.0.Tomcatisintended
:tobeacollaborationofthebest-of-breeddevelopersfromaroundtheworld.
[[email protected]_node01~]#
提示:可以看到在updates倉庫中有tomcat包,但是版本有點低,如果想要安裝新一點的包,可以去官網下載對應包安裝即可;官網地址:http://tomcat.apache.org/;
[[email protected]_node01~]#yuminstalltomcat-y
Loadedplugins:fastestmirror
Loadingmirrorspeedsfromcachedhostfile
*base:mirror.bit.edu.cn
*extras:mirror.bit.edu.cn
*updates:mirror.bit.edu.cn
ResolvingDependencies
-->Runningtransactioncheck
--->Packagetomcat.noarch0:7.0.76-12.el7_8willbeinstalled
-->ProcessingDependency:tomcat-lib=7.0.76-12.el7_8forpackage:tomcat-7.0.76-12.el7_8.noarch
-->ProcessingDependency:apache-commons-poolforpackage:tomcat-7.0.76-12.el7_8.noarch
-->ProcessingDependency:apache-commons-loggingforpackage:tomcat-7.0.76-12.el7_8.noarch
-->ProcessingDependency:apache-commons-dbcpforpackage:tomcat-7.0.76-12.el7_8.noarch
-->ProcessingDependency:apache-commons-daemonforpackage:tomcat-7.0.76-12.el7_8.noarch
-->ProcessingDependency:apache-commons-collectionsforpackage:tomcat-7.0.76-12.el7_8.noarch
-->Runningtransactioncheck
……省略部分內容
Installed:
tomcat.noarch0:7.0.76-12.el7_8
DependencyInstalled:
apache-commons-collections.noarch0:3.2.1-22.el7_2
apache-commons-daemon.x86_640:1.0.13-7.el7
apache-commons-dbcp.noarch0:1.4-17.el7
apache-commons-logging.noarch0:1.1.2-7.el7
apache-commons-pool.noarch0:1.6-9.el7
avalon-framework.noarch0:4.3-10.el7
avalon-logkit.noarch0:2.1-14.el7
ecj.x86_641:4.5.2-3.el7
geronimo-jms.noarch0:1.1.1-19.el7
geronimo-jta.noarch0:1.1.1-17.el7
javamail.noarch0:1.4.6-8.el7
log4j.noarch0:1.2.17-16.el7_4
tomcat-el-2.2-api.noarch0:7.0.76-12.el7_8
tomcat-jsp-2.2-api.noarch0:7.0.76-12.el7_8
tomcat-lib.noarch0:7.0.76-12.el7_8
tomcat-servlet-3.0-api.noarch0:7.0.76-12.el7_8
xalan-j2.noarch0:2.7.1-23.el7
xerces-j2.noarch0:2.11.0-17.el7_0
xml-commons-apis.noarch0:1.4.01-16.el7
xml-commons-resolver.noarch0:1.2-15.el7
Complete!
[[email protected]_node01~]#
檢視tomcat包安裝所生成的檔案
[[email protected]_node01~]#rpm-qltomcat
/etc/logrotate.d/tomcat
/etc/sysconfig/tomcat
/etc/tomcat
/etc/tomcat/Catalina
/etc/tomcat/Catalina/localhost
/etc/tomcat/catalina.policy
/etc/tomcat/catalina.properties
/etc/tomcat/conf.d
/etc/tomcat/conf.d/README
/etc/tomcat/context.xml
/etc/tomcat/log4j.properties
/etc/tomcat/logging.properties
/etc/tomcat/server.xml
/etc/tomcat/tomcat-users.xml
/etc/tomcat/tomcat.conf
/etc/tomcat/web.xml
/usr/bin/tomcat-digest
/usr/bin/tomcat-tool-wrapper
/usr/lib/systemd/system/tomcat.service
/usr/lib/systemd/system/[email protected]
/usr/libexec/tomcat
/usr/libexec/tomcat/functions
/usr/libexec/tomcat/preamble
/usr/libexec/tomcat/server
/usr/sbin/tomcat
/usr/share/doc/tomcat-7.0.76
/usr/share/doc/tomcat-7.0.76/LICENSE
/usr/share/doc/tomcat-7.0.76/NOTICE
/usr/share/doc/tomcat-7.0.76/RELEASE-NOTES
/usr/share/tomcat
/usr/share/tomcat/bin/bootstrap.jar
/usr/share/tomcat/bin/catalina-tasks.xml
/usr/share/tomcat/conf
/usr/share/tomcat/lib
/usr/share/tomcat/logs
/usr/share/tomcat/temp
/usr/share/tomcat/webapps
/usr/share/tomcat/work
/var/cache/tomcat
/var/cache/tomcat/temp
/var/cache/tomcat/work
/var/lib/tomcat
/var/lib/tomcat/webapps
/var/lib/tomcats
/var/log/tomcat
/var/log/tomcat/catalina.out
[[email protected]_node01~]#
提示:/etc/tomcat/是tomcat的配置檔案目錄,存放tomcat配置相關檔案;/usr/lib/systemd/system/tomcat.service是tomcat的unitfile啟動指令碼;/var/log/tomcat/catalina.out是tomcat的日誌檔案;
啟動tomcat
提示:tomcat預設監聽在tcp的8080埠;
測試:用瀏覽器訪問對應伺服器上的8080埠,看看是否訪問到tomcat的預設提供的頁面?
提示:可以看到用瀏覽器展示訪問不到對應頁面,提示我們404;這說明我們訪問的頁面不存在,原因是我們只安裝了tomcat的程式包,並沒有安裝任何webapp,所以對應目錄下都沒有頁面存在,所以我們現在訪問提示我們404;
提示:對應目錄下並沒有任何的頁面,所以我們訪問時訪問不到的;
安裝tomcat-webapps、tomcat-docs-webapp、tomcat-admin-webapps
[[email protected]_node01~]#yuminstall-ytomcat-webappstomcat-admin-webappstomcat-docs-webapp
Loadedplugins:fastestmirror
Loadingmirrorspeedsfromcachedhostfile
*base:mirror.bit.edu.cn
*extras:mirror.bit.edu.cn
*updates:mirror.bit.edu.cn
ResolvingDependencies
-->Runningtransactioncheck
--->Packagetomcat-admin-webapps.noarch0:7.0.76-12.el7_8willbeinstalled
--->Packagetomcat-docs-webapp.noarch0:7.0.76-12.el7_8willbeinstalled
--->Packagetomcat-webapps.noarch0:7.0.76-12.el7_8willbeinstalled
-->ProcessingDependency:jakarta-taglibs-standard>=1.1forpackage:tomcat-webapps-7.0.76-12.el7_8.noarch
-->Runningtransactioncheck
--->Packagejakarta-taglibs-standard.noarch0:1.1.2-14.el7_1willbeinstalled
-->FinishedDependencyResolution
DependenciesResolved
====================================================================================================
PackageArchVersionRepositorySize
====================================================================================================
Installing:
tomcat-admin-webappsnoarch7.0.76-12.el7_8updates40k
tomcat-docs-webappnoarch7.0.76-12.el7_8updates721k
tomcat-webappsnoarch7.0.76-12.el7_8updates341k
Installingfordependencies:
jakarta-taglibs-standardnoarch1.1.2-14.el7_1base303k
TransactionSummary
====================================================================================================
Install3Packages(+1Dependentpackage)
Totaldownloadsize:1.4M
Installedsize:5.4M
Downloadingpackages:
(1/4):jakarta-taglibs-standard-1.1.2-14.el7_1.noarch.rpm|303kB00:00:00
(2/4):tomcat-admin-webapps-7.0.76-12.el7_8.noarch.rpm|40kB00:00:00
(3/4):tomcat-webapps-7.0.76-12.el7_8.noarch.rpm|341kB00:00:00
(4/4):tomcat-docs-webapp-7.0.76-12.el7_8.noarch.rpm|721kB00:00:00
----------------------------------------------------------------------------------------------------
Total2.7MB/s|1.4MB00:00:00
Runningtransactioncheck
Runningtransactiontest
Transactiontestsucceeded
Runningtransaction
Installing:jakarta-taglibs-standard-1.1.2-14.el7_1.noarch1/4
Installing:tomcat-webapps-7.0.76-12.el7_8.noarch2/4
Installing:tomcat-docs-webapp-7.0.76-12.el7_8.noarch3/4
Installing:tomcat-admin-webapps-7.0.76-12.el7_8.noarch4/4
Verifying:tomcat-admin-webapps-7.0.76-12.el7_8.noarch1/4
Verifying:jakarta-taglibs-standard-1.1.2-14.el7_1.noarch2/4
Verifying:tomcat-webapps-7.0.76-12.el7_8.noarch3/4
Verifying:tomcat-docs-webapp-7.0.76-12.el7_8.noarch4/4
Installed:
tomcat-admin-webapps.noarch0:7.0.76-12.el7_8tomcat-docs-webapp.noarch0:7.0.76-12.el7_8
tomcat-webapps.noarch0:7.0.76-12.el7_8
DependencyInstalled:
jakarta-taglibs-standard.noarch0:1.1.2-14.el7_1
Complete!
[[email protected]_node01~]#
檢視/usr/shar/tomcat/webapps/下是否有檔案?
提示:可以看到在/usr/share/tomcat/webapps/下已經有檔案生成了,接下來我們再用瀏覽器訪問下8080埠,看看是否能夠訪問到頁面呢?
提示:可以看到我們能夠正常訪問到頁面,說明tomcat環境搭建已經完成;後續我們就可以把java開發的一些jsp程式部署到tomcat上使用了;
官方下載tomcat部署
[[email protected]java]#wgethttps://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-8/v8.5.57/bin/apache-tomcat-8.5.57.tar.gz
--2020-07-1413:09:04--https://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-8/v8.5.57/bin/apache-tomcat-8.5.57.tar.gz
Resolvingmirrors.tuna.tsinghua.edu.cn(mirrors.tuna.tsinghua.edu.cn)...101.6.8.193,2402:f000:1:408:8100::1
Connectingtomirrors.tuna.tsinghua.edu.cn(mirrors.tuna.tsinghua.edu.cn)|101.6.8.193|:443...connected.
HTTPrequestsent,awaitingresponse...200OK
Length:10379806(9.9M)[application/octet-stream]
Savingto:‘apache-tomcat-8.5.57.tar.gz’
100%[==========================================================>]10,379,8061.90MB/sin5.2s
2020-07-1413:09:10(1.90MB/s)-‘apache-tomcat-8.5.57.tar.gz’saved[10379806/10379806]
[[email protected]java]#ls
apache-tomcat-8.5.57.tar.gzjdk-7u79-linux-x64.rpmjdk-8u211-linux-x64.rpm
[[email protected]java]#
提示:官方預設只提供了二進位制包和原始碼包,沒有rpm包,所以我們下載二進位制包解壓到對應目錄即可;
[[email protected]java]#mkdir/usr/share/tomcat
[[email protected]java]#tarxfapache-tomcat-8.5.57.tar.gz-C/usr/share/tomcat
[[email protected]java]#cd/usr/share/tomcat
[[email protected]tomcat]#ls
apache-tomcat-8.5.57
[[email protected]tomcat]#
建立軟連線
[[email protected]tomcat]#ln-sapache-tomcat-8.5.57tomcat
[[email protected]tomcat]#ll
total0
drwxr-xr-x9rootroot220Jul1413:10apache-tomcat-8.5.57
lrwxrwxrwx1rootroot20Jul1413:12tomcat->apache-tomcat-8.5.57
[[email protected]tomcat]#
建立tomcat使用者
[[email protected]tomcat]#useradd-rtomcat
[[email protected]tomcat]#getentpasswdtomcat
tomcat:x:996:992::/home/tomcat:/bin/bash
[[email protected]tomcat]#
更改/usr/share/tomcat/tomcat屬主/組許可權為tomcat
[[email protected]tomcat]#ll
total124
drwxr-x---2rootroot4096Jul1413:10bin
-rw-r-----1rootroot19318Jun3017:53BUILDING.txt
drwx------2rootroot238Jun3017:53conf
-rw-r-----1rootroot5408Jun3017:53CONTRIBUTING.md
drwxr-x---2rootroot4096Jul1413:10lib
-rw-r-----1rootroot57011Jun3017:53LICENSE
drwxr-x---2rootroot6Jun3017:49logs
-rw-r-----1rootroot1726Jun3017:53NOTICE
-rw-r-----1rootroot3255Jun3017:53README.md
-rw-r-----1rootroot7136Jun3017:53RELEASE-NOTES
-rw-r-----1rootroot16262Jun3017:53RUNNING.txt
drwxr-x---2rootroot30Jul1413:10temp
drwxr-x---7rootroot81Jun3017:50webapps
drwxr-x---2rootroot6Jun3017:49work
[[email protected]tomcat]#chown-Rtomcat:tomcat./*
[[email protected]tomcat]#ll
total124
drwxr-x---2tomcattomcat4096Jul1413:10bin
-rw-r-----1tomcattomcat19318Jun3017:53BUILDING.txt
drwx------2tomcattomcat238Jun3017:53conf
-rw-r-----1tomcattomcat5408Jun3017:53CONTRIBUTING.md
drwxr-x---2tomcattomcat4096Jul1413:10lib
-rw-r-----1tomcattomcat57011Jun3017:53LICENSE
drwxr-x---2tomcattomcat6Jun3017:49logs
-rw-r-----1tomcattomcat1726Jun3017:53NOTICE
-rw-r-----1tomcattomcat3255Jun3017:53README.md
-rw-r-----1tomcattomcat7136Jun3017:53RELEASE-NOTES
-rw-r-----1tomcattomcat16262Jun3017:53RUNNING.txt
drwxr-x---2tomcattomcat30Jul1413:10temp
drwxr-x---7tomcattomcat81Jun3017:50webapps
drwxr-x---2tomcattomcat6Jun3017:49work
[[email protected]tomcat]#
新增環境變數
[[email protected]tomcat]#cat/etc/profile.d/tomcat.sh
CATALINA_BASE=/usr/share/tomcat/tomcat
PATH=$CATALINA_BASE/bin:$PATH
exportCATALINA_BASEPATH
[[email protected]tomcat]#
切換tomcat使用者啟動tomcat
[[email protected]tomcat]#su-tomcat
Lastlogin:TueJul1413:26:15EDT2020onpts/0
su:warning:cannotchangedirectoryto/home/tomcat:Nosuchfileordirectory
-bash-4.2$catalina.sh--help
UsingCATALINA_BASE:/usr/share/tomcat/tomcat
UsingCATALINA_HOME:/usr/share/tomcat/tomcat
UsingCATALINA_TMPDIR:/usr/share/tomcat/tomcat/temp
UsingJRE_HOME:/
UsingCLASSPATH:/usr/share/tomcat/tomcat/bin/bootstrap.jar:/usr/share/tomcat/tomcat/bin/tomcat-juli.jar
Usage:catalina.sh(commands...)
commands:
debugStartCatalinainadebugger
debug-securityDebugCatalinawithasecuritymanager
jpdastartStartCatalinaunderJPDAdebugger
runStartCatalinainthecurrentwindow
run-securityStartinthecurrentwindowwithsecuritymanager
startStartCatalinainaseparatewindow
start-securityStartinaseparatewindowwithsecuritymanager
stopStopCatalina,waitingupto5secondsfortheprocesstoend
stopnStopCatalina,waitinguptonsecondsfortheprocesstoend
stop-forceStopCatalina,waitupto5secondsandthenusekill-KILLifstillrunning
stopn-forceStopCatalina,waituptonsecondsandthenusekill-KILLifstillrunning
configtestRunabasicsyntaxcheckonserver.xml-checkexitcodeforresult
versionWhatversionoftomcatareyourunning?
Note:Waitingfortheprocesstoendanduseofthe-forceoptionrequirethat$CATALINA_PIDisdefined
-bash-4.2$catalina.shstart
UsingCATALINA_BASE:/usr/share/tomcat/tomcat
UsingCATALINA_HOME:/usr/share/tomcat/tomcat
UsingCATALINA_TMPDIR:/usr/share/tomcat/tomcat/temp
UsingJRE_HOME:/
UsingCLASSPATH:/usr/share/tomcat/tomcat/bin/bootstrap.jar:/usr/share/tomcat/tomcat/bin/tomcat-juli.jar
Tomcatstarted.
-bash-4.2$ss-tnl
StateRecv-QSend-QLocalAddress:PortPeerAddress:Port
LISTEN0128*:6033*:*
LISTEN0128*:22*:*
LISTEN0100127.0.0.1:25*:*
LISTEN0128*:3306*:*
LISTEN0128*:3306*:*
LISTEN0128*:3306*:*
LISTEN0128*:3306*:*
LISTEN0100:::8080:::*
LISTEN0128:::22:::*
LISTEN0100::1:25:::*
LISTEN01::ffff:127.0.0.1:8005:::*
LISTEN0128:::2377:::*
LISTEN0128:::7946:::*
-bash-4.2$
提示:啟動tomcat要使用內部的shell指令碼catalina.sh來啟動;當然startup.sh也是可以的;可以看到8080埠已經處於監聽的狀態,接下來我們用瀏覽器嘗試訪問下,看看是否能夠訪問到頁面?
提示:可以看到tomcat提供的頁面我們是能夠正常訪問,說明我們安裝部署的tomcat環境就準備就緒了;到此tomcat環境安裝就部署完畢了;總結一點,部署tomcat環境,首先要安裝jdk,因為tomcat本身就是java語言編寫,我們要在伺服器上安裝好java程式執行環境和標準類庫等元件,tomcat才可以伺服器上正常的執行起來;其實從上面的演示我們大概也能知道tomcat就是為Javajsp程式提供一個執行環境,後續的jsp程式碼主要就是在tomcat上執行,而非jdk上;jdk是執行Java程式(tomcat)而必須有的元件;後續本人會持續更新有關tomcat配置使用相關的話題,感興趣的同學可以關注關注;
相關文章
SQOOP安裝部署
2020-11-22
Java泛型詳解
2020-11-22
Java
vscode遠端連線伺服器進行嵌入式開發
2020-11-22
VSCode嵌入式
Java動態代理—框架中的應用場景和基本原理
2020-11-22
Java框架
leetcode動態規劃買賣股票的最佳時機含手續費java
2020-11-22
JavaLeetCode
ThreadPoolExecutor原始碼分析-面試問爛了的Java執行緒池執行流程,如果要問你具體的執行細節,你還會嗎?
2020-11-22
Java面試
流程控制與陣列—Java基礎學習(二)
2020-11-22
Java
Scala與Java差異(五)之Map與Tuple
2020-11-22
Java
Java之定時任務全家桶
2020-11-22
Java
靠這份面試手冊拿下京東的Java研發崗的offer,萬分感謝特此分享
2020-11-22
Java面試
leetcode【每日一題】242.有效的字母異位詞java
2020-11-22
JavaLeetCode
HeadFirstJava學習筆記(7):繼承與多型
2020-11-22
Java
Java學生管理系統(MVC)開源原始碼(基礎版)
2020-11-22
Java
JavaScript正則學習筆記
2020-11-22
JavaScript
小白不懂就問,學自動化測試,會Java可以嗎,還是必須得會python(python不太會)
2020-11-22
PythonJava自動化測試
JavaBean重寫Object類中的方法
2020-11-22
Java
基於Java的Socket類Tcp網路程式設計實現實時聊天互動程式(一):QQ聊天介面的搭建
2020-11-22
Java
java的序列化Serializable
2020-11-22
Java
k8s二進位制部署
2020-11-22
k8s
最新文章
一起看I/O|GooglePlay更新一覽
我使用SpringAOP實現了使用者操作日誌功能
7000字+24張圖帶你徹底弄懂執行緒池
[原始碼解析]TensorFlow分散式之ClusterCoordinator
密碼學之安全模型總結
熱力圖生成演算法及其具體實現
用Python畫個生日蛋糕為朋友慶生
SQL中常用的字串LEFT函式和RIGHT函式詳解!
萬字長文,帶你輕鬆學習Spark
開源軟體ZincSearch獲360萬美元風險投資
青雲雲原生沙龍線上集結,找到屬於你的雲原生實踐之路!
像寫部落格一樣寫程式碼,laf導致一個部門被裁
延伸文章資訊
- 1Java JSP架站- Tomcat Apache Eclipse 設定 - 進度條
1. 下載Eclipse · 2. 之後下載JAVA jdk · 3. 下載"Apache Tomcat" · 4. 設定Eclipse · 5. 安裝Tomcat Server · 6. 改變...
- 2安裝Java 與Apache Tomcat (Windows) - PTC Support
安裝Java 與Apache Tomcat (Windows). 1. 如果您要針對您的資料庫使用AzureSQL,請轉至使用Azure SQL Server 作為持續性提供者。執行該部份中的步...
- 3Apache Tomcat - 維基百科,自由的百科全書
Tomcat 6.x[編輯] · 符合Servlet 2.5和JSP 2.1規範 · 支援統一表達式語言2.1 · 設計執行在Java SE 5.0及以後版本上 · 通過CometProcess...
- 4Java應用伺服器之tomcat部署 - IT人
一、相關術語簡介首先我們來了解下tomcat是什麼,tomcat是apache軟體基金會中的一個專案,由apache、Sun 和其他一些公司及個人共同開發而成。
- 5Apache Tomcat® - Welcome!
The Jakarta EE platform is the evolution of the Java EE platform. Tomcat 10 and later implement s...