How to Install Tomcat in Ubuntu
Part 1 of 2:
Setting Up Tomcat
- Open a Terminal window on your Ubuntu machine. Click the Dash icon on the top-left, and click Terminal on the app list to open the Terminal.
- Alternatively, press Ctrl+Alt+T on your keyboard to open the Terminal.
- Type sudo apt-get update in Terminal. This command will update all your repositories, and make sure you have the latest software versions for new installations.
- Press ↵ Enter or ⏎ Return on your keyboard. This will run the command, and update your repositories.
- Run sudo apt-get install default-jdk in Terminal. This will install the latest version of the official Java Development Kit on your computer.
- Type or paste the command, and press ↵ Enter or ⏎ Return to run it.
- You'll need Java installed on your computer to install and set up Tomcat.
- If you already have Java installed, this will update it to the latest version.
- You can skip this step if you already have the latest Java version installed.
- Run sudo useradd -r -m -U -d /opt/tomcat -s /bin/false tomcat in Terminal. This will create a new system user, and group with home directory opt/tomcat to run the Tomcat service.
- You cannot run the Tomcat service under the root user for your server's security purposes.
- Open the Tomcat website in your internet browser. Type or paste http://tomcat.apache.org into your browser's address bar, and press ↵ Enter or ⏎ Return on your keyboard.
- Click the Tomcat version you want under "Download" on the left sidebar. You'll find the available Tomcat version on a navigation menu on the left-hand side of the page. You can select Tomcat 9 or another version here.
- If you want to see which versions are compatible with your system, click Which version? under the Download heading here.
- Right-click the blue tar.gz link under the "Core" heading. This will open your right-click options on a drop-down menu.
- Click Copy Link Address from the right-click menu. You can directly install Tomcat with the TAR file's link address here.
- Type wget into the Terminal. This will allow you to download the latest version of Tomcat to your computer from the official download link.
- Replace with the link address you copied from the official Apache Tomcat website.
- If you're located in the US, you can use https://www-us.apache.org/dist/tomcat/tomcat-9/v9.0.21/bin/apache-tomcat-9.0.21.tar.gz as the link address.
- If you're in Europe, you can use https://www-eu.apache.org/dist/tomcat/tomcat-9/v9.0.21/bin/apache-tomcat-9.0.21.tar.gz as the link address.
- Press ↵ Enter or ⏎ Return. This will run the download command, and download Tomcat on your computer.
- Run sudo tar xf /tmp/apache-tomcat-9*.tar.gz -C /opt/tomcat. Once your download is complete, run this command to extract the downloaded TAR file's contents, and move the files to the opt/tomcat directory.
- Make sure to replace the version number in "tomcat-9*.tar.gz" with the Tomcat version you download.
- Run sudo nano /etc/systemd/system/tomcat.service. This will create a new file named "tomcat.service," and allow you to edit its contents with your default text editor.
- Paste the following configuration into the tomcat.service file.
- Make sure to set "JAVA_HOME" to your system's Java directory in the following code.
[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
Part 2 of 2:
Starting Tomcat Service
- Run sudo systemctl daemon-reload in Terminal. This will reload the SystemD deamon, and find your new service file.
- Run the sudo ufw allow 8080 command (optional). If your server is protected by a firewall, run this command in Terminal to allow traffic on port 8080.
- This will allow you to access the Tomcat interface from outside of your local network.
- Run the systemctl enable tomcat command (optional). If you run this command, Tomcat service will automatically start on system boot.
- Run sudo systemctl start tomcat in Terminal. This will start the Tomcat service on your server.
- You can use the sudo systemctl status tomcat command to verify the service status.
- You can now test Tomcat in your internet browser at http://ip-address:8080. Just change "ip-address" with your system's default IP address in the link.
4 ★ | 1 Vote
You should read it
- 6 interesting terminal commands on Mac
- How to use Terminal on a Mac
- 8 best free Terminal Emulator apps for Android
- Notable changes in Windows Terminal ver 0.11
- How to Set Up an Independent IDS/IPS Lab Enviroment (Using Snort, Pytbull, Eclipse and Tomcat)
- How to fix the problem of being unable to enter Terminal in Linux
- How to customize Windows Terminal application
- Top 5 useful Terminal tips for Mac users
May be interested
- How to Get Help for Ubuntualthough ubuntu is considered to be one of the best linux distributions for newcomers, you still may find yourself in need of help whether this is your first time using a linux based os or if you're an experienced user. making the switch...
- How to Automatically Have Wallpaper Change on Ubuntudo you like the idea of a wallpaper that changes automatically? if you're looking for that kind of variety, you can set your desktop wallpaper to change automatically at certain intervals in ubuntu using wallch. open the terminal. first...
- How to Install Ubuntu Tweak 0.5.1 in Ubuntuif you wanna to install this package manually, just go to their homepage. there you will be able to see which versions are available and which version you need. second way is to install this application through terminal using three simple...
- How to Install HandBrake on Ubuntu 14.04handbrake is a free, open-source program used to convert video files. it's available for windows, os x and ubuntu. this article will explain how to install it in ubuntu 14.04. open a terminal window. this is usually done by pressing .
- How to Install Blender 3D on Ubuntuinstalling blender on ubuntu can be considered a nightmare if you don't know what you're doing. this article will take you through this challenging task step-by-step. navigate to the blender website. then go to the download page. you can ...
- How to Set Up an Independent IDS/IPS Lab Enviroment (Using Snort, Pytbull, Eclipse and Tomcat)this page is meant to help new software developers to set up an independent lab environment to run the ids/ips snort as well as the testing framework pytbull. advanced users can also install eclipse and apache tomcat, so as to be able to...