XP Build Apache+tomcat+jsp+php+mysql Environment Tutorial

Source: Internet
Author: User
Tags apache windows php online php print php windows vc9
I. Environmental description

1. Windows XP

2, apache_2.2.11-win32-x86-no_ssl.msihttp://httpd.apache.org/

3, mod_jk-1.2.28-httpd-2.2.3.sohttp://tomcat.apache.org/download-connectors.cgi

4, apache-tomcat-6.0.18.ziphttp://archive.apache.org/dist/tomcat/tomcat-6/v6.0.18/src/

5, mysql-5.5.15-win32.msihttp://www.mysql.com/

6, php-5.4.35-win32-vc9-x86http://windows.php.net/download/#php -5.4-ts-vc9-x86

7, jdk-7-ea-bin-b134-windows-i586-17_mar_2011


Package Download Address:


My programs are installed separately to




Second, the program installation

Ⅰ, Apache Installation

Note: This example only intercepts the need to be aware of, the other default is not displayed.

1. Server information can be configured by default, if the server's 80 port is not occupied by other server programs. Optional "for all Users,on Port 80,as a Service?" Recommended. " If you are only using 8080 ports for the current user, manually start, and select "Only for the onPort 8080, when started manually." The port number can be modified through a configuration file.

2. "Typical" is the default installation, "Custom" for user-defined installation.

The default installation path can be changed by selecting "Change", and this example is installed by default.

Note: If an Apache service entry does not appear in the Service management list after you install it, it indicates that an error occurred during the installation process, which can be installed manually.

Use cmd to enter D:\webserver\Apache2.2\bin This is my native installed directory and executes the Httpd-k install command, which prompts you to see the Apache service in the service management list after success.

3. Running

If the port selected above is 8080, enter http://localhost:8080/.

If it is port 80, enter http://localhost/.

Ⅱ, MySQL Installation

1. Modify the path as needed, the default installation is, mainly MySQL configuration.

2. Select the configuration mode: "Detailedconfiguration (Manual precise configuration)", "Standard Configuration", select "Detailed Configuration",

3. Select the server type, "Developer Machine (Development test class, MySQL occupies very little resources)", "Server machine (server type, MySQL takes up more resources)", "dedicated MySQL server Machine (dedicated database server, MySQL occupies all available resources) ", General Select" Server machine ". Can be selected according to the actual situation.

4. Select the general purpose of MySQL database, "Multifunctional database (Universal multifunction, good)", "Transactional database only (server type, focus on transaction processing, general)", " Non-transactional Database only (non-transactional, simpler, mainly to do some monitoring, counting, support for MYSAM data types is limited to non-transactional) ", select" Transactional Database only ", this example selects the Universal multifunction type.

5. InnoDB tablespace configuration, is to select a storage space for InnoDB database files, if modified, to remember the location, re-install the time to choose the same place, otherwise it may cause database corruption, of course, do a backup of the database is no problem. Use the default location.

6. Select half of the Web site MySQL traffic, simultaneous connections, "decision Support (DSS)/olap (20)", "Online Transaction Processing (OLTP) (500 or so)", " Manual Setting (manually set, lose one number) ", select" Online Transaction processing (OLTP) ". Choose the manual setting, depending on your needs.

7. Whether to enable TCP/IP connection, set the port, if not enabled, you can only access the MySQL database on your own machine, select "Enable TCP/IP Networking" to enable TCP/IP connection, set the port, if not enabled, You can only access the MySQL database on your own machine and select "Enable TCP/IP Networking".

8. Set the database language encoding, "standard Character set" for Western encoding, "best supportfor Multilingualism" for RTF-8 encoding, "manualselected Default Character set/collation "To manually set the encoding, select UTF8 here.

9. "Install as Windows Service" Choose to install the MySQL service, you can customize the name of the service.

"Include Bin Directory in Windows PATH" is an environment variable that adds MySQL to the machine.

10. Select "Modify Security Settings" To check the "Enableroot Access from remote machines" according to the actual requirements so that it can be accessed from other machines.

11. When the configuration is complete, click "Execute" to execute the configuration.

The MySQL installation operation is complete.

Test MySQL

Ⅲ, PHP installation

1. Copy the php.ini-dist in E:\Program files\php to php.ini.

If you do not have a php.ini-dist file, you can use the Php.ini-development file and change the name to PHP.ini (Leave a backup, good habit)

Php.ini-development for development

Php.ini-produciton for production machines

2. Open D:\webserver\PHP5\php.ini to modify the following line of statements:

3, Extension_dir = "D:\webserver\PHP5\ext"

4, default_charset= "Utf-8"

5, will Extension=php_exif.dll, Php_gd2.dll, Php_imap.dll, Php_mbstring.dll, Php_mcrypt.dll, Php_mime_magic.dll, Php_ Mysql.dll, Php_mysqli.dll, Php_pdf.dll in front of the semicolon ";" removed.

6. In the "Path" of "Environment variable", add:; D:\webserver\PHP5; D:\webserver\PHP5\ext of two values.

7. Other configurations

A, in the writing PHP program sometimes this warning appears: PHP warning:date (): It is not safe to rely on the system's timezonesettings. You is *required* to use the Date.timezone setting or Thedate_default_timezone_set () function. In case you used any of those methods andyou is still getting this warning, your most likely misspelled the Timezoneidenti Fier. We selected ' UTC ' for ' 8.0/no DST ' instead in D:\xxx\xxx\xxx.php online 10. This is because PHP takes time is Greenwich Mean time, so and your local time will be the difference between Greenwich Mean time and Beijing time is about 8 hours, we can follow the following method to solve:

① use Date_default_timezone_set () in the header to set my default time zone to Beijing time, that 's it.

② set the value of Date.timezone in php.ini to PRC, set the following as: DATE.TIMEZONE=PRC, and also cancel the comment of this line of code, that is, to remove the preceding semicolon is OK.

8, the configuration of httpd.conf:

httpd.conf File Location: D:\webserver\Apache2.2\conf

This is the directory where I installed my machine. Note: There are many tutorials on the web that need to copy the PHP directory to a DLL file under System32, in fact, this is not necessary, just need to load the PHP module in httpd.conf.

Add and modify the following line of statements:


① If you have a link to the MySQL database

Fatal Error:call to Undefinedfunction mysql_connect () in C:\xxxxx.php

That's because you didn't add this property.

② If there is no php5apache2_2.dll in the PHP installation directory, it must be the wrong version of the download.

It should be php-5.4.35-win32-vc9-x86.

Default path and default index can be modified according to your needs

Note: The directory delimiter required in Apache Windows profile httpd.conf is a slash "/", while the PHP Windows configuration file php.ini requires a backslash "\" to write the directory, so don't confuse it.

Configure the test to create index.php print PHP configuration information in the specified directory (default is Htdocs).

Code for


Run the effect where MySQL, mysqli loaded after the show can be connected with MySQL

Ⅳ, Tomcat and Apache integration

1, why need integration?

The main reason for consolidation is to provide maximum load under existing hardware conditions.

If you use Tomcat alone as a JSP server, there will be problems in productivity, Tomcat processing static HTML is not as good as Apache, and can withstand the maximum number of concurrent connections also have a certain limit;

In testing, when there are more concurrent connections, Tomcat is in a "zombie" state and loses its response to subsequent request connections. So now put forward a "consolidation" solution: the HTML and JSP functional parts of the clear division of labor, so that Tomcat only deal with the JSP part, the other by the Apache this web

Server processing. Apache and Tomcat do their own work, so the overall efficiency of the server can be improved.

Because we do not only need PHP to do the site, but also use JSP, and also need to integrate Tomcat and Apache.

2. Java Environment Configuration

JSP run must yes Java support

The installation package is installed properly and the environment variable is configured after completion.

In the "My Computer" environment variable, add JAVA system variables, the operation is to create a new variable named "Java_home" in the "System variables" area, the variable value is the installation path of the JDK, such as "D:\Program files\java\jdk1.7.0" Then add the java_home to the system variable path by editing open the system variable path, adding the code in double quotation marks before the original variable value "%java_home%/bin;", where the semicolon separates and is indispensable.

Running Javac in CMD will cause information to be installed successfully.

3. Tomcat Environment Configuration

We are using a free-install version of Tomcat, directly extracted to the D:\webserver.

Add the following environment variable (assuming your Tomcat is installed in D:\webserver\apache-tomcat-6.0.18) to the system variable, high-level environment variable, my computer, properties, and so on:




You can then start Tomcat, Access http://localhost:8080 in IE, and if you see the Tomcat Welcome page, the installation is successful.

4. Apache and Tomcat Integration

A. Copy mod_jk-1.2.28-httpd-2.2.3.so to D:\webserver\Apache2.2\modules (my Apache installation directory)

B. Create a new Workers.properties file with the following contents:

workers.tomcat_home=d:\webserver\apache-tomcat-6.0.18# let the MOD_JK module know the location of Tomcat Workers.java_home=d:\programfiles\ java\jdk1.7.0 #让mod_jk模块知道jre的位置 worker.list=ajp13 #模块版本worker. ajp13.port=8009 #工作端口, do not modify if not occupied worker.ajp13.host= LocalHost #本机, if the above Apache host is not localhost, make the corresponding modification worker.ajp13.type=ajp13 #类型worker. ajp13.lbfactor=1 #代理数 without modification

Copy to D:\WEBSERVER\APACHE-TOMCAT-6.0.18\CONF\JK, this is my Tomcat's installation directory.

C. Add the configuration at the bottom of the Apache httpd.conf content:

#tomcatLoadModule jk_module Modules/mod_jk-1.2.28-httpd-2.2.3.sojkworkersfile "d:/webserver/apache-tomcat-6.0.18/ Conf/jk/workers.properties "Jklogfile" D:/webserver/apache-tomcat-6.0.18/logs/mod_jk2.log "JkLogLevel info 
  ServerAdmin @hbu. Cn#documentroot d:/servername localhostdirectoryindex index.html index.htm Index.jsperrorlog logs/shsc-error_log.txtcustomlog logs/shsc-access_log.txt commonjkmount/servlet/* ajp13JkMount/* . JSP ajp13jkmount/*.do ajp13

After the configuration is complete, Apache tests the jsp,servlet,.do request with Tomcat. Other files are handled by Apache because of the stability of Apache and

Security, as well as the fast static page processing speed relative to Tomcat, can also improve the load capacity of the site, provided that the site has more static pages, such as static.

D.apache and Tomcat directory unification

This is the directory where Tomcat is unified.

Open the httpd.conf under D:\webserver\Apache2.2\conf

Find the default path for DocumentRoot and directory set to Tomcat

5. Tomcat Performance optimization

A. Thread pool optimization

In order to improve the website's access performance, we often select the appropriate deployment environment on the server side. The simplest is a tomcat, but in the case of high concurrency, it is very
Easy to be a machine. Because the tomcat configuration is not optimized. I didn't pay attention to these details at the earliest, because I knew that the performance of a project was not built by the environment, but the efficiency of the algorithm, the code
Reasonable use of the database, optimization of the use of technology and so on. However, optimizing the deployment environment is one of the most straightforward scenarios. Now I know of a tomcat optimization
The scenario is to use the Tomcat thread pool. You only need to change the configuration in the Server.xml. Core Configuration code:


Reference documents:

1, PHP Environment (APACHE,PHP,MYSQL) Detailed configuration method


2, apache2.2.11+tomcat6.0.18 Integration and actual combat notes, tomcat optimization of communication


3. Build apache+tomcat+jsp+php+mysql environment under Windows XP


4. Apache and Tomcat cluster configuration


5. Configuration of Tomcat environment variables


6. Windows environment Configuration apache+mysql+php


  • 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.