小wolf@http://blog.csdn.net/xiaolangyangyang
There are quite a few articles like this on Google. But some of them are not complete and not suitable for me. I had to write it myself
This article mainly uses httpd2.2's porny_ajp to connect to tomcat
My environment is: Centos5.2
Download the latest version of apache. The latest version is httpd-2.2.10.tar.gz
Download the latest version of tomcat. The latest version is apache-tomcat-6.0.18.tar.gz
jdk1.6
at http://apr.apache.org Download the latest apr-1.3.3 and apr-util-1.3.4
1. Start the installation
1. #Compile apr
#tar - zxvf apr - 1 . 3 . 3 . tar . gz
#cd apr - 1 . 3 . 3
#. / configure - - prefix = / usr / local / apr - httpd /
#make
#make install
2. #compile apr-util
#tar - zxvf apr - util - 1 . 3 . 4 . tar . gz #cd apr - util - 1 . 3 . 4 #. / configure - - prefix = / usr / local / apr - util - httpd / - - with - apr = / usr / local / apr - httpd / #make #make install
3. #compile httpd
#tar - zxvf httpd - 2 . 2 . 10 . tar . gz #cd httpd - 2 . 2 . 10 #. / 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:
#/ usr / local / apache2 / bin / apachectl start
Test whether the installation is correct. Use this http://yourip/ to display the apache default page. It works!
4. Configure tomcat
1) #Install JDK1.6
Download jdk from java.sun.com and install it directly
2) #Set environment variables
vim /etc/profile Add:
export JAVA_HOME=/usr/java/jdk export JRE_HOME=$JAVA_HOME/jre export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
3 ) #Install tomcat
#tar - zxvf apache - tomcat - 6 . 0 . 18 . tar . gz - C / usr / local / #mv / usr / local / apache - tomcat - 6 . 0 . 18 tomcat
4) Start tomcat and test
#/ usr / local / tomcat / bin / startup . sh
5) 访问:http://yourip:8080/如果看到默认首页证明安装成功
二.整合apache和tomcat
我这里的apache的根目录和tomcat的根目录不在同一目录,当然了你完全可以放在同一目录下
我的apache的根目录在/www tomcat的根目录在/usr/local/tomcat/webapps
修改apache的httpd.conf
添加模块:
LoadModule proxy_module modules/mod_proxy.so LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
打开Virtual hosts 即去掉Include conf/extra/httpd-vhosts.conf一行的注释
注释掉DocumentRoot和ServerAdmin
编辑httpd-vhosts.conf
添加:
<virtualhost> ServerAdmin jsjzhang@gmail.com DocumentRoot "/www/web" #此虚拟主机的主目录为/www/web <directory> Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow from all </directory> ServerName www.terr.com #只是测试,生产环境可以写为对应的域名 ProxyPass /images ! #以下几行的意思是对/images,/sna 和/news/images几个目录的访问请求由apache处理其它都由tomcat处理. ProxyPass /sna ! ProxyPass /news/images! ProxyPass / ajp://localhost:8009/ ProxyPassReverse / ajp://localhost:8009/ ErrorLog "logs/3.249-error_log" CustomLog "logs/3.249-access_log" common </virtualhost>如何有多个虚拟主机可以再添加.例如:<virtualhost> ServerAdmin jsjzhang@gmail.com DocumentRoot "/www/web2" <directory> Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow from all </directory> ServerName www.terr2.com ProxyPass /images ! ProxyPass /sna ! ProxyPass /news/images! ProxyPass / ajp://localhost:8009/ ProxyPassReverse / ajp://localhost:8009/ ErrorLog "logs/3.249-error_log" CustomLog "logs/3.249-access_log" common </virtualhost>
注: 生产环境下这些虚拟主机都是用域名访问的.因为他们都对应同一个IP。如何用IP访问一般打开的为最一个虚拟主机的主页。
把web这个网站放到tomcat的主目录/usr/local/tomcat/webapps下,其中images,sna和/news/images这三个目录放到/www/web下当然了我的apache还有其它用处所以没有和tomcat设为同一主目录为了简单你当然可以这么做,但一定要记得把apache中虚拟主机中的
修改为和你tomcat一致的主目录,例如我这里应 该设为:
三.测试
现在启动tomcat启动apache在浏览器输入http://www.terr.com/web看看效果吧,因为是测试所以我在只在hosts里面对www.terr.com做了解析。
以上就介绍了apache2.2用proxy_ajp方式整合tomcat6.0,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

PHP and Python are both high-level programming languages that are widely used in web development, data processing and automation tasks. 1.PHP is often used to build dynamic websites and content management systems, while Python is often used to build web frameworks and data science. 2.PHP uses echo to output content, Python uses print. 3. Both support object-oriented programming, but the syntax and keywords are different. 4. PHP supports weak type conversion, while Python is more stringent. 5. PHP performance optimization includes using OPcache and asynchronous programming, while Python uses cProfile and asynchronous programming.

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values and handle functions that may return null values.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

SublimeText3 Linux new version
SublimeText3 Linux latest version

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Zend Studio 13.0.1
Powerful PHP integrated development environment

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.