Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to integrate RHEL5 Apache+Tomcat and support jsp and php at the same time

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article focuses on "how to achieve RHEL5 Apache+Tomcat integration and support jsp and php at the same time", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let the editor take you to learn how to integrate RHEL5 Apache+Tomcat and support jsp and php at the same time.

Configure the environment:

OS: RHEL5 with kernel 2.6.18-8.1.1.el5

Httpd-2.2.3-6.el5.i386.rpm

Apache-tomcat-6.0.14.tar.gz

Jdk-6u3-linux-i586.bin

Mod_jk-1.2.23-apache-2.2.x-linux-i686.so

It is officially announced that mod_jk-1.2.26-httpd-2.2.6.so supports Apache 2.2.x and 2.2.6 and later, but experiments show that 1.2.26 mod_jk will report an error in RHEL5.

Download address:

Http://java.sun.com/javase/downloads/index.jsp

Http://www.apache.org/dist/tomcat/tomcat-connectors

Http://apache.mirror.phpchina.com/tomcat/tomcat-connectors/jk/binaries/linux/jk-1.2.23/

1. Install and configure jdk and tomcat

1. Install jdk and tomcat

[root@wardking] # tar zxvf apache-tomcat-6.0.14.tar.gz-C / usr/local/

[root@wardking ~] # mv jdk-6u3-linux-i586.bin / usr/local/

[root@wardking ~] # cd / usr/local

[root@wardking local] # chmod axix jdk-6u3-linux-i586.bin

[root@wardking local] #. / jdk-6u3-linux-i586.bin

2. Configure environment variables

[root@wardking ~] # ln-sf / usr/local/apache-tomcat-6.0.14 / usr/local/tomcat

[root@wardking ~] # ln-sf / usr/local/jdk1.6.0_03 / usr/local/jdk6

[root@wardking ~] # ln-sf / usr/local/jdk6/bin/java / usr/bin/

[root@wardking ~] # ln-sf / usr/local/tomcat/bin/startup.sh / usr/bin/tomcat-up

[root@wardking ~] # ln-sf / usr/local/tomcat/bin/shutdown.sh / usr/bin/tomcat-down

Add an administrator user named "michael"

[root@wardking ~] # vi / usr/local/tomcat/conf/tomcat-users.xml

Set environment variabl

[root@wardking ~] # vi / etc/profile

JAVA_HOME=/usr/local/jdk6

CATALINA_HOME=/usr/local/tomcat

CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$CATALINA_HOME/lib/servlet-api.jar

PATH=$JAVA_HOME/bin:$PATH

Export JAVA_HOME CATALINA_HOME CLASSPATH PATH

[root@wardking ~] # source / etc/profile

3. Test the tomcat service

[root@wardking ~] # / usr/bin/tomcat-up

Or execute directly.

/ usr/local/tomcat/bin/startup.sh

Check whether tomcat is started

[root@wardking ~] # netstat-anp | grep 8080

Visit http://localhost:8080/ in the browser, you can see the web interface of tomcat, and you can use the

User "michael" login management

Stop the tomcat service

[root@wardking ~] # tomcat-down

Connect tomcat to apache

1. Install the mod_jk module

[root@wardking ~] # cp mod_jk-1.2.23-apache-2.2.x-linux-i686.so / etc/httpd/modules/

2. Modify apache configuration file

[root@wardking ~] # vi / etc/httpd/conf.d/mod_jk.conf

LoadModule jk_module modules/mod_jk-1.2.23-apache-2.2.x-linux-i686.so

JkWorkersFile "/ etc/httpd/conf/workers.properties"

JkShmFile / var/log/httpd/mod_jk.shm

JkLogFile "/ var/log/httpd/mod_jk.log"

JkLogLevel info

JkMount / * / servlet/* ajp13

JkMount / * .jsp ajp13

JkMount / * .do ajp13

AddType application/x-jsp .jsp

3. Add tomcat configuration file

[root@wardking ~] # vi / etc/httpd/conf/workers.properties

[shm]

File=/etc/httpd/logs/shm.file

Size=1048576

[channel.socket:localhost:8009]

TomcatId=localhost:8009

[uri:/jsp-examples/*]

Workers.tomcat_home=/usr/local/tomcat

Workers.java_home=/usr/local/jdk6

Ps=\

Worker.list=ajp13

Worker.ajp13.port=8009

Worker.ajp13.host=localhost

Worker.ajp13.type=ajp13

Worker.ajp13.lbfactor=1

4. Set up the tomcat home directory

[root@wardking ~] # vi / usr/local/tomcat/conf/server.xml

5. Confirm the startup of apache and tomcat

[root@wardking ~] # httpd-t

[root@wardking ~] # service httpd restart

[root@wardking ~] # / usr/bin/tomcat-up

6. Test access to php and jsp pages respectively

[root@wardking ~] # vi / var/www/html/showtime.jsp

Now Time is:

[root@wardking ~] # echo'> phpinfo.php

To access http://localhost/showtime.jsp in a browser, the system time should be displayed on the web page.

Visit http://localhost/phpinfo.php to display php and server-related configuration information

Another consolidation approach is to use reverse proxies in httpd.conf:

ProxyPass / images!

ProxyPass / icons!

ProxyPass / ajp://127.0.0.1:8009/

ProxyPassReverse / ajp://127.0.0.1:8009/ at this point, I believe you have a deeper understanding of "how to achieve RHEL5 Apache+Tomcat integration and support both jsp and php". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report