简体   繁体   中英

Install Tomcat 9.0.16 on Ubuntu 18.04

I'm trying to install Java and Tomcat on Linux Ubuntu 18.04 and I'm following this guide:

https://noviello.it/come-installare-apache-tomcat-9-su-ubuntu-18-04-lts/

I've already done hundreds of attempts. Could I know what's wrong with the tutorial? Do you know of the most recent and functional guides to install Tomcat 9.0.16 on Ubuntu 18.04? I also tried this guide but without success:

https://www.digitalocean.com/community/tutorials/install-tomcat-9-ubuntu-1804

I would like to do exactly what I find in these two guides:

https://noviello.it/come-installare-apache-tomcat-9-su-ubuntu-18-04-lts/ https://www.digitalocean.com/community/tutorials/install-tomcat-9-ubuntu-1804

This is what I would like to do:

sudo passwd root
******
sudo passwd ubuntu
******
su
******
apt-get update
apt update
apt install default-jdk
groupadd tomcat
useradd -s /bin/false -g tomcat -d /opt/tomcat tomcat
cd /tmp
apt install curl
curl -O http://it.apache.contactlab.it/tomcat/tomcat-9/v9.0.16/bin/apache-tomcat-9.0.16.tar.gz
mkdir /opt/tomcat
tar xzvf apache-tomcat-9.0.16.tar.gz -C /opt/tomcat --strip-components=1
cd /opt/tomcat
chown -R tomcat:tomcat /opt/tomcat
chmod -R g+r /opt/tomcat/conf
chmod -R g+w /opt/tomcat/logs
chmod -R g+w /opt/tomcat/temp
chmod -R g+w /opt/tomcat/webapps
chmod -R g+w /opt/tomcat/work
usermod -a -G tomcat tomcat
update-java-alternatives -l
nano /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.11.0-openjdk-amd64
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
systemctl daemon-reload
systemctl start tomcat
systemctl status tomcat
ufw enable
ufw allow ssh
ufw default allow
ufw allow 80
reboot
su
******
apt-get update
ufw status
systemctl enable tomcat
nano /opt/tomcat/conf/tomcat-users.xml
<user username="******" password="******" roles="manager-gui,admin-gui"/>
nano /opt/tomcat/webapps/manager/META-INF/context.xml
nano /opt/tomcat/webapps/host-manager/META-INF/context.xml
<!--<Valve className="org.apache.catalina.valves.RemoteAddrValve"
         allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />-->
systemctl restart tomcat
ls -R /opt/tomcat/conf/
nano /opt/tomcat/conf/server.xml
<Connector port="80" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />
systemctl restart tomcat
http://IP-PUBBLICO-SERVER

Where is the error? What are the tests I can do on the machine to understand what the problems are? Thank you

Steps look good.Except that you didn't install Java. Is java already installed and in PATH?

Follow these steps manually

Check the Java version in PC

1) Create user and group tomcat

2) Extract the tomcat .tar file in /opt

3) chown tomcat:tomcat /opt/tomcat

4) chmod -r u+g rwx /opt/tomcat/*.sh

5) start tomcat using start.sh

If every thing works add it in service.

只需下载Apache Tomcat 可分发文件并将其解压缩到您的机器上

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM