Notes on integration of apache and tomcat in CentOS

Source: Internet
Author: User
Installation of apache: Unzip: tarzxvfhttpd-2.2.21.tar.gz rename: mvhttpd-2.2.21apa.

 

I. preparation

 

Download httpd-2.2.21.tar.gz

 

Download apache-tomcat-7.0.23.tar.gz

 

Download tomcat-connectors-1.2.32-src.tar.gz connection

 

II. Installation

 

① Install apache:

 

Unzip: tar zxvf httpd-2.2.21.tar.gz

 

Renamed: mv httpd-2.2.21 apache

 

#./Configure -- prefix =/002/apache

 

# Make

 

# Make install

 

② Install tomcat

 

Tomcat can be directly run without installation or decompression

 

Compile and install atat-connectors-1.2.32-src.tar.gz

 

1. unzip the tar zxvf tomcat-connectors-1.2.32-src.tar.gz

 

2. renamed: mv tomcat-connectors-1.2.32-src.tar.gz conn

 

3. installation:

 

# Tar-xzvf tomcat-connectors-1.2.32-src.tar.gz

 

# Cd tomcat-connectors-1.2.31-src/native

 

#./Configure -- with-apxs =/002/apache/bin/apxs #/002/apache is your apache installation directory.

 

# Make

 

# Cp apache-2.0/mod_jk.so/002/apache/modules/mod_jk.so

 

④ Configure tomcat apache to start automatically

 

Manually add the tomcat service to the system. the specific configuration is as follows:

 

1. configure apache to open the terminal and enter chkconfig to list all services.

 

Chkconfig httpd on

 

2. configure tomcat

 

Cd/etc/rc. d/init. d

 

Chmod 755 tomcat

 

Vi tomcat

 

 

 

Add content

 

Startup script for the tomcat

 

#

 

# Chkconfig: 345 80 15

 

# Description: Tomcat is a Servlet + JSP Engine.

 

Export JDK_HOME =/usr/java/javaeejdk/jdk7

 

Export JAVA_HOME =/usr/java/jdk1.7.0 _ 02

 

# Enter the JDK location

 

# Source function library.

 

./Etc/rc. d/init. d/functions

 

Start (){

 

If [-z $ (/sbin/pidof java)]; then

 

Echo "Starting tomcat"

 

/002/tomcat/bin/startup. sh

 

Touch/var/lock/subsys/tomcat

 

Else

 

Echo "tomcat allready running"

 

Fi

 

}

 

Stop (){

 

If [! -Z $ (/sbin/pidof java)]; then

 

Echo "Shutting down tomcat"

 

/002/tomcat/bin/shutdown. sh

 

Until [-z $ (/sbin/pidof java)]; do:; done

 

Rm-f/var/lock/subsys/tomcat

 

Else

 

Echo "tomcat not running"

 

Fi

 

}

 

Case "$1" in

 

Start)

 

Start

 

;;

 

Stop)

 

Stop

 

;;

 

Restart)

 

Stop

 

Start

 

;;

 

Status)

 

/002/tomcat/bin/catalina. sh version

 

;;

 

*)

 

Echo "Usage: $0 {start | stop | restart | status }"

 

Esac

 

Exit 0

 

Add Service: chkconfig -- add tomcat

 

Start: chkconfig tomcat on

 

⑤ Add apache to start automatically

 

Cp/002/apache/bin/apachectl/etc/init. d/httpd

 

Sudo vi/etc/init. d/httpd

 

Add the following lines at the beginning of the file:

 

#! /Bin/sh

 

# Chkconfig: 2345 85 15

 

# Description: Apache is a World Wide Web

 

Add Service

 

# Chkconfig -- add httpd

 

Set automatic service startup

 

# Chkconfig httpd on

 

 

 

III. configuration

 

① Configure apache to support jk module

 

# Vi/002/apache/conf/httpd. conf

 

② Add the configuration file mod_jk.conf

 

Go to/002/apache/conf

 

# Cd/002/apache/conf

 

# Add the following content to vi mod_jk.conf:

 

JkWorkersFile/002/apache/conf/workers. properties

 

JkLogFile/002/apache/logs/mod_jk.log

 

JkLogLevel info

 

# Select the log format

 

JkLogStampFormat "[% a % B % d % H: % M: % S % Y]"

 

# JkOptions indicate to send ssl key size,

 

JkOptions + ForwardKeySize + ForwardURICompat-ForwardDirectories

 

# JkRequestLogFormat set the request format

 

JkRequestLogFormat "% w % V % T"

 

JkMount/servlet/* worker1

 

JkMount/*. jsp worker1

 

# Vi workers. properties

 

# Defining a worker named worker1 and of type ajp13

Worker. list = worker1

 

# Set properties for worker1

Worker. worker1.type = ajp13

Worker. worker1.host = localhost

Worker. worker1.port = 8009

Worker. worker1.lbfactor = 50

Worker. worker1.cachesize = 10

Worker. worker1.cache _ timeout = 600

Worker. worker1.socket _ keepalive = 1

Worker. worker1.socket _ timeout = 300

 

③ Configure httpd. conf

 

# Vi httpd. conf

 

Modify the following content

 

Change Listen 80 to Listen 127.0.0.1: 80

 

ServerName your host name: 80

 

Add the following to the end

 

LoadModule jk_module modules/mod_jk.so

Include/002/apache/conf/mod_jk.conf

 

IV. test

 

Write the index. jsp test file in the/var/web directory.

 

Check whether the server can be correctly parsed

 

Test passed

 

 

 

 

 

V. Summary

 

 

 

I have just touched the linux notes and the content is handwritten. it is not just a tutorial that records the process of setting up the server environment, so there is no

 

All I want to do is to take a general thought step for the installer's reference. it is best not to copy it completely.

 

The installation configuration of each software is debugged N times on the virtual machine, and the documentation is also manually written (except for some code)

 

We would like to thank our predecessors on the Internet for their experience and support.

 

From Youfeng 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.