Get the App
SLTechnology News&Howtos  ›  Servers  › 

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

Shulou Source: shulou.com Published: 2022-06-01 09:28:13 10月03日 Update

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!

Tags: Configure support integrate simultaneously environment web pages services content variables files browsers users learning testing browsing management practical deeper information interests Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information NVidia Redmi Docker Shulou Tech Info