新聞中心
Tomcat簡介
Tomcat(Apache Tomcat,簡稱TC)是一個開源的Web應(yīng)用服務(wù)器,它是Java Servlet和JavaServer Pages(JSP)技術(shù)的實現(xiàn)者,實現(xiàn)了對Servlet和JSP的支持,并提供了作為Web服務(wù)器的一些特性,如處理HTML文件,Tomcat采用MVC設(shè)計模式,可以處理動態(tài)網(wǎng)頁,是一種非常流行的Web服務(wù)器軟件。

成都創(chuàng)新互聯(lián)是一家專業(yè)提供防城港企業(yè)網(wǎng)站建設(shè),專注與成都網(wǎng)站設(shè)計、成都做網(wǎng)站、H5技術(shù)、小程序制作等業(yè)務(wù)。10年已為防城港眾多企業(yè)、政府機構(gòu)等服務(wù)。創(chuàng)新互聯(lián)專業(yè)網(wǎng)站建設(shè)公司優(yōu)惠進行中。
安裝前的準備工作
在安裝Tomcat之前,需要確保已經(jīng)安裝了以下軟件:
1、Java Development Kit(JDK):Tomcat是基于Java開發(fā)的,因此需要先安裝JDK,建議安裝JDK 8或更高版本。
2、Apache Maven:Maven是一個項目管理工具,可以幫助我們管理項目的依賴和構(gòu)建過程,雖然不是必須的,但建議安裝。
3、MySQL數(shù)據(jù)庫:Tomcat需要一個數(shù)據(jù)庫來存儲配置信息和會話數(shù)據(jù),推薦使用MySQL數(shù)據(jù)庫。
安裝步驟
以Windows系統(tǒng)為例,介紹如何安裝Tomcat。
1、下載Tomcat安裝包
訪問Tomcat官網(wǎng)(https://tomcat.apache.org/),選擇合適的版本進行下載,下載完成后,解壓縮到一個目錄中,C:tomcat。
2、配置環(huán)境變量
為了方便使用Tomcat命令行工具,需要配置環(huán)境變量,按照以下步驟操作:
在“計算機”->“屬性”->“高級系統(tǒng)設(shè)置”->“環(huán)境變量”中,新建一個名為“CATALINA_HOME”的系統(tǒng)變量,值設(shè)置為Tomcat解壓后的目錄,C:tomcat。
在“計算機”->“屬性”->“高級系統(tǒng)設(shè)置”->“環(huán)境變量”中,找到“Path”變量,點擊“編輯”,在變量值的最后添加“;%CATALINA_HOME%bin”。
3、安裝MySQL數(shù)據(jù)庫
訪問MySQL官網(wǎng)(https://www.mysql.com/),下載合適的版本進行安裝,安裝完成后,啟動MySQL服務(wù)。
4、修改MySQL配置文件
打開MySQL安裝目錄下的my.ini文件,找到[mysqld]部分,添加以下內(nèi)容:
skip-networking=false bind-address=127.0.0.1
保存文件并重啟MySQL服務(wù)。
5、創(chuàng)建數(shù)據(jù)庫和用戶
登錄MySQL,執(zhí)行以下命令創(chuàng)建一個名為“tomcat”的數(shù)據(jù)庫,并授權(quán)給一個用戶:
CREATE DATABASE tomcat; GRANT ALL PRIVILEGES ON tomcat.* TO 'root'@'localhost' IDENTIFIED BY 'your_password'; FLUSH PRIVILEGES;
6、下載并解壓Tomcat安裝包中的“webapps”文件夾到Tomcat的“webapps”目錄下,這個文件夾包含了一些示例應(yīng)用程序,可以直接運行,如果需要部署自己的應(yīng)用程序,可以將應(yīng)用程序打包成WAR文件,然后將其放到“webapps”目錄下。
7、啟動Tomcat
打開命令提示符,切換到Tomcat的“bin”目錄下,執(zhí)行以下命令啟動Tomcat:
startup.bat
如果看到類似如下的輸出,表示Tomcat已成功啟動:
Using CATALINA_BASE: C:tomcat Using CATALINA_HOME: C:tomcat Using CATALINA_TMPDIR: C:Usersyour_usernameAppDataLocalTemptomcat9440204002963843286web1144093561099186tmpdir Using JRE_HOME: C:Program FilesJavajdk1.8.0_281jre Starting Tomcat v9.0.50 on Windows NT (6.1.7601) version 10.0.1776. SP1 (Build 14393: KB4557265) with patch H28D8A06 for Windows XP Service Pack 3 (http://tomcat.apache.org/whichversion.html). Web application deployed as "/" using DefaultWebApplicationDescriptor provided by Tomcat at "C:tomcatconfweb.xml" with context root "/". Tomcat initialized with base URL '' and dynamic resource manager '' in APR/Native mode. The server default host is "localhost", and the server IP address is "127.0.0.1". The server is running in the UNIX domain [127.0.0.1]. The server was started at 23/03/2022 15:56:58 GMT by "root" with admin privileges via command line interface. Server version: Apache Tomcat/9.0.50 (Win64). Server built: Jun 29 2020 18:54 UTC, 2 months ago. Server number: 1 (based on list of configured servers with server().info()). Undertow HTTP/1.1 server [id=default-server]: Undertow configured for a throughput rate of 2048 requests/second(tps) and a maximum of 512 thread workers. Main buffer size is not configured explicitly;默認buffer size is defined dynamically. Using native worker implementation. Access log files are stored in "logs" directory. Default access log formats are "common" and "combined" including date/time information and tracking ID if available. Access log path is "logs" directory under "work" directory (current value is "C:tomcatlogs"). Using custom protocol to listen on port [::]:8080 instead of the default ["http"]. A request received on main thread [id=main, queue=main-event-queue] (http/1.1 [::1]) for first attempt to serve response for [/]. The request sent successfully back to the client browser, fulfilling the request of getting the information on this website. This will be the initial response sent to any GET requests made by the browser after this point in time (if any). The web application loaded within one second was [file:///C:/Users/your_username/Downloads/ROOT-INF/classes/org/apache/catalina/core/StandardContext.__context__], located at URL [http://localhost:8080/ROOT-INF/classes/org/apache/catalina/core/StandardContext.__context__]. Tomcat detected an additional resource blocking configuration '/ROOT-INF' which must be added to the list of resources allowed for protection against Cross Site Scripting attacks (see http://tomcat.apache.org/tomcat-7.0-doc/config/valves.htmlXMLValve). Tomcat encountered an error processing your request while trying to serve static content from the following location(s): [file:///C:/Users/your_username/Downloads/ROOT-INF/classes/org/apache/catalina/core/StandardContext.__context__]. An exception was thrown (Access Denied): org.apache.jasper.JasperException: java.lang.IllegalArgumentException: StandardContext XML declaration missing or malformed at line 36 in file: C:Usersyour_usernameDownloadsROOT-INFclassesorgapachecatalinacoreStandardContext.__context__ Line36 column95 Start tag open seen at column95 but not closed at line36 Unmatched end tag "". Total time taken for initialization is 3 seconds (JVM running for 7 seconds). Time taken for shutdown is 0 seconds (JVM shutting down). Any help would be greatly appreciated! Thank you very much!
網(wǎng)頁題目:Tomcat怎么安裝
標題URL:http://m.fisionsoft.com.cn/article/cceciic.html


咨詢
建站咨詢
