- A Guide To Apache Tomcat Linux Installation and Set-Up
- Step 1 — Download And Extract The Latest Binary Distribution
- Step 2 — Set The Required Environment Variables
- Step 3 — Start Tomcat
- Step 4 — What To Do Next
- Step 1 — Create A Tomcat-Specific User and User Group
- Step 2 — Adjust Ownership For New Users And Groups
- Step 3 — Relay Traffic For Non-Root Tomcat User
- Step 3 — Create A Custom init Script
- Apache Tomcat on Linux — Installation and configuration on multiple platforms
- Basic Linux installation
- 1 — Create a low privilege user
- 2 — Download the latest binary release
- 3 — Move distribution into place and uncompress
- 4 — Change permissions
- 5 — Start Tomcat
- Platform specific instructions
- Debian and Ubuntu Linux
- Red Hat Linux
- Gentoo Linux
- How to Install Latest Apache Tomcat 8.5.14 in Linux
- Components of Tomcat
- Step 1: Installing Java 8
- Step 2: Download and Install Apache Tomcat 8
- If You Appreciate What We Do Here On TecMint, You Should Consider:
A Guide To Apache Tomcat Linux Installation and Set-Up
Many Apache Tomcat users choose to run their Tomcat instances on Linux, with good reason — it’s a rock solid operating system, with many different flavors to cater to the needs of a wide variety of users and situations.
Installing Tomcat on Linux need not be cumbersome. Some users will have no problem getting Tomcat up and running on their Linux machine. However, the large number of available Linux distributions with slightly differing features can leave a large number of users hung up on small installation errors.
This situation isn’t helped by the fact that many Linux distributions include custom Tomcat packages, which are often modified in odd ways, and sometimes contain bugs that have already been fixed in the official Tomcat releases.
The aim of this article is to guide you through a successful, error-free installation of Tomcat on Linux. We’ll focus on installing Tomcat on Linux from the official binary distribution, as this is the most sure way to avoid errors down the line.
We hope that you find this guide useful as you set-up Tomcat for the first time on your Linux machine! Let’s get started.
Tip: Tcat Server is the enterprise Tomcat application server, providing key enterprise features such as deep diagnostics, configuration management, advanced deployment functionality and reliable restarts. Try Tcat Server today!
Installing Tomcat From the Apache Distribution
It might not be as simple as typing a single repository command, but installing Tomcat using the latest official Apache binary release is the best way to avoid errors and confusion, provided you do it correctly. This method is recommended especially if you are new to Tomcat, because it will be a good introduction to Tomcat’s internal configuration files.
Also, the Tomcat documentation available on the Apache project site, which is quite good, references the unmodified binary distribution exclusively — there is no comprehensive package-specific documentation. If you anticipate having to look up a good amount of infuriation early on, using the official distribution will potentially save you a lot of hassle.
Finally, and most importantly, using the official distribution ensures that you are using the most up-to-date version of Tomcat available. The Tomcat developers are very active, often releasing multiple patches per day for bugs and security risks. Using the binary distribution ensures that you’ll be able to take advantage of all their hard work.
Step 1 — Download And Extract The Latest Binary Distribution
You can download the latest version of Tomcat from the Apache project site. Click here to see the list of available versions. Most Linux users will want to use the latest TAR package.
To download the package directly from the Linux command line, you’ll use a command that looks something like this:
After you have downloaded the package, make sure to verify the MD5 checksum against the key provided on the Apache website, like this:
Next, extract the package:
. And move the extracted folder into a dedicated directory:
Step 2 — Set The Required Environment Variables
If you haven’t already done so during a different application’s install process, you’ll need to set the JAVA_HOME environment variable in order for Tomcat to run. We recommend doing this by editing «.bashrc», as it this will allow you to set up automatic start for Tomcat, if you need it. Open the file with vi:
. And set the variable like this:
While you’re here, you should also set the CATALINA_HOME variable, which should point to the main Tomcat directory:
Log out and log back into bash to have your changes take effect.
Step 3 — Start Tomcat
If you followed all these steps correctly, you should be able to start Tomcat via its included startup script, startup.sh:
Tomcat runs on port 8080 by default. To check if your server is up and running correctly, use:
If this command returns the Catalina process, Tomcat is up and running. You should now be able to access the Tomcat Welcome Page at http://localhost:8080/
Step 4 — What To Do Next
Now that you’ve installed Tomcat, you may want some additional information to get you started.
If you want more information about configuring Tomcat, please visit our helpful guide to Tomcat Configuration, as well as our Tomcat Performance and Tomcat JVM guides, which will help you get Tomcat performing at its best on your machine.
Running Tomcat Automatically At Linux Startup
A potential drawback of installing Tomcat from a binary distribution instead of using a Linux-packaged version is that you’ll have to do some extra legwork to make Tomcat start automatically when Linux boots up. To make this process easy and pain-free, follow this simple guide.
Step 1 — Create A Tomcat-Specific User and User Group
It’s a bad idea to run Tomcat as the root user, especially if you’re going to be starting Tomcat automatically. It’s much more secure to create a new group and user specifically to run Tomcat. You can do so with the following commands (in this example, we have created a user group named tomcat, and a user named tomcat with the password tomcat; you can certainly be more creative if you wish):
Step 2 — Adjust Ownership For New Users And Groups
Now that you have created a user to run Tomcat, you’ll need to give them access to the correct directories. Use the following commands, substituting your own usernames and groups as necessary:
The first gives ownership of the Tomcat directories to the Tomcat user, and the second gives the user write access for the web apps directory.
Step 3 — Relay Traffic For Non-Root Tomcat User
When running Tomcat as a user other than the root user, you will not be able to bind to port 80, which is where Tomcat listens for HTTP requests. To get around this, you can use Netfilter, which is packaged with all major Linux distributions:
To preserve these rules through re-boot, save them with the «ip-tables-save» command, and then follow the procedure appropriate for your Linux distribution (for most distributions, this means editing the iptables init script; Debian users should load the configuration via a script called by if-up.d or pre-up.d).
Step 3 — Create A Custom init Script
To start Tomcat at Linux boot time, we’ll need to create an init script that calls the startup.sh and shutdown.sh scripts included with Tomcat.
The actual creation of this script is outside the scope of this article, but there are many useful resources available online. All you need to know in order to use the basic init script format to call Tomcat is how the startup.sh and shutdown.sh scripts work.
For more information about these scripts, visit our Tomcat Start page, which includes a simple, step-by-step guide to Tomcat’s three start-up shell scripts.
Источник
Apache Tomcat on Linux — Installation and configuration on multiple platforms
Technically, Apache Tomcat is fully compatible with all major Linux distributions, and many users run Tomcat on Linux. Despite this, many Linux users run into snags during the initial set up process.
Most Linux users are accustomed to differences between Linux distributions causing a process that works on one flavor to fail on another. However, it can be hard to trace the actual source of the failure, as there are a number of factors other than differences between distributions that can cause problems. For example, although most Linux distributions include a pre-configured Tomcat package in their repositories, these packages are often out of date or configured in such a way that certain web applications fail.
In this article, we’ve rounded up a list of common errors and configuration quirks you might experience when installing Apache Tomcat on a number of major Linux distributions — Debian, Red Hat, Ubuntu, and Gentoo.
Basic Linux installation
Although different distributions will require slightly different configurations, these instructions describe the basic process for most flavors of Linux.
Before you begin, make sure your Java runtimes are up to date, and that you are running a version of Java high enough for the Tomcat distribution you are preparing to install. You can download the latest version of the Java runtimes from Java.com.
Be careful when using distribution-specific Java packages from repositories, as these can be prone to the same problems as other repackaged Java programs.
1 — Create a low privilege user
Running Tomcat as root introduces the unnecessary risk that a compromised Tomcat instance could yield control over your entire server. Thus, creating a user with low privileges to run Tomcat should be standard practice when installing new instances.
Logged in as the root user, run the following command:
This command creates a new user named ‘tomcat’ belonging to the nobody group, with the /sbin/nologin/ shell and a locked password.
2 — Download the latest binary release
While there are a number of distribution-specific Tomcat packages available, the quality of these releases varies.
Unless you are using one of the better maintained releases (for example, the Ubuntu/Debian package, which is maintained by MuleSoft’s own Jason Brittain, author of O’Reilly’s The Definitive Guide to Apache Tomcat and lead developer of Tcat), downloading the latest release directly from Apache is the only way to be sure that you are getting the latest bug and stability fixes.
The trade-off is that the installation may not be as tightly integrated into the system, and may require extra legwork to monitor or update (as opposed to executing a simple package manager command).
The latest stable release can always be found on the Apache Tomcat download page on Apache’s website.
3 — Move distribution into place and uncompress
Next, copy Tomcat to the directory you want to install it in, and extract the package:
4 — Change permissions
Finally, change the permissions of the folder to allow the user you created to run Tomcat in step one to read and write to the folder (you’ll need root access again):
5 — Start Tomcat
You should now be able to start Tomcat from the command line by running startup.sh, the start script included with Tomcat, or by running catalina.sh with the ‘start’ parameter.
Platform specific instructions
Debian and Ubuntu Linux
The standard Linux installation instructions provided above can be used without modification to successfully install Tomcat on Debian or Ubuntu Linux.
However, a number of quirks will affect a manual Debian/Ubuntu installation. For example, Tomcat’s STDOUT and STDERR logs will be appended to the main syslog, instead of appearing in Tomcat’s default log file, ‘catalina.out’.
Also, as the Apache distributions of Tomcat include no Debian/Ubuntu-specific init script, a custom script must be written and installed if Tomcat needs to be run as a service. These are not big problems, but they can be a hassle.
Although it is normally a good idea to avoid re-packaged versions of Tomcat from repositories, the Debian / Ubuntu package (they share the same upstream) is maintained by MuleSoft’s own Jason Brittain, author of O’Reilly’s Definitive Guide To Apache Tomcat.
Thanks to Jason’s work, most users should find that a simple ‘apt get’ command is now the easiest and best way to install Tomcat on the Debian and Ubuntu platforms.
Jason’s package includes a custom init script that makes Tomcat restarts more reliable, and some custom Tomcat configurations that help users to avoid the most common problems with new manual installations, such as disabling the SecurityManager by default and fixing port binding issues.
If you’d like some more information about the package, Jason has written two in-depth blogs about his improvements, which you can read here and here on the MuleSoft blog.
Red Hat Linux
The standard Linux installation instructions provided above can be used without modification to successfully install Tomcat on Red Hat Linux.
Although a Tomcat package is provided in the YUM repositories, it is not frequently updated, and so a manual installation is not recommended.
If you want to run Tomcat as a service, as with Debian and Ubuntu, you will need to write a custom init.d script, similar to the bare bones example below, and place it in Red Hat’s «/etc/init.d» folder:
Gentoo Linux
The standard Linux installation instructions provided above can be used without modification to successfully install Tomcat on Debian or Ubuntu Linux. However, the installation will not comply with Gentoo / LHS standards.
A distribution of Tomcat that splits Tomcat into multiple Gentoo-friendly pieces is available in the Gentoo repositories. Documentation is available on gentoo.org. However, the guide has not been updated since 2007, so users should proceed with caution.
To install Tomcat from the Gentoo repositories, use the following command:
The Gentoo distribution includes a custom init script. Once you have installed Tomcat, it can be started with the following command:
To enable Tomcat as a service, so that it automatically starts at boot time, use the following command:
Источник
How to Install Latest Apache Tomcat 8.5.14 in Linux
Apache Tomcat commonly called as Tomcat is an open-source web server and servlet container developed by Apache Software Foundation. It is written primarily in Java and released under Apache License 2.0. This is a cross platform application.
Recently, on April 18th, 2017, Apache Tomcat reached to version 8 (i.e. 8.5.14), which includes a numerous fixes and number of other enhancements and changes. Some of noticeable changes included in this release are: support for Java Servlet 3.1, JSP (JavaServer Pages) 2.3, EL (Java Expression Language) 3.0, Java Websocket 1.1, etc.
Components of Tomcat
- Catalina : It is the Servlet Container of Tomcat.
- Coyote : Coyote acts as a connector and supports HTTP 1.1
- Jasper : It is the Tomcat’s JSP Engine.
- Cluster : A component for load balancing to manage large applications.
- High availability : A Tomcat component to schedule system upgrades and changes without affecting live environment.
- Web Application : Manage Sessions, Support deployment across different environments.
This article will walk you throughout the process of installing Apache Tomcat 8 (i.e. 8.5.14) on Linux systems, which includes RHEL, CentOS, Fedora, Debian, Ubuntu, etc.
Step 1: Installing Java 8
1. Before installing Tomcat make sure you have the latest version of Java Development Kit (JDK) installed and configured on the system. It is preferred to use oracle Java.
To install latest Oracle Java JDK (jdk-8u131) on Linux, you may like to refer our recent posts on Oracle jdk/jre/jar installations here:
Step 2: Download and Install Apache Tomcat 8
2. Once latest Java installed and configured correctly on the system, we will move forward to download and install latest stable version of Tomcat 8 (i.e. 8.5.14). If you want to cross check, if any newer version available, go to following Apache download page and cross check.
3. Next create a /opt/tomcat/ directory and download the latest version of Apache Tomcat 8 under this directory, also for cross checking the download file, we will be downloading hash file. The download will take some time depending upon your connection speed.
Note: Make sure to replace the version number in the above download link with the latest version available if it was different.
4. Now verify the MD5 Checksum against the key.
Make sure that the output (Hash Value) matches, as shown below.
Verify Apache Tomcat MD5
5. Extract the Tomcat zip and cd to ‘apache-tomcat-8.5.14/bin/‘ directory.
6. Now make Linux scripts executable that is under ‘apache-tomcat-8.5.14/bin/‘ and then create symbolic link of startup and shutdown script for tomcat as:
Change all scripts *.sh executable only for root as,
Create Symbolic link for startup script as,
Create Symbolic link for shutdown script as,
7. Now to start tomcat, you just need to fire the below command as root from anywhere in the shell.
Sample Output
Once ‘Tomcat Started‘, you can point your browser to http://127.0.0.1:8080 and you should see something as:
Default Apache Tomcat Page
If You Appreciate What We Do Here On TecMint, You Should Consider:
TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
We are thankful for your never ending support.
Источник