Amazon Linux环境下Tomcat版本查询、服务启动及开机自启配置咨询
Hey there! Let's walk through your Tomcat questions step by step, since you're used to the httpd service workflow:
1. Start Tomcat Using service Command (Like httpd)
When you install Tomcat 8.5 via amazon-linux-extras, the package sets up a system service automatically. You can use the same service syntax you know for httpd:
- Start Tomcat:
sudo service tomcat start - Stop Tomcat:
sudo service tomcat stop - Restart Tomcat:
sudo service tomcat restart - Check running status:
sudo service tomcat status
If the tomcat service isn't found, double-check that your installation completed without errors. You can verify the service exists with this command:systemctl list-unit-files | grep tomcat
2. Set Tomcat to Auto-Start on Instance Reboot (Like chkconfig httpd on)
Amazon Linux uses systemd by default now, but it still supports legacy chkconfig commands. Here are both options:
Option 1: Systemd (Recommended)
Use systemctl to enable auto-start for Tomcat:sudo systemctl enable tomcat
Confirm the setting took effect with:systemctl is-enabled tomcat
Option 2: Legacy chkconfig
If you prefer the chkconfig workflow you're used to, run:sudo chkconfig tomcat on
Verify the auto-start status with:chkconfig --list tomcat
3. Check Tomcat Version
The simplest way is to use Tomcat's built-in version script. By default, this lives in /usr/share/tomcat/bin:
- Run the script directly:
sudo /usr/share/tomcat/bin/version.sh - Or navigate to the bin folder first:
cd /usr/share/tomcat/bin sudo ./version.sh
You'll get detailed output including the exact Tomcat version, your JVM version, and system environment info.
内容的提问来源于stack exchange,提问作者Subramanian Lakshmanan

