Jsp environment in Linux: Apache and Tomcat configuration

Source: Internet
Author: User

In the jsp development environment in Linux, the configuration process of apache and tomcat servers is as follows:

Note: The content of this article is based on the Internet and summarized through personal practice. If you encounter any problems in the configuration, please contact me. Some parts may be missing during the writing. Thank you for your experience on the Internet, hope more practical experience can be shared)

1. Operating System

RedHat in Linux 9.0

2. Required Software

Apache 2.0.54

Http://apache.freelamp.com/httpd

Download the file httpd-2.0.54.tar.gz

Tomcat5.5.9

Http://apache.justdn.org/jakarta/tomcat-5/v5.5.9/bin/

Download this file jakarta-tomcat-5.5.9.tar.gz

Mod_jk 1.2.14

Http://apache.justdn.org/jakarta/tomcat-connectors/jk/source/jk-1.2.14/

Download the file jakarta-tomcat-connectors-1.2.14-src.tar.gz

Jdk rj5_0_04

Http://java.sun.com/j2se/1.5.0/download.jsp

Download this file jdk-1_5_0_04-linux-i586-rpm.bin

Save the required package file to the/usr/local directory during download.

3. Installation Steps

A. Install JDK

# Cd/usr/local/

# Chmod + x jdk-1_5_0_04-linux-i586-rpm.bin

#./Jdk-1.5.0_04-linux-i586-rpm.bin

# Cd/usr/java/

# Ln-s/usr/java/The jdk-1_5_0_04/usr/local/java

# Vi/etc/profile

Add the following content:

JAVA_HOME =/usr/java/jdk-1_5_0_04

CLASSPATH =/usr/java/jdk-1_5_0_04/lib/dt. jar:/usr/java/jdk-1_5_0_04/lib/tools. jar

PATH =/usr/java/jdk-1_5_0_04/bin: $ PATH

Export PATH JAVA_HOME CLASSPATH

B. install Apache

# Cd/usr/local/

# Tar xvfz httpd-2.0.54.tar.gz

# Cd httpd-2.0.54

#./Configure -- prefix =/usr/local/apache -- enable-module = so

# Make

# Make install

# Cd/usr/local/apache/conf

# Vi./httpd. conf

Change Listen 80 to Listen 127.0.0.1: 80 (row 219)

Change ServerName to ServerName LocalHost: 80 (row 291)

Add index. jsp row 394 to DirectoryIndex)

# Cd/usr/local/apache/bin/

#./Apachectl configtest

If Syntax OK is displayed, the installation is successful.

#./Apachectl start

Start the apache service and access port 80 of the local machine in the browser to check whether the port is normal. enter 127.0.0.1: 80

#./Apachectl stop

Close service

Note: prefix defines the installation path of apache

C. install Tomcat

# Cd/usr/local/

# Tar xvfz jakarta-tomcat-5.5.9.tar.gz

# Ln? S/usr/local/jakarta-tomcat-5.5.9/usr/local/tomcat

# Vi/usr/local/tomcat/bin/catalina. sh

Add this sentence to row 3

JAVA_HOME =/usr/java/jdk-1_5_0_04

After the service is started, access port 8080 of the Local Machine to check whether the port is properly input 127.0.0.1: 8080)

#/Usr/local/tomcat/bin/startup. sh/startup. bat

Close service

#/Usr/local/tomcat/bin/shutdown. sh/shutdown. bat

D. Install JK

# Cd/usr/local/

# Tar xzvf jakarta-tomcat-connectors-1.2.14-src.tar.gz

# Cd jakarta-tomcat-connectors-1.2.14-src/jk/native

# Chmod 755 buildconf. sh

#./Buildconf. sh

#./Configure -- with-apxs =/usr/local/apache/bin/apxs

# Make

# Make install

# Cd/usr/local/jakarta-tomcat-connectors-jk1.2.14-src/jk/native/apache-2.0/

# Cp mod_jk.so/usr/local/apache/modules/

E System Integration

# Vi/usr/local/apache/conf/httpd. conf

Add the following statement at the end of the file

# Load mod_jk

LoadModule jk_module modules/mod_jk.so

# Configure mod_jk

JkWorkersFile conf/workers. properties

JkLogFile logs/mod_jk.log

JkLogLevel info

JkMount/*. jsp loadbalancer

JkMount/servlet/* loadbalancer

JkMount/application/* loadbalancer

# Vi/usr/local/apache/conf/workers. properties

Add the following statements

#

# Workers. properties

#

# In Unix, we use forward slashes:

Ps =/

# List the workers by name

Worker. list = worker at1, tomcat2, loadbalancer

#------------------------

# First tomcat server

#------------------------

Worker. tomcat1.port = 8009

Worker. tomcat1.host = 127.0.0.1

Worker. tomcat1.type = ajp13

# Specify the size of the open connection cache.

# Worker. tomcat1.cachesize

#

# Specifies the load balance factor when used

# A load balancing worker.

# Note:

# ----> Lbfactor must be> 0

# ----> Low lbfactor means less work done by the worker.

Worker. tomcat1.lbfactor = 100

#------------------------

# Second tomcat server

#------------------------

Worker. tomcat2.port = 8009

Worker. tomcat2.host = 192.168.1.34

Worker. tomcat2.type = ajp13

# Specify the size of the open connection cache.

# Worker. tomcat2.cachesize

#

# Specifies the load balance factor when used

# A load balancing worker.

# Note:

# ----> Lbfactor must be> 0

# ----> Low lbfactor means less work done by the worker.

Worker. Maid = 100

#------------------------

# Load Balancer worker

#------------------------

# The loadbalancer (type lb) worker performs weighted round-robin

# Load balancing with sticky sessions.

# Note:

# ----> If a worker dies, the load balancer will check its state

# Once in a while. Until then all work is redirected to peer

# Worker.

Worker. loadbalancer. type = lb

Worker. loadbalancer. balanced_workers = worker at1, tomcat2

#

# END workers. properties

#

# Vi/usr/local/tomcat/conf/server. xml

ProtocolHandlerClassName = "org. apache. jk. server. JkCoyoteHandler"

RedirectPort = "8443" protocol = "AJP/1.3"/> 101st rows

Add the following statement to comments in about 119 rows)

If the second tomcat server is deployed, change jvmRoute to tomcat 2.

System integration completed

Start apache and tomcat services

#/Usr/local/apache/bin/apachectl start

#/Usr/local/tomcat/bin/catalina. sh start

Add the following content to the end of the/etc/rc. d/rc. local file.

Enable the apache and tomcat services after the system starts.

# Vi/etc/rc. d/rc. local

Add

/Usr/local/tomcat/bin/catalina. sh start

/Usr/local/apache/bin/apachectl start

Related Articles]

  • Integration of Tomcat and Apache Web servers in Linux
  • Simple Integration of Apache and Tomcat in Linux
  • Detailed description of Tomcat and Java Web Development Technology

Related Article

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.