Apache Tomcat: Difference between revisions
Jump to navigation
Jump to search
(Created page with "<source lang="bash"> apt update; apt list --upgradable mkdir /opt/tomcat; cd /opt/tomcat/ wget https://archive.apache.org/dist/tomcat/tomcat-8/v8.5.63/bin/apache-tomcat-8.5.63...") |
|||
(3 intermediate revisions by the same user not shown) | |||
Line 5: | Line 5: | ||
tar -xzvf apache-tomcat-8*tar.gz -C /opt/tomcat --strip-components=1 | tar -xzvf apache-tomcat-8*tar.gz -C /opt/tomcat --strip-components=1 | ||
</source> | </source> | ||
==Permission== | |||
<source lang="bash"> | |||
groupadd tomcat | |||
useradd -r -g tomcat -d /opt/tomcat -s /sbin/nologin tomcat | |||
chown -R tomcat: /opt/tomcat | |||
chmod o+x /opt/tomcat/bin | |||
</source> | |||
<source lang="bash"> | |||
# chmod -R g+r /opt/tomcat/conf | |||
# chmod g+x /opt/tomcat/conf | |||
</source> | |||
==Service== | |||
<source lang="bash"> | |||
update-java-alternatives -l | |||
nano /etc/systemd/system/tomcat.service | |||
</source> | |||
<source lang="ini" highlight="2,11,12,15,16,18,19" line> | |||
[Unit] | |||
Description=Apache Tomcat Web Application Container | |||
After=network.target | |||
[Service] | |||
Type=forking | |||
Environment=CATALINA_HOME=/opt/tomcat | |||
Environment=CATALINA_BASE=/opt/tomcat | |||
Environment=CATALINA_PID=/opt/tomcat/temp/tomcat.pid | |||
Environment=JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-armhf/jre | |||
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 | |||
</source> | |||
<source lang="bash"> | |||
systemctl daemon-reload | |||
systemctl enable tomcat | |||
systemctl start tomcat | |||
systemctl status tomcat | |||
tail -f /opt/tomcat/logs/catalina.out | |||
</source> | |||
ssh [email protected] -L 8080:localhost:8080 | |||
http://localhost:8080/ | |||
==References== | ==References== | ||
* [https://superuser.com/questions/518347/ Equivalent to tar's <code>--strip-components=1</code> in unzip] | |||
* [https://stackoverflow.com/questions/41243174/ Untar tar file using <code>--strip-components=1</code>] | |||
* [https://www.digitalocean.com/community/tutorials/install-tomcat-9-ubuntu-1804 Install Apache Tomcat 9 on Ubuntu 18.04] | |||
* [https://www.digitalocean.com/community/tutorials/how-to-install-apache-tomcat-8-on-ubuntu-16-04 Install Apache Tomcat 8 on Ubuntu 16.04] | * [https://www.digitalocean.com/community/tutorials/how-to-install-apache-tomcat-8-on-ubuntu-16-04 Install Apache Tomcat 8 on Ubuntu 16.04] | ||
* [https:// | * [https://archive.apache.org/dist/tomcat/ Archive Apache Tomcat] | ||
Latest revision as of 09:29, 27 February 2021
apt update; apt list --upgradable
mkdir /opt/tomcat; cd /opt/tomcat/
wget https://archive.apache.org/dist/tomcat/tomcat-8/v8.5.63/bin/apache-tomcat-8.5.63.tar.gz
tar -xzvf apache-tomcat-8*tar.gz -C /opt/tomcat --strip-components=1
Permission
groupadd tomcat
useradd -r -g tomcat -d /opt/tomcat -s /sbin/nologin tomcat
chown -R tomcat: /opt/tomcat
chmod o+x /opt/tomcat/bin
# chmod -R g+r /opt/tomcat/conf
# chmod g+x /opt/tomcat/conf
Service
update-java-alternatives -l
nano /etc/systemd/system/tomcat.service
[Unit]
Description=Apache Tomcat Web Application Container
After=network.target
[Service]
Type=forking
Environment=CATALINA_HOME=/opt/tomcat
Environment=CATALINA_BASE=/opt/tomcat
Environment=CATALINA_PID=/opt/tomcat/temp/tomcat.pid
Environment=JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-armhf/jre
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
systemctl daemon-reload
systemctl enable tomcat
systemctl start tomcat
systemctl status tomcat
tail -f /opt/tomcat/logs/catalina.out
ssh [email protected] -L 8080:localhost:8080 http://localhost:8080/