In Linux, apache integrates tomcat-Enthusiasm & nbsp; for 10 years

Source: Internet
Author: User
I. Prepare the experiment environment before installation: ReaHatEnterpriseLinux5 installation files required: The jdk-6u20-linux-i586-rpm.binhttpd-2.2.15.tar.gzapache-tomcat-6.0.26.tar.gztomcat-connectors-1.2.30-src.tar.gz uploads the installation software over FTP to the Linux server, I am temporarily put under the mineftp

I. Preparations before installation
Lab environment: ReaHat Enterprise Linux 5
Install the required files:
Jdk-6u20-linux-i586-rpm.bin
Httpd-2.2.15.tar.gz
Apache-McAt-6.0.26.tar.gz
TomCat-Connectors-1.2.30-src.tar.gz
Upload the installation software over FTP to the Linux server/FtpLower
Remotely log on to the Linux Server

Ii. JDK Installation
1. Enter
Sh jdk-6u20-linux-i586-rpm.bin

2. Check that the installer is on the page asking if you want to abide by the license agreement. Press enter and enter a space.
A line of words appears: Do you aggree to the above license teRmS? [Yes or no]
The installer asks if you are willing to comply with the license agreement you just saw. Of course you have to agree. Enter "y" or "yes" and press Enter.

3. Set environment variables inCommandLine input:
Vi/etc/proFileAppend the following content to it:
ExPort JAVA_HOME =/usr/java/jdk1.6.0 _ 20
ExportJAVA_BIN =/usr/java/jdk1.6.0 _ 20/bin
Export PATH = $ PATH: $ JAVA_BIN
Export CLASSPATH =.: $ JAVA_HOME/lib/dt. jar: $ JAVA_HOME/lib/tooLs. Jar
Export JAVA_HOME JAVA_BIN PATH CLASSPATH

4. Go to the/usr/bin/directory.Cd/Usr/bin
Ln-S-f/usr/java/jdk1.6.0 _ 17/jre/bin/java
Ln-s-f/usr/java/jdk1.6.0 _ 17/bin/javac

5. logout command:Su

6. Enter java-version in the command line.
Screen output:
Java version "jdk1.6.0 _ 20"
Java (TM) 2 RunTimeEnvironment, Standard Edition (build jdk1.6.0 _ 20)
Java HotSpot (TM) Client VM (build jdk1.6.0 _ 20, mixEdMode)

7. JDK1.6 installation is complete.

Iii. Apache installation
1. Enter in/mine/ftp:
Tar zxvf http-2.2.15.tar.gz
Cd httpd-2.2.15
./Configure -- prefix =/mine/apache2 -- with-mpm = worker --Enable-Mod-shared = all
-- Enable-proxy-http -- enable-proxy-ajp -- enable-proxy-balaNcEr
-- Enable-proxy-ftp -- enable-proxy-connect
-- Enable-so -- enable-moDuLes = so
Make
Make install
2. After the installation, apache will be installed in the/mine/apache2 directory.
3. Test apache:
Enable the apache service:/mine/apache2/bin/ApachectlStart
Command Line input: wget http: // localhost/
If:
-- 13:17:20 -- http: // localhost/
Parsing host localhost... 127.0.0.1
Connecting to localhost | 127.0.0.1 |: 80... connected.
An HTTP request has been sent and is waiting for response... 200 OK
Length: 7777 (7.6 K) [text/html]
Saving to: 'index.html'
............
The installation is successful!
4. stop the apache service:/mine/apache2/bin/apachectl stop

4. Tomcat installation
1. Enter in/mine/ftp:
Tar zxvf apache-tomcat-6.0.26.tar.gz
Tomcat is a green software,ExtractYou can use it.

2. Move the decompressed directory to/mine and change the name to tomcat6.
MvApache-tomcat-6.0.26/mine/tomcat6

3. Set Tomcat Environment Variables
Add the following content to vi/etc/profile:
TOMCAT_HOME =/mine/tomcat6
Export TOMCAT_HOME

4. Test Tomcat:
Start tomcat:/mine/tomcat6/bin/startup. sh
Command Line input: wget http: // localhost: 8080/
If:
-- 13:21:28 -- http: // localhost: 8080/
Parsing host localhost... 127.0.0.1
Connecting to localhost | 127.0.0.1 |: 8080... connected.
An HTTP request has been sent and is waiting for response... 200 OK
Length: 7777 (7.6 K) [text/html]
Saving to: 'index.html 1'
............
The installation is successful!

5. Stop tomcat:/mine/tomcat6/bin/shutdown. sh

V. JK connector Installation
1. Enter in/mine/ftp:
Tar zxvf tomcat-connectors-1.2.30-src.tar.gz
Cd tomcat-connectors-1.2.30-src/native
./Buildconf. sh
./Configure -- with-apxs =/mine/apache2/bin/apxs
Make
Make install

2. The compiled file is under the/mine/tomcat-connectors-1.2.30-src/native/apache-2.0 directory.
Move the compiled mod_jk.so file to/mine/apache2/modules /.

6. modify the configuration file
1. Modify/mine/apache2/conf/httpd. conf
A) Modify DocumentRoot "/mine/tomcat6/webapps"
B) Comment out: serverAdmin
C). Comment out: serverName
D). append at the end: Include conf/mod_jk.conf

2. Create this file/mine/apache2/conf/mod_jk.conf and add the following content:

# Loading jk Connector
LoadModule jk_module modules/mod_jk.so

# Specify the jk connector configuration file
JkWorkersFile conf/workers. properties

# Specify the uri that the jk connector forwards to tomcat
JkMountFile conf/uriworkermap. properties
 
# Specify the jk connector working Log File
JkLogFile logs/mod_jk.log
 
# Specify the jk connector Log Level
JkLogLevel info
 
# Specify the log format of jk Connector
JkLogStampFormat "[% a % B % d % H: % M: % S % Y]"
 
# Specify which requests are sent to tomcat for processing
# "Worker1" is the tomcat specified in workers. properties
JkMount/* worker1

3. Add the following content to the new file/mine/apache2/conf/workers. properties:
# Tomcat list
Worker. list = worker1
# Tomcat and apache communication protocols
Worker. worker1.type = ajp13
# Ajp13 port number
Worker. worker1.port = 8009
# Tomcat host address. Fill in the IP address if it is not the local host.
Worker. worker1.host = localhost
 
4. Add the following content to the new file/mine/apache2/conf/uriworkermap. properties:
/* = Worker1
! /*. Gif = worker1
! /*. Jpg = worker1
! /*. Png = worker1
! /*. Css = worker1
! /*. Js = worker1
! /*. Htm = worker1
! /*. Html = worker1
 
VII. Test
Now the configuration of apache and Tomcat integration is complete.
Start tomcat:/mine/tomcat6/bin/startup. sh
Enable the apache service:/mine/apache2/bin/apachectl start
Enter http: // 192.168.157.130/and http: // 192.168.157.130: 8080/in the browser/
If the display is consistent, the configuration is successful! (Note: 192.168.157.130 is the IP address of my linux Server)
Note: If the test on the Linux host is good, but the connection fails to be tested on other machines,
It may be that the firewall of Linux is blocked. Try to disable the firewall.
Firewall: service iptables start | stop | restart

8. Automatic startup
Finally, let's talk about how to enable apache and tomcat on their own when they are started. There are many ways to do this.
1. apache: Register apache as a system service
Cp/Mine/apache2/bin/apachectl/etc/rc. d/init. d/apache2
Vi/etc/rc. d/init. d/apache2
In the first line #! Add two lines of text under/bin/sh:
#Chkconfig: 35 70 30
# Description: Apache
Then register the service: chkconfig-DdApache2

2. tomcat: Add tomcat startup in the/etc/rc. local file
Vi/etc/rc. local is appended after:
JAVA_HOME = usr/java/jdk1.6.0 _ 20
Export JAVA_HOME
/Mine/tomcat6/bin/startup. sh

OK. After the server is restarted, apache and tomcat can both be started with the server.

 

 

 
 

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.