Tomcat下载地址 https://archive.apache.org/dist/tomcat/tomcat-7/ https://archive.apache.org/dist/tomcat/tomcat-8/
Tomcat与JDK版本之间的选择 http://tomcat.apache.org/whichversion.html
一、CentOS yum 安装
[root@centos7 ~]
Loaded plugins: fastestmirror
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
Determining fastest mirrors
Available Packages
tomcat.noarch 7.0.76-16.el7_9 updates
tomcat-admin-webapps.noarch 7.0.76-16.el7_9 updates
tomcat-docs-webapp.noarch 7.0.76-16.el7_9 updates
tomcat-el-2.2-api.noarch 7.0.76-16.el7_9 updates
tomcat-javadoc.noarch 7.0.76-16.el7_9 updates
tomcat-jsp-2.2-api.noarch 7.0.76-16.el7_9 updates
tomcat-jsvc.noarch 7.0.76-16.el7_9 updates
tomcat-lib.noarch 7.0.76-16.el7_9 updates
tomcat-native.x86_64 1.2.23-1.el7 epel
tomcat-servlet-3.0-api.noarch 7.0.76-16.el7_9 updates
tomcat-webapps.noarch 7.0.76-16.el7_9 updates
tomcatjss.noarch 7.2.5-1.el7 base
tomcat.noarch
tomcat-admin-webapps.noarch
tomcat-docs-webapp.noarch
tomcat-webapps.noarch
yum install -y tomcat tomcat-admin-webapps tomcat-docs-webapp tomcat-webapps
systemctl enable tomcat && systemctl restart tomcat && systemctl status tomcat
二、Ubuntu apt 安装
root@ubuntu1804:~
tomcat8 | 8.5.39-1ubuntu1~18.04.3 | https://mirrors.aliyun.com/ubuntu bionic-updates/universe amd64 Packages
tomcat8 | 8.5.39-1ubuntu1~18.04.3 | https://mirrors.aliyun.com/ubuntu bionic-security/universe amd64 Packages
tomcat8 | 8.5.30-1ubuntu1 | https://mirrors.aliyun.com/ubuntu bionic/universe amd64 Packages
apt install tomcat8
dpkg -L tomcat8
/.
/etc
/etc/cron.daily
/etc/cron.daily/tomcat8
/etc/init.d /etc/init.d/tomcat8
/etc/logrotate.d /etc/rsyslog.d
/etc/rsyslog.d/tomcat8.conf
/etc/tomcat8 /etc/tomcat8/Catalina
/etc/tomcat8/Catalina/localhost
/etc/tomcat8/catalina.properties
/etc/tomcat8/context.xml
/etc/tomcat8/jaspic-providers.xml
/etc/tomcat8/logging.properties
三、二进制部署
3.1 下载并解压压缩包
yum install -y java-1.8.0-openjdk
cd /apps
wget https://archive.apache.org/dist/tomcat/tomcat-8/v8.5.64/bin/apache-tomcat-8.5.64.tar.gz
tar xvf apache-tomcat-8.5.64.tar.gz
ln -sv /apps/apache-tomcat-8.5.64 /apps/tomcat
'/apps/tomcat' -> '/apps/apache-tomcat-8.5.64'
chmod a+x /apps/tomcat/bin/*.sh
3.2 创建普通账号
groupadd -g 2021 tomcat
useradd -r -m -s /bin/bash -u 2021 -g 2021 tomcat
id tomcat
chown tomcat.tomcat /apps/ -R
3.3 启动 tomcat
su - tomcat
/apps/tomcat/bin/catalina.sh start
su - tomcat -c "whoami" tomcat
su - tomcat -c "/apps/tomcat/bin/catalina.sh start"
3.4 创建并配置启动脚本文件
cat /lib/systemd/system/tomcat.service
[Unit]
Description=Apache Tomcat Web Application Container
After=syslog.target network.target
[Service]
Type=forking
ExecStart=/apps/tomcat/bin/catalina.sh start
ExecStop=/apps/tomcat/bin/catalina.sh stop
SuccessExitStatus=143
User=tomcat
Group=tomcat
[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl enable --now tomcat
四、主要文件与目录
主要目录: logs #日志目录。 temp #缓存目录。 webapps #默认保存代码的目录。 work #tomcat 工作目录,保存了运行时的 class 文件。 lib #各种 jar 包形式的库文件
[root@centos7 apps]
total 20
-rw-r----- 1 tomcat tomcat 6092 Aug 2 23:16 catalina.2021-08-02.log
-rw-r----- 1 tomcat tomcat 6092 Aug 2 23:16 catalina.out
-rw-r----- 1 tomcat tomcat 0 Aug 2 23:16 host-manager.2021-08-02.log
-rw-r----- 1 tomcat tomcat 458 Aug 2 23:16 localhost.2021-08-02.log
-rw-r----- 1 tomcat tomcat 0 Aug 2 23:16 localhost_access_log.2021-08-02.txt
-rw-r----- 1 tomcat tomcat 0 Aug 2 23:16 manager.2021-08-02.log
主要配置文件
[root@centos7 apps]
total 224
drwxr-x--- 3 tomcat tomcat 23 Aug 2 23:16 Catalina
-rw------- 1 tomcat tomcat 12874 Mar 5 07:17 catalina.policy
-rw------- 1 tomcat tomcat 7661 Mar 5 07:17 catalina.properties
-rw------- 1 tomcat tomcat 1338 Mar 5 07:17 context.xml
-rw------- 1 tomcat tomcat 1149 Mar 5 07:17 jaspic-providers.xml
-rw------- 1 tomcat tomcat 2313 Mar 5 07:17 jaspic-providers.xsd
-rw------- 1 tomcat tomcat 3916 Mar 5 07:17 logging.properties
-rw------- 1 tomcat tomcat 7588 Mar 5 07:17 server.xml
-rw------- 1 tomcat tomcat 2164 Mar 5 07:17 tomcat-users.xml
-rw------- 1 tomcat tomcat 2558 Mar 5 07:17 tomcat-users.xsd
-rw------- 1 tomcat tomcat 171879 Mar 5 07:17 web.xml
catalina.policy
catalina.properties
tomcat.conf
web.xml
context.xml
logging.properties
server.xml
tomcat-users.xml
|