PHP跟Tomcat整合

Jun 13, 2016 pm 01:08 PM
apache php tomcat

PHP和Tomcat整合

我的软件如下:

Apache2.2 ?目录:C:\Program Files (x86)\Apache Software Foundation\Apache2.2

Tomcat 5.5 目录:D:\apache-tomcat-5.5.25

PHP 目录:D:\DEV\php-5.2.13-Win32-VC6-x86

MySql Server5.2 目录:C:\Program Files (x86)\MySQL\MySQL Server 5.2

JK插件:mod_jk-1.2.28-httpd-2.2.3.so

?

需要做如下设置:

1. 安装Apache2.2,过程中让你选择域名和端口,我写的是www.seya.com,端口:80. 邮箱写个自己的好了:seyason@gmail.com.这些都在配置文件httpd.conf里,后面也可以自己改的。

?

2. 安装java JDK和设置Tomcat 环境变量,CATALINA_HOME和CATALINA_BASE设置到tomcat的根目录就行了,保证在tomcat下的bin目录下运行catalina start命令能跑起来。

?

3. 安装MySql Server5.2 都按默认配置好了,一路Next. 设置root账号的密码,比如是111111.

?

4. 配置PHP服务,让它能同时提供PHP和JSP的服务。

1》将php安装目录下的php.ini-dist文件改名为php.ini, 去掉这几行前面的分号(取消注释)

? extension=php_mbstring.dll
? extension=php_dbase.dll
? extension=php_gd2.dll
? extension=php_mysql.dll

并改extension_dir =”extension_dir = "D:/DEV/php-5.2.13-Win32-VC6-x86/ext/“ 以上那几个文件就在这个目录下。

2》配置Apache,修改C:\Program Files (x86)\Apache Software Foundation\Apache2.2\conf\httpd.conf文件

修改 DocumentRoot "D:/DEV/php-5.2.13-Win32-VC6-x86/webroot/"

修改

在ScriptAlias /cgi-bin/ "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/cgi-bin/"下面增加几行,使其支持PHP服务:

??? ScriptAlias???????????? /php/? "D:/DEV/php-5.2.13-Win32-VC6-x86/"
??? addtype??????????? application/x-httpd-php .php
??? action????????? application/x-httpd-php "/php/php.exe"

3》加载PHP模块和JK模块

?? LoadModule php5_module "D:/DEV/php-5.2.13-Win32-VC6-x86/php5apache2_2.dll"
?? AddHandler application/x-httpd-php .php

?? # configure the path to php.ini
?? PHPIniDir "D:/DEV/php-5.2.13-Win32-VC6-x86"

?? LoadModule jk_module modules/mod_jk-1.2.28-httpd-2.2.3.so

4》配置和Tomcat的集成

? 在D:\DEV\php-5.2.13-Win32-VC6-x86下新建目录ConnApaTom,在其下新建文件workers.properties, 内容如下:

? workers.tomcat_home=D:\apache-tomcat-5.5.25
workers.java_home=C:\Program Files (x86)\Java\jdk1.5.0_05
worker.list=ajp12, ajp13
worker.ajp12.port=8007
worker.ajp12.host=localhost
worker.ajp12.type=ajp12
worker.ajp12.lbfactor=1
worker.ajp13.port=8009
worker.ajp13.host=localhost
worker.ajp13.type=ajp13
worker.ajp13.lbfactor=1
worker.loadbalancer.type=lb
worker.loadbalancer.balance_workers=ajp12, ajp13
worker.inprocess.type=jni
worker.inprocess.class_path=$(workers.tomcat_home)$(ps)lib$(ps)tomcat.jar
worker.inprocess.cmd_line=start
worker.inprocess.jvm_lib=$(workers.java_home)$(ps)jre$(ps)bin$(ps)classic$(ps)jvm.dll
worker.inprocess.stdout=$(workers.tomcat_home)$(ps)logs$(ps)inprocess.stdout
worker.inprocess.stderr=$(workers.tomcat_home)$(ps)logs$(ps)inprocess.stderr

?

然后再修改C:\Program Files (x86)\Apache Software Foundation\Apache2.2\conf\httpd.conf文件, 加这么几行:

JkWorkersFile "D:/DEV/php-5.2.13-Win32-VC6-x86/ConnApaTom/workers.properties"
JkMount /servlet/* ajp13
JkMount /*.jsp ajp13
JkMount /*.do? ajp13

就是把.jsp, .do 和 /servlet的请求转到workers.properties中设置的路径去处理,也就是D:\apache-tomcat-5.5.25。 实现了将JSP整合到了PHP server下。
?

至此配置工作完成,重启Apache和Tomcat。把你的JSP项目,或者php项目放在D:\DEV\php-5.2.13-Win32-VC6-x86\webroot目录下,通过localhost:80端口都可以访问了。

?

?

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP and Python: Comparing Two Popular Programming Languages PHP and Python: Comparing Two Popular Programming Languages Apr 14, 2025 am 12:13 AM

PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

How to set the cgi directory in apache How to set the cgi directory in apache Apr 13, 2025 pm 01:18 PM

To set up a CGI directory in Apache, you need to perform the following steps: Create a CGI directory such as "cgi-bin", and grant Apache write permissions. Add the "ScriptAlias" directive block in the Apache configuration file to map the CGI directory to the "/cgi-bin" URL. Restart Apache.

The Enduring Relevance of PHP: Is It Still Alive? The Enduring Relevance of PHP: Is It Still Alive? Apr 14, 2025 am 12:12 AM

PHP is still dynamic and still occupies an important position in the field of modern programming. 1) PHP's simplicity and powerful community support make it widely used in web development; 2) Its flexibility and stability make it outstanding in handling web forms, database operations and file processing; 3) PHP is constantly evolving and optimizing, suitable for beginners and experienced developers.

How to start apache How to start apache Apr 13, 2025 pm 01:06 PM

The steps to start Apache are as follows: Install Apache (command: sudo apt-get install apache2 or download it from the official website) Start Apache (Linux: sudo systemctl start apache2; Windows: Right-click the "Apache2.4" service and select "Start") Check whether it has been started (Linux: sudo systemctl status apache2; Windows: Check the status of the "Apache2.4" service in the service manager) Enable boot automatically (optional, Linux: sudo systemctl

PHP's Purpose: Building Dynamic Websites PHP's Purpose: Building Dynamic Websites Apr 15, 2025 am 12:18 AM

PHP is used to build dynamic websites, and its core functions include: 1. Generate dynamic content and generate web pages in real time by connecting with the database; 2. Process user interaction and form submissions, verify inputs and respond to operations; 3. Manage sessions and user authentication to provide a personalized experience; 4. Optimize performance and follow best practices to improve website efficiency and security.

How to delete more than server names of apache How to delete more than server names of apache Apr 13, 2025 pm 01:09 PM

To delete an extra ServerName directive from Apache, you can take the following steps: Identify and delete the extra ServerName directive. Restart Apache to make the changes take effect. Check the configuration file to verify changes. Test the server to make sure the problem is resolved.

What to do if the apache80 port is occupied What to do if the apache80 port is occupied Apr 13, 2025 pm 01:24 PM

When the Apache 80 port is occupied, the solution is as follows: find out the process that occupies the port and close it. Check the firewall settings to make sure Apache is not blocked. If the above method does not work, please reconfigure Apache to use a different port. Restart the Apache service.

PHP in Action: Real-World Examples and Applications PHP in Action: Real-World Examples and Applications Apr 14, 2025 am 12:19 AM

PHP is widely used in e-commerce, content management systems and API development. 1) E-commerce: used for shopping cart function and payment processing. 2) Content management system: used for dynamic content generation and user management. 3) API development: used for RESTful API development and API security. Through performance optimization and best practices, the efficiency and maintainability of PHP applications are improved.

See all articles