Apache + Tomcat + PHP + MySQL + Zend in Windows

Source: Internet
Author: User

1. Prerequisites:

Sufficient space.

If you have already installed IIS, uninstall or disable IIS. Actually, it is to close any port 80Program.

2. Software preparation

= Apache

Version: apache_2.2.6-win32-x86-no_ssl.msi

Role: Web Server

= J2sdk

Version: jdk-6u3-windows-i586-p.exe

Role: Java virtual machine. Java program running

= Tomcat

Version: apache-tomcat-6.0.2.zip

Role: Java Web application container

= Jk_mod

Version: mod_jk-apache-2.2.4.so

Role: Tomcat connectors, that is, Tomcat Connector, is the connector that Tomcat integrates into Apache

= PhP5

Version: php-5.2.5-Win32.zip

Role: PhP virtual machine. PHP programs run on it.

= Zend Optimizer

Version: ZendOptimizer-3.3.0a-Windows-i386.exe

Role: PHPCodeOptimization/decoder. Many PHP programs need it.

= MySQL

Version: mysql-noinstall-5.1.22-rc-win32.zip

Role: Database Server

3. Installation and integration

3-1 install Apache

The Installation Wizard is installed by default. Directory I installed in "D: \ apache2.2 ".

Access "http: // 127.0.0.1" in the browser. If an Apache welcome page exists, it indicates that Apache is successfully installed.

3-2 j2sdk Installation

The Installation Wizard is installed by default. The directory is installed in "C: \ Program Files \ Java \ jdk1.6.0 _ 03". We recommend that you set the environment variable "java_home" to "C: \ Program Files \ Java \ jdk1.6.0 _ 03 ".

3-3 tomcat installation

Directory I installed in "D: \ apache-Tomcat-6.0.2 ".

Access "http: // 127.0.0.1: 8080" in the browser. If an Apache welcome page exists, Tomcat is successfully installed.

3-4 jk_mod Installation

Copy the file mod_jk-apache-2.2.4.so to the Apache Module Directory (I .e. D: \ apache2.2 \ modules) and change it to "mod_jk.so ".

3-5 integration of Apache and tomcat

3-5-1 configure mod_jk

Under the Apache configuration directory (D: \ apache2.2 \ conf), create the mod_jk configuration file "workers. properties" and create the following content (between horizontal lines) in the file ):

--------------------------

# Defining a worker named worker1 and of Type ajp13

Worker. List = worker1

# Set Properties for worker1

Worker. worker1.type = ajp13

Worker. worker1.host = localhost

Worker. worker1.port = 8009

Worker. worker1.lbfactor = 1

--------------------------

Under the Apache configuration directory (D: \ apache2.2 \ conf), create the configuration file mod_jk.conf and create the following content in the file (between horizontal lines ):

--------------------------

Loadmodule jk_module modules/mod_jk.so

Jkworkersfile CONF/workers. Properties

Jklogfile logs/mod_jk.log

Jkloglevel info

Jklogstampformat "[% A % B % d % H: % m: % S % Y]"

Jkoptions + forwardkeysize + forwarduricompat + forwarddirectories

Jkrequestlogformat "% w % v % t"

Jkmount/servlet/* worker1

Jkmount/*. jsp worker1

Jkmount/*. Action worker1

Jkmount/*. Do worker1

--------------------------

Modify the "httpd-vhosts.conf" of the file under the Apache configuration directory (that is, D: \ apache2.2 \ conf \ extra), as follows (between bars ):

--------------------------

Namevirtualhost *: 80

<Virtualhost *: 80>

Serveradmin webmaster@mainsite.com

DocumentRoot D:/Apache-Tomcat-6.0.2/webapps/root

Servername localhost

Errorlog logs/localhost-error_log

Customlog logs/localhost-access_log common

</Virtualhost>

<Virtualhost *: 80>

Serveradmin webmaster@mainsite.com

DocumentRoot D:/Apache-Tomcat-6.0.2/webapps/medicine

Servername www.mainsite.com

Errorlog logs/www.mainsite.com-error_log

Customlog logs/www.mainsite.com-access_log common

<Location/Server-status>

Sethandler server-status

Order deny, allow

Deny from all

Allow from localhost

Allow from www.mainsite.com

</Location>

</Virtualhost>

<Virtualhost *: 80>

Serveradmin webmaster@mydiscuz.com

DocumentRoot D:/Apache-Tomcat-6.0.2/webapps/discuz

Servername www.mydiscuz.com

Errorlog logs/www.mydiscuz.com-error_log

Customlog logs/www.mydiscuz.com-access_log common

</Virtualhost>

3-5-2 configure Apache

Open the Apache configuration file (D: \ apache2.2 \ conf \ httpd. conf), and add the following content (between horizontal lines ):

--------------------------

Servername 127.0.0.1: 80

<Directory/>

Options followsymlinks

AllowOverride none

Order allow, deny

Allow from all

Satisfy all

</Directory>

<Ifmodule dir_module>

Directoryindex index.html index.htm index. php index. jsp

</Ifmodule>

# Virtual Hosts

Include CONF/extra/httpd-vhosts.conf

# Mod_jk (Apache + Tomcat)

Include CONF/mod_jk.conf

--------------------------

3-5-3 configure Tomcat

Open the tomcat configuration file (that is, D: \ apache-Tomcat-6.0.2 \ conf \ Server. XML) and add the following content (between horizontal lines ):

--------------------------

<Host name = "localhost" appbase = "webapps" unpackwars = "true" autodeploy = "true" xmlvalidation = "false" xmlnamespaceaware = "false">

<Context Path = "" docbase = "root" DEBUG = "0" reloadable = "false"> </context>

</Host>

<Host name = "www.mainsite.com" DEBUG = "0" appbase = "webapps" unpackwars = "true" autodeploy = "true" xmlvalidation = "false" xmlnamespaceaware = "false">

<Context Path = "" docbase = "medicine" DEBUG = "0" reloadable = "false"> </context>

<Logger classname = "org. apache. catalina. logger. filelogger "directory =" logs "prefix =" OK .com _ log. "suffix = ". TXT "timestamp =" true "/>

</Host>

--------------------------

3-5-4 Test

Modify the hosts file in the system and add two lines.

127.0.0.1 www.mainsite.com

127.0.0.1 www.mydiscuz.com

Restart Apache to access

Http: // localhost/

Http://www.mainsite.com

Http://www.mydiscuz.com

If the execution is successful, your Tomcat + Apache integration is successful.

3-6 install MySQL

Skipped

3-7 install PHP

Decompress the php-5.1.2-Win32.zip file to the C: \ PhP5 directory.

To access the MySQL database using PHP, copy the c: \ PhP5 \ libmysql. dll file to the "C: \ WINDOWS \ System32" directory. Pay special attention to this!

3-8 integration of Apache and PHP

3-8-1 configure PHP

In the "C: \ PhP5" directory, copy the "php. ini-Dist" file and change it to "php. ini ".

Modify the content in PHP. ini:

Query "extension_dir" and change it to "extension_dir =" C: \ PhP5 \ Ext "". Purpose: Tell the PHP extension module location.

Query "extension" and find an extension list. Remove the comments (namely, semicolons) before "; Extension = php_mysql.dll" and load them into the MySQL access module. If you want to use other modules, you only need to remove the preceding annotations. For example, if some programs require image verification codes, they need to remove the comments before "extension = php_gd2.dll.

3-8-2 configure Apache

Create the "php5.conf" configuration file under the Apache configuration directory (D: \ apache2.2 \ conf) and create the following content in the file (between horizontal lines ):

--------------------------

# Add to the end of the loadmodule Section

Loadmodule php5_module C:/PhP5/php5apache2_2.dll

Addtype application/X-httpd-PHP. php

# Configure the path to PhP. ini

Phpinidir "C:/PhP5"

--------------------------

You can copy and modify the content from the install.txt file in the PHP installation directory.

Open the Apache configuration file (D: \ apache2.2 \ conf \ httpd. conf), and add the following content (between horizontal lines ):

--------------------------

# PhP5

Include CONF/php5.conf

--------------------------

3-8-3 create a test file

In the "D: \ apache-Tomcat-6.0.2 \ webapps \ medicine" directory, create the file index. php, and create the following content (between horizontal lines ):

--------------------------

<? Phpinfo ();?>

--------------------------

3-8-4 Test

Restart Apache and access "http://www.mainsite.com" in the browser. If php information appears, it indicates that PHP and Apache have been integrated successfully.

You can check whether the MySQL module is successfully loaded from the related information.

3-9 install Zend Optimizer

Install in the installation wizard.

Enter "C: \ PhP5" for the directory where PHP. INI is located ";

Enter "D: \ apache \ apache2" in the Apache directory ";

Enter "D: \ wwwroot" for the web and directory ";

If the input is correct, Zend optimizer will be integrated into Apache and PHP by itself.

Restart Apache and access the http://www.mainsite.com in the browser. There is Zend version information. If "3.3" is included, it indicates that Zend has been installed successfully.

Related Article

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.