Apache Tomcat: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
(2 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== |
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/