Example of integration of Apache and TOMCAT4 under RedHat7.2

Source: Internet
Author: User
Tags add end version apache access log access root directory tomcat linux
Apache here to introduce my Redhat Linux 7.2 under the integration of Apache and TOMCAT4 process, focusing on mod_webapp.so production methods,
And in the virtual Host environment configuration, management and application, has been tested successfully. I hope to help you, please correct me if you have any mistakes.
First, the correct installation of TOMCAT4
Installation of the necessary software, as follows:
1. Java SDK
Version 1.3.1 or 1.4, it is recommended to install it under/usr/java and make a soft link to the JDK.
If there is a problem installing the version 1.3.1 SDK, read the documentation: http://java.sun.com/j2se/1.3/install-linux-sdk.html
2, TOMCAT4
It is recommended that you install the binary file installation package for the latest release version. Currently the latest Tomcat version is 4.1.12.
Download Address:
Http://jakarta.apache.org/builds/jakarta-tomcat-4.0/release/v4.1.12/bin/jakarta-tomcat-4.1.12.tar.gz
This example installs Tomcat in the/OPT directory and makes a soft link for Tomcat.
Set the following environment variables and enable:

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

It is recommended that you create a single user tomcat to/opt/tomcat the owner of all of the following directory files and start Tomcat by it:
# Useradd Tomcat
# Chown-r Tomcat:tomcat/opt/tomcat
# su-tomcat-c "/opt/tomcat/bin/startup.sh"
Access http://localhost:8080/should be able to see the successful Tomcat installation page.

Second, the integration of Apache and TOMCAT4
1, first install Apache,

Please note that Apache must be installed in DSO mode, that is, when executing./configure should be added--enable-module=so

The default installation is in the/usr/local/apache directory. The version of Apache installed in this example is the 1.3 series.

2, the production of mod_webapp.so

The following packages are required:

Jakarta-tomcat-connectors-4.x.xx-src.tar.gz

The download address is in the Tomcat version of the SRC directory. For example, the Tomcat version I installed is 4.1.12, and now the location of the package you need is:

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

Download Address: http://www.apache.org/dist/apr/apr-0.9.1.tar.gz

autoconf-2.52-ximian.1.i386.rpm

Download Address: http://rpmfind.net/linux/RPM/helix/gnome-2-snapshot/redhat-72-i386/autoconf-2.52-ximian.1.i386.html

First install the autoconf-2.52 with RPM, as the following installation will be used;

Then untie the jakarta-tomcat-connectors-4.1.12-src.tar.gz, generate the JAKARTA-TOMCAT-CONNECTORS-4.1.12-SRC directory,

Into the Jakarta-tomcat-connectors-4.1.12-src/webapp directory, and then apr-0.9.1.tar.gz to the directory,

and change the directory name of the newly generated directory apr-0.9.1 to Apr.

Or in the WebApp directory, run the following command:


# support/buildconf.sh



At this point if the version of autoconf less than 2.52 will be an error exit, so must first install autoconf-2.52.

The Configure file is generated in the current directory when the command completes successfully.

Run the following command in turn:


#./configure--with-apxs=/usr/local/apache/bin/apxs
# make
# CP Apache-1.3/mod_webapp.so/usr/local/apache/libexec



Now the mod_webapp.so has been made and has been copied to the Apache libexec directory.

Edit the Apache configuration file, and at the end, add the following lines:


==========================
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



As long as the "Syntax OK" shows that the mod_webapp.so has been installed successfully.

Start Apache


#/usr/local/apache/bin/apachectl Start



Visit the Http://localhost/examples to see the Tomcat example program.

Third, the configuration, management and application under the virtual host

The following is an example of how a virtual host uses both Apache and TOMCAT4

The directory structure of the virtual host host1 is as follows:


/www
|---The home directory of the host1 virtual host host1
| |--htdocs Common root: For displaying static pages or PHP programs
| |----Logs Apache access log
| |----WebApps Java application directory (new addition, no association with Tomcat's WebApps directory)
| |--root JSP root: For displaying JSP page programs
| |----Jive A SET of Java application examples
|---The home directory of the HOST2 virtual host Host2
............



The original Apache configuration file is configured like this:


=====================================
Namevirtualhost xxx.xxx.xxx.xxx

< VirtualHost xxx.xxx.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 both Apache and TOMCAT4 at the same time, you need to configure the following:

1. Edit Tomcat configuration file Server.xml and make the following modifications in the final section:


=====================================
<!--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= "Ten" 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"/>

<!--below is the new addition content-->

< Host name= "host1.mydomain.com" debug= "0" appbase= "/www/host1/webapps"
Uppackwars= "true" autodeploy= "true" >
< context path= "" docbase= "ROOT" debug= "0"/>
<!--Below is a tomcat-led management page that can also be used under a virtual host->
< 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"/>

<!--new Content end-->

</engine >

</service >
=====================================



2, edit Tomcat's administrative rights file Tomcat-users.xml, add a line in the middle:


< user username= "myname" password= "mypasswd" roles= "Standard,manager"/>



3, edit Apache configuration file, make the following modifications:


=====================================
LoadModule Webapp_module libexec/mod_webapp.so
Addmodule mod_webapp.c
Webappconnection warpconnection Warp localhost:8008

Namevirtualhost xxx.xxx.xxx.xxx

< VirtualHost xxx.xxx.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

Webappdeploy ROOT warpconnection/

#注: The purpose of this row is to use the root directory as the root of the virtual host URL and invalidate the previously defined root htdocs.
#但如果不想整个虚拟主机都使用jsp页面程序 and want to use a lot of static pages or PHP programs,
#就要使用下面这行, and put all the static pages and PHP programs in the Htdocs directory.
# Webappdeploy ROOT warpconnection/jsp

Webappdeploy Manager Warpconnection/manager
Webappdeploy Jive Warpconnection/jive
#在server. In XML, each of the definitions should add a webappdeploy here.

</virtualhost >

.............
=====================================

4, the Tomcat user is set to/www/host1/webapps all the following directory files of the owner.

It should be noted that if you want to upload or change the files below the directory, you should change their owner to Tomcat.

(if Tomcat is always running as root, this step can be omitted.) )
# Chown-r Tomcat:tomcat/www/host1/webapps
5. Restart Tomcat:
# su-tomcat-c "/opt/tomcat/bin/shutdown.sh"
# su-tomcat-c "/opt/tomcat/bin/startup.sh"
6, Back up Apache:
/usr/local/apache/bin/apachectl restart
The access http://host1.mydomain.com/manager/html will prompt for a password, and after you have entered the correct myname and MYPASSWD, you will see the "Tomcat Web Application Manager" page. The application path inside is already the information configured in the virtual host and can be managed.

The configuration and management to this virtual host is complete, and the rest is testing and application. In the example above

We have already installed the jive and have been tested to run normally.

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.