Integration of Apache and Tomcat 4 in RedHat7.2

Source: Internet
Author: User
Article title: Apache and Tomcat 4 integrated instances in RedHat7.2. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
Summary
This article introduces the integration process of Apache and Tomcat 4 under RedHat Linux 7.2, focuses on the creation method of mod_webapp.so, and the configuration, management, and application in the virtual host environment.
  
This section describes how to integrate Apache and Tomcat 4 under RedHat Linux 7.2, and focuses on how to create mod_webapp.so,
  
Configuration, management, and application in the virtual host environment have been tested successfully. I hope it will help you. please correct me if you have any errors.
  
1. install Tomcat 4 correctly
  
Install necessary software as follows:
  
1. Java SDK
  
For version 1.3.1 or 1.4, it is recommended to install it in/usr/java and create a soft link for jdk.
  
If there is a problem installing SDK 1.3.1, read the documentation: http://java.sun.com/j2se/1.3/install-linux-sdk.html
  
2. Tomcat4
  
We recommend that you install the binary file installation package of the latest release version. The latest tomcat version is 4.1.12.
  
:
  
Http://jakarta.apache.org/builds/jakarta-tomcat-4.0/release/v4.1.12/bin/jakarta-tomcat-4.1.12.tar.gz
  
In this example, tomcat is installed in the/opt directory and a soft link of tomcat is made.
  
Set and enable the following environment variables:
  
  
PATH = $ PATH:/usr/java/jdk/bin:/usr/java/jdk/jre/bin
JAVA_HOME =/usr/java/jdk
  
Export JAVA_HOME
CLASSPATH = "./:/usr/java/jdk/lib:/usr/java/jdk/jre/lib"
Export CLASSPATH
CATALINA_HOME =/opt/tomcat
Export CATALINA_HOME
  
  
  
We recommend that you create a single user tomcat, set it to the owner of all Directory files under/opt/tomcat, and start tomcat by it:
  
  
# Useradd tomcat
# Chown-R tomcat: tomcat/opt/tomcat
# Su-tomcat-c "/opt/tomcat/bin/startup. sh"
  
  
  
Visit http: // localhost: 8080/to see the successful tomcat installation page.
  
II. Integration of Apache and Tomcat 4
  
1. first install Apache,
  
Note that DSO mode must be installed in Apache, that is, -- enable-module = so must be added when you execute./configure.
  
Installed in the/usr/local/apache directory by default. The apache version installed in this example is 1.3 series.
  
2. create mod_webapp.so
  
The following software packages are required:
  
Jakarta-tomcat-connectors-4.x.xx-src.tar.gz
  
In the src Directory of the tomcat version. For example, if the tomcat version I installed is 4.1.12, the required software package is located:
  
Http://jakarta.apache.org/builds/jakarta-tomcat-4.0/release/v4.1.12/src/jakarta-tomcat-connectors-4.1.12-src.tar.gz
  
Apr-0.9.1.tar.gz
  
: Http://www.apache.org/dist/apr/apr-0.9.1.tar.gz
  
Autoconf-2.52-ximian.1.i386.rpm
  
: Http://rpmfind.net/linux/RPM/helix/gnome-2-snapshot/redhat-72-i386/autoconf-2.52-ximian.1.i386.html
  
First use rpm to install the autoconf-2.52, because the following installation will be used;
  
Then open jakarta-tomcat-connectors-4.1.12-src.tar.gz and generate the jakarta-tomcat-connectors-4.1.12-src directory,
  
Go to the jakarta-tomcat-connectors-4.1.12-src/webapp's directory and remove apr-0.9.1.tar.gz to this directory,
  
And change the directory name of the directory apr-0.9.1 just generated to apr.
  
In the webapp Directory, run the following command:
  
  
# Support/buildconf. sh
  
  
  
In this case, if autoconf is earlier than 2.52, an error is reported and exited, so you must install the autoconf-2.52 first.
  
After the command is completed successfully, the configure file is generated in the current directory.
  
Run the following commands in sequence:
  
  
#./Configure -- with-apxs =/usr/local/apache/bin/apxs
# Make
# Cp apache-1.3/mod_webapp.so/usr/local/apache/libexec
  
  
  
Now mod_webapp.so has been created and copied to the libexec directory of apache.
  
Edit the apache configuration file and add the following lines at the end:
  
  
======================================
LoadModule webapp_module libexec/mod_webapp.so
AddModule mod_webapp.c
WebAppConnection warpConnection warp localhost: 8008
WebAppDeploy examples warpConnection/examples
======================================
  
  
  
Run the following command:
  
  
#/Usr/local/apache/bin/apachectl configtest
  
  
  
"Syntax OK" indicates that mod_webapp.so has been installed successfully.
  
Start apache
  
  
#/Usr/local/apache/bin/apachectl start
  
  
  
Visit http: // localhost/examples to see the tomcat example program.
  
III. configuration, management, and application under virtual hosts
  
The following uses an example to describe how a VM uses Apache and Tomcat 4 at the same time.
  
The directory structure of host1 is as follows:
  
  
/Www ???????????????
? | --- Host1 ?? Main Directory of host1
? | ?? | -- Htdocs? Common root directory: used to display static pages or php programs
? | ?? | ---- Logs ?? Apache access log
? | ?? | ---- Webapps java Application Directory (newly added, no association with tomcat's webapps directory)
? | ????? | -- ROOT? Jsp root directory: used to display jsp page programs
? | ????? | ---- Jive? A set of java application instances
? | --- Host2 ??? Main Directory of host2
............
  
  
  
The original apache configuration file is configured as follows:
  
  
============================================
NameVirtualHost xxx. xxx
  
<VirtualHost xxx. xxx>
ServerName host1.mydomain.com
ServerAdmin webmaster@mydomain.com
DocumentRoot/www/host1/htdocs
ErrorLog/www/host1/logs/error_log
CustomLog/www/host1/logs/access_log common
</VirtualHost>
.............
  
============================================
  
  
  
To enable the virtual host host1 to use Apache and Tomcat 4 at the same time, you need to configure the following:
  
1. edit the tomcat configuration file server. xml and make the following changes in the last part:
  
  
============================================
<! -- Define an Apache-Connector Service -->
  
<Service name = "Tomcat-Apache">
  
<Connector className = "org. apache. catalina. connector. warp. WarpConnector"
Port = "8008" minProcessors = "5" maxProcessors = "75"
EnableLookups = "true" appBase = "webapps"
AcceptCount = "10" debug = "0"/>
  
<Engine className = "org. apache. catalina. connector. warp. WarpEngine"
Name = "Apache" debug = "0">
  
<Logger className = "org. apache. catalina. logger. FileLogger"
Prefix = "apache_log." suffix = ". txt"
Timestamp = "true"/>
  
<Realm className = "org. apache. catalina. realm. MemoryRealm"/>
  
<! -- The following is the newly added content -->
  
<Host name = "host1.mydomain.com" debug = "0" appBase = "/www/host1/webapps"
UppackWars = "true" autoDeploy = "true">
<Context path = "" docBase = "ROOT" debug = "0"/>
<! -- The following is a built-in tomcat management page, which can also be used under a VM -->
<Context path = "/manager" debug = "0" privileged = "true"
DocBase = "/opt/tomcat/server/webapps/manager"/>
<Context path = "/jive" docBase = "jive" debug = "0"
Reloadable = "true" crossContext = "true"/>
<Logger className = "org. apache. catalina. logger. FileLogger"
Prefix = "host1_log." suffix = ". txt"
Timestamp = "true"/>
</Host>
  
<! -- Add content ended -->
  
</Engine>
  
</Service>
============================================
  
  
  
2. edit the tomcat management permission file tomcat-users.xml, add a line in the middle:
  
  
<User username = "myname" password = "mypasswd" roles = "standard, manager"/>
  
  
  
3. edit apac

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.