Ubuntu 12.04 APACHE2+TOMCAT7 with the PROXY_AJP way integration steps

Source: Internet
Author: User
Tags tomcat

First download the required installation package before starting the operation.

apache2:http://httpd.apache.org/download.cgi

Apr and apr-util:http://apr.apache.org/

tomcat7:http://tomcat.apache.org/download-70.cgi

Jdk:http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html

When things are ready, start compiling and installing.

First, the compilation of APR

TAR-ZXVF apr-1.5.0.tar.gz
CD apr-1.5.0
./configure–prefix=/usr/local/apr-httpd/
Make
Make install

Second, compile Apr_util

TAR-ZXVF apr-util-1.5.3.tar.gz
CD apr-util-1.5.3
./configure–prefix=/usr/local/apr-util-httpd/–with-apr=/usr/local/apr-httpd/
Make
Make install

Third, compile Apache2

TAR-ZXVF httpd-2.2.26.tar.gz
CD httpd-2.2.26
./configure–prefix=/usr/local/apache2/–with-apr=/usr/local/apr-httpd/–with-apr-util=/usr/local/apr-util-httpd/ –enable-so–enable-mods-shared=most–enable-rewrite=shared–enable-proxy=shared–enable-proxy-ajp=shared– Enable-proxy-balancer=shared–enable-speling=shared
Make
Make install

Start Apache2 Server

/usr/local/apache2/bin/apachectl start

If there is no error, and the browser opens http://yourip/display it works! page, then the Apache installation is successful.

Set Apache2 to boot automatically, add service.

Cp-a/usr/local/apache2/bin/apachectl/etc/init.d/
Mv/etc/init.d/apachectl/etc/init.d/apache2

Edit/etc/init.d/apache2 and add the following two lines under #!/bin/bash.

# chkconfig:35 70 30
# Description:apache2

UPDATE-RC.D apache2 Defaults

Iv. installation of TOMCAT7

1. Install JDK

Tar zxvf jdk-7u55-linux-x64.gz

Mkdir-p/usr/lib/jvm/

MV jdk1.7.0_55//USR/LIB/JVM

Setting JDK Environment variables

Export java_home=/usr/lib/jvm/jdk1.7.0_55
Export JRE_HOME=/USR/LIB/JVM/JDK1.7.0_55/JRE
Export path= $JAVA _home/bin: $PATH
Export classpath=.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar: $JAVA _home/lib: $JRE _home/lib: $CLASSPATH

Finally, the following page shows the JDK setup complete.

root@ubuntu:/usr/lib/jvm# java-version
Java Version "1.7.0_55″
Java (TM) SE Runtime Environment (build 1.7.0_55-b13)
Java HotSpot (TM) 64-bit Server VM (build 24.55-b03, Mixed mode)

2. Install Tomcat

Tar zxvf apache-tomcat-7.0.52.tar.gz-c/usr/local/

Mv/usr/local/apache-tomcat-7.0.52/usr/local/tomcat7

"# OS specific support found in/usr/local/tomcat7/bin/catalina.sh. $var _must_ is set to either true or false. ", add the following two message below him to save the exit.

Catalina_home=/usr/local/tomcat7
Java_home=/usr/lib/jvm/jdk1.7.0_55

3. Start Tomcat

/usr/local/tomcat7/bin/startup.sh

If there is no error, and the browser opens http://yourip:8080/to display the default page for Tomcat, the Tomcat installation is successful.

4, set up TOMCAT7 boot

Create a new file/etc/init.d/tomcat7 and add the following content.


#!/bin/bash

#

#/ETC/RC.D/INIT.D/TOMCAT7

# init script for Tomcat precesses

#

# Processname:tomcat

# Description:tomcat is a J2SE server

# chkconfig:2345 86 16

# Description:start up the Tomcat servlet engine.

Retval=$?

Catalina_home= "/USR/LOCAL/TOMCAT7"

Case "$" in

Start

If [f $CATALINA _home/bin/startup.sh];

Then

echo $ "Starting Tomcat"

$CATALINA _home/bin/startup.sh

Fi

;;

Stop

If [f $CATALINA _home/bin/shutdown.sh];

Then

echo $ "Stopping Tomcat"

$CATALINA _home/bin/shutdown.sh

Fi

;;

*)

echo $ "Usage: $ {start|stop}"

Exit 1

;;

Esac

Exit $RETVAL
Grant TOMCAT7 after saving to execute permissions, and then run UPDATE-RC.D tomcat7 defaults.

V. Integrating TOMCAT and Apache

Modify Apache configuration file httpd.conf, add modules Proxy_module and Proxy_ajp_module, and remove comments from the Include conf/extra/httpd-vhosts.conf line.

LoadModule Proxy_module modules/mod_proxy.so
LoadModule Proxy_ajp_module modules/mod_proxy_ajp.so

......

Include conf/extra/httpd-vhosts.conf

Edit the httpd-vhosts.conf file, my settings are as follows, open the http://yourip/images handled by Apache, and the others are handled by Tomcat.


Namevirtualhost *:80


<virtualhost *:80>

ServerAdmin webmaster@dummy-host.example.com

DocumentRoot "/home/www/"

ServerName www.domain.com

<directory "/home/www/" >

Options Indexes FollowSymLinks

AllowOverride None

Order Allow,deny

Allow from all

</Directory>

Proxypass/images!

proxypass/ajp://localhost:8009/

proxypassreverse/ajp://localhost:8009/

ErrorLog "/home/wwwlogs/www.domain.com-error_log"

Customlog "/home/wwwlogs/www.domain.com-access_log" common

</VirtualHost>
Here, Apache integrated Tomcat is basically deployed to complete.

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.