To install Apache Tomcat on Linux OS, execute the following operations:
Create a tomcat system user (without home directory, password, permission to enter the system):
sudo useradd -r -M tomcat
Copy an archive with the Apache Tomcat 7 installation file to the home directory.
Create the /opt/tomcat7 directory:
sudo mkdir /opt/tomcat7
Extract the archive to the home directory by executing the following commands in the terminal:
cd /opt/tomcat7
sudo tar xvfz /home/foresight/<Apache Tomcat 7 archive name>.tar.gz
Add Apache Tomcat user with manager-gui permissions. To do this, open the tomcat-users.xml file by executing the command in the terminal:
sudo nano /opt/tomcat7/<Apache Tomcat 7 archive name>/conf/tomcat-users.xml
Go to the end of the file and add strings before the closing tag </tomcat-users>:
<role rolename="manager-gui"/>
<user username="system user name" password="system user password" roles="manager-gui"/>
If Java version was changed (OpenJDK was replaced with Oracle Java), modify JAVA_HOME variable in /home/foresight/.bashrc file:
sudo nano ~/.bashrc
Replace value of the JAVA_HOME variable if Oracle Java 7 was installed, with the following:
export JAVA_HOME="/usr/lib/jvm/java-7-oracle"
Increase the available loading limit by editing the web.xml file and adding 1 at the beginning of value of the max-file-size and max-request-size parameters:
sudo nano /opt/tomcat7/<Apache Tomcat 7 archive name>/webapps/manager/config/web.xml
Transform parameters in the <multipart-config> section to the following form:
<max-file-size>1524288000</max-file-size>
<max-request-size>1524288000</max-request-size>
Make tomcat user the owner of the /opt/tomcat7 directory:
sudo chown -R tomcat:tomcat /opt/tomcat7
Start Apache Tomcat by executing the commands in the terminal:
cd /opt/tomcat7/<Apache Tomcat 7 archive name>/bin/
sudo -u tomcat /catalina.sh run
The terminal should display the message: "INFO: Server startup in XXX ms", where XXX is a server startup time.
NOTE. On restarting the operating system the Apache Tomcat server is not automatically restarted. To set up automatic server startup on system startup, execute settings specified in the Setting Up Apache Tomcat as a Service section.
To check Apache Tomcat performance, open the URL in the browser: http://localhost:8080/.
TIP. To access the web application, see the Opening Web Application article.
See also: