Welcome to Salem Houali ‘s Oracle Developer Notes

install and Configure Apache on Linux

Introduction

Apache HTTP Server, commonly known as Apache, is one of the most popular web server software in the world due to its powerful features, 
extensive documentation, and active community support. 
In this comprehensive guide, we will walk through the steps of installing and configuring Apache on a Linux system.

There are several ways to set up Tomcat for running on different platforms. 
The main documentation for this is a file called RUNNING.txt. We encourage you to refer to that file if the information 
below does not answer some of your questions.

Prerequisites:
Download the following files:

apache-tomcat-11.0.0.tar.gz
OpenJDK21U-jdk_x64_linux_hotspot_21.0.5_11.tar.gz
Installation
# Create a user called “tomcat” to own the Tomcat installation. We also create a directory called “/opt/tomcatdir” to hold all the config,  and make sure that it is owned by the new “tomcat” user.
useradd tomcat
mkdir -p /opt/tomcatdir
chown tomcat:tomcat -R /opt/tomcatdir

# Install the JDK from the tarball under the “/opt/tomcatdir/java” directory.
# We unzip it to create a new directory, which includes the version number,
# but use a symbolic link so we can always use the same path for the JAVA_HOME environment variable, regardless of the version.


su – tomcat $ mkdir -p /opt/tomcatdir/java
cd /opt/tomcatdir/java
$ tar xzf /home/oracle/Downloads/OpenJDK21U-jdk_x64_linux_hotspot_21.0.5_11.tar.gz tomcat@crowncloud java]$ ln -s jdk-21.0.5+11 latest
[tomcat@crowncloud java]$ ls -l
drwxr-xr-x. 9 tomcat tomcat 131 Oct 20 14:43 jdk-21.0.5+11
lrwxrwxrwx. 1 tomcat tomcat 13 Oct 20 14:45 latest -> jdk-21.0.5+11


# Install Tomcat from the tarball under the “/u01/tomcat” directory. We unzip it to create a new directory,
# which includes the version number, but use a symbolic link so we can always use the same path for
# the CATALINA_HOME environment variable, regardless of the version.


$ cd /opt/tomcatdir
$ tar xzf /tmp/apache-tomcat-8.5.35.tar.gz
$ ln -s apache-tomcat-11.0.0 latest


. We want to separate the config from the binaries, to make future upgrades easier, so we will create a new directory
. to act as the CATALINA_BASE location, and seed it by copying the relevant directories to the new directory.
. We are using a sub-directory called “instance1” to allow for multiple instances, but that is not necessary if you only
. plan to have a single Tomcat instance running.

# Set the following environment variables and append them to the "/home/tomcat/.bash_profile"
export JAVA_HOME=/opt/tomcatdir/java/latest
export CATALINA_HOME=/opt/tomcatdir/latest
export CATALINA_BASE=/opt/tomcatdir/apache-tomcat-11.0.0

# so they are set for subsequent logins.
# make the .jar files executable first
rwxr—–. 1 tomcat tomcat 47380 Oct 3 13:00 /opt/tomcatdir/apache-tomcat-11.0.0/bin/tomcat-juli.jar
[tomcat@crowncloud logs]$ ls -altr /opt/tomcatdir/apache-tomcat-11.0.0/bin/bootstrap.jar
-rwxr—–. 1 tomcat tomcat 31594 Oct 3 13:00 /opt/tomcatdir/apache-tomcat-11.0.0/bin/bootstrap.jar
# Add the following variables to tomcat user’s .bash_profile# tomcat user environement variables

 

Start and stop Tomcat using the following scripts.
$ $CATALINA_HOME/bin/startup.sh
$ $CATALINA_HOME/bin/shutdown.sh

The Tomcat logs are written to the “$CATALINA_BASE/logs/” directory by default.
Once Tomcat is started, the following URL should be available. Configuration for the management URLs is discussed below.

http://localhost:8080/
http://localhost:8080/manager/html
http://localhost:8080/manager/status

Remember to open up the port on the firewall if you want to access the site from other servers on the network. Information about the Linux firewall is available here.
Check the Status of the server 
There are several ways to check the status of the service.


$ netstat -nlp | grep 8080
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
$ ps -ef | grep tomcat
tomcat 18751 1 15 14:47 pts/1 00:00:11 /u01/java/latest/bin/java
-Djava.util.logging.config.file=/u01/config/instance1/conf/logging.properties
-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048
-Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Dorg.apache.catalina.security.SecurityListener.UMASK=0027
-Dignore.endorsed.dirs= -classpath /u01/tomcat/latest/bin/bootstrap.jar:/u01/tomcat/latest/bin/tomcat-juli.jar
-Dcatalina.base=/u01/config/instance1 -Dcatalina.home=/u01 tomcat/latest -Djava.io.tmpdir=/u01/config/instance1/temp
org.apache.catalina.startup.Bootstrap start
tomcat 18854 3994 0 14:49 pts/1 00:00:00 grep –color=auto tomcat



$ curl -I http://localhost:8080
HTTP/1.1 200
Content-Type: text/html;charset=UTF-8
Transfer-Encoding: chunked
Date: Sat, 15 Dec 2018 14:51:02 GMT


Configuration Files

The main locations of configuration and log information are shown below.
Release Notes : $CATALINA_HOME
Bin Directory    : $CATALINA_HOME/bin
Config              : $CATALINA_BASE/conf
Webapps         : $CATALINA_BASE/webapps
Logs                : $CATALINA_BASE/logs

Enabling HTML Management Access

Edit the “$CATALINA_BASE/conf/tomcat-users.xml” file, adding the following entries inside “tomcat-users” tag. Adjust the password as required.

<role rolename=”manager-gui”/>
<role rolename=”admin-gui”/>
<user username=”tomcat” password=”MyPassw0rd!” roles=”manager-gui,admin-gui”/>

Verify the server ‘status

 

 

 

 

 

 

This ends the demo

Leave a Reply