sudo apt-get update
sudo apt-get install default-jdk
2.创建tomcat用户
sudo groupadd tomcat
sudo useradd -s /bin/false -g tomcat -d /opt/tomcat tomcat
3.安装tomcat
cd /tmp
curl -O http://apache.mirrors.ionfish.org/tomcat/tomcat-8/v8.5.5/bin/apache-tomcat-8.5.5.tar.gz
sudo mkdir /opt/tomcat
sudo tar -zxf apache-tomcat-8*tar.gz -C /opt/tomcat --strip-components=1
4.权限配置
cd /opt/tomcat
sudo chgrp -R tomcat /opt/tomcat
sudo chmod -R g+r conf
sudo chmod g+x conf
sudo chown -R tomcat webapps work temp logs
5.创建systemd文件
sudo update-java-alternatives -l
sudo vi /etc/systemd/system/tomcat.service
sudo systemctl daemon-reload
sudo systemctl start tomcat
sudo systemctl status tomcat
sudo systemctl enable tomcat
6.配置防火墙
sudo ufw allow 8080
7.配置tomcat管理界面
sudo vi /opt/tomcat/conf/tomcat-users.xml
sudo tar -zxf apache-tomcat-8*tar.gz -C /opt/tomcat --strip-components=1
4.权限配置
cd /opt/tomcat
sudo chgrp -R tomcat /opt/tomcat
sudo chmod -R g+r conf
sudo chmod g+x conf
sudo chown -R tomcat webapps work temp logs
5.创建systemd文件
sudo update-java-alternatives -l
sudo vi /etc/systemd/system/tomcat.service
点击(此处)折叠或打开
- [Unit]
- Description=Apache Tomcat Web Application Container
- After=network.target
- [Service]
- Type=forking
- Environment=JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre
- Environment=CATALINA_PID=/opt/tomcat/temp/tomcat.pid
- Environment=CATALINA_HOME=/opt/tomcat
- Environment=CATALINA_BASE=/opt/tomcat
- Environment='CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC'
- Environment='JAVA_OPTS=-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom'
- ExecStart=/opt/tomcat/bin/startup.sh
- ExecStop=/opt/tomcat/bin/shutdown.sh
- User=tomcat
- Group=tomcat
- UMask=0007
- RestartSec=10
- Restart=always
- [Install]
- WantedBy=multi-user.target
sudo systemctl start tomcat
sudo systemctl status tomcat
sudo systemctl enable tomcat
6.配置防火墙
sudo ufw allow 8080
7.配置tomcat管理界面
sudo vi /opt/tomcat/conf/tomcat-users.xml
点击(此处)折叠或打开
- <tomcat-users . . .>
- <user username="admin" password="password" roles="manager-gui,admin-gui"/>
- </tomcat-users>