在AWS的AmazonLinux 2023上安装tomcat9.0.82
安装Tomcat9到Amazon Linux 2023上。
创建Tomcat用户
useradd -r -s /sbin/nologin tomcat
■ 在/root目录下安装Tomcat。
cd
wget https://archive.apache.org/dist/tomcat/tomcat-9/v9.0.82/bin/apache-tomcat-9.0.82.tar.gz
tar -zxvf apache-tomcat-9.0.82.tar.gz
mv apache-tomcat-9.0.82 /usr/local/src/
ln -s /usr/local/src/apache-tomcat-9.0.82/ /usr/local/src/tomcat
chown -R tomcat:tomcat /usr/local/src/apache-tomcat-9.0.82
chown -R tomcat:tomcat /usr/local/src/tomcat
■ Tomcat启动配置的描述(/etc/systemd/system/tomcat.service)
[Unit]
Description=Tomcat Web Server
After=network.target
[Service]
Type=forking
User=tomcat
Group=tomcat
Environment="CATALINA_BASE=/usr/local/src/tomcat"
Environment="CATALINA_HOME=/usr/local/src/tomcat"
Environment="CATALINA_PID=/usr/local/src/tomcat/temp/tomcat.pid"
ExecStart=/usr/local/src/tomcat/bin/startup.sh
ExecStop=/usr/local/src/tomcat/bin/shutdown.sh
[Install]
WantedBy=multi-user.target
■注册 Tomcat
(Note: The phrase provided is already in Japanese, not Chinese. However, if you want a paraphrase in Chinese, the equivalent translation would be “注册 Tomcat”.)
systemctl daemon-reload
systemctl enable tomcat
systemctl is-enabled tomcat
将路径注入到~/.bash_profile中
vi ~/.bash_profile
※以下を追記
export CATALINA_HOME=/usr/local/src/tomcat
source ~/.bash_profile
systemctl start tomcat
在安全组的入站规则中添加允许端口8080的权限。
通过实例的地址:8080访问,在浏览器上安装和验证功能。
如果显示Tomcat 9.0.82,则表示正常。
参考(Tomcat10基本相同)
https://zenn.dev/lifewithpiano/scraps/d579be009c112b
如果要使用应用程序管理器的功能,请参考这里(编辑tomcat-users.xml和context.xml文件中的两个位置)。请访问https://nets-tip.com/?p=1329。