Tutorial on building an Apache + Tomcat + JSP + PHP + MYSQL environment using XP

Source: Internet
Author: User
Tags apache windows php online php windows vc9
Build an Apache + Tomcat + JSP + PHP + MYSQL environment using XP tutorial 1. environment description

1. Window 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

4366apache-tomcat-6.0.18.zip http://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

Http://www.oracle.com/technetwork/java/javase/downloads/index.html

Packaging:

Http://download.csdn.net/detail/itas109/8226595

My programs are installed on

D: \ webserver \ Apache2.2

D: \ webserver \ PHP5

D: \ webserver \ Tapache-tomcat-6.0.18

II. program installation

I. install Apache

Note: In this example, you only need to note that the screenshot is not displayed by default.

1. the server information can be configured by default if Port 80 of the server is not occupied by other server programs. Optional "for All Users, on Port 80, as a Service? Recommended. "If you are using port 8080 only for the Current User, start it Manually and select" only for the Current User, onPort 8080, when started Manually .". The port number can be modified through the configuration file.


2. "Typical" is the default installation, and "Custom" is the Custom installation.

You can select "Change" to Change the default installation path. In this example, the default installation path is used.


Note: If no apache service item is displayed in the service management list after installation, it indicates that an error occurs during the installation process. you can manually install the service.

Run cmd to enter D: \ webserver \ Apache2.2 \ bin. this is the local installation directory and run the httpd-k install command. after the prompt is successful, you can see the apache service in the service management list.

3. run

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

For port 80, enter http: // localhost /.

II. install MySQL

1. modify the path as needed and install it by default, mainly for MySQL configuration.

2. select the Configuration method: "DetailedConfiguration (manual precise Configuration)", "Standard Configuration (Standard Configuration)", and "Detailed Configuration ",

3. select the Server type, "Developer Machine (development and testing class, mysql occupies a small amount of resources)", "Server Machine (Server type, mysql occupies a large amount of resources) "," Dedicated MySQL Server Machine (Dedicated Database Server, mysql occupies all available resources) ", generally select" Server Machine ". You can select one based on the actual situation.


4. select the general purpose of the mysql Database, "Multifunctional Database (universal multi-function type, Good)", "Transactional Database Only (server type, dedicated to transaction processing, general) "," Non-Transactional Database Only (non-transaction processing type, relatively simple, mainly used for monitoring and recording, the support for MySAM data types is limited to Non-transactional )", select "Transactional Database Only". In this example, the general multi-function type is selected.

5. configure InnoDB Tablespace to select a bucket for the InnoDB database file. if you modify the bucket, remember the location and select the same place for the reinstallation. Otherwise, the database may be damaged, of course, it is okay to back up the database. Use the default location.

6. select half of the site's mysql traffic and the number of connections at the same time, "demo-support (DSS)/OLAP (about 20)", "Online Transaction Processing (OLTP) (about 500) "," Manual Setting (Manual Setting, input a number by yourself) ", and select" Online Transaction Processing (OLTP )". Select as needed. select manual here.

7. whether to Enable TCP/IP connection and set the port. if it is not enabled, you can only access the mysql database on your own machine and select "Enable TCP/IP Networking" to Enable TCP/IP connection, set the port. if it is not enabled, you can only access the mysql database on your machine and select "Enable TCP/IP Networking ".

8. set Database language encoding, "Standard Character Set" is Spanish encoding, "Best SupportFor Multilingualism" is RTF-8 encoding, and "ManualSelected Default Character Set/Collation" is manual encoding. select utf8 here.


9. select "Install As Windows Service" to Install the MySql Service. you can customize the Service name.

"Include Bin Directory in Windows PATH" is an environment variable for adding MySql to a machine.


10. select "Modify Security Settings" to check "Enableroot access from remote machines" as required to allow access from other machines.

11. after completing the configuration, click "Execute" to Execute the configuration.

MySql installation is complete.

Test MySql

III. PHP installation

1. copy PHP. ini-dist from E: \ Program Files \ php to php. ini.

If you do not have a php. ini-dist file, use the php. ini-development file and change the name to php. ini (keep a backup. good practice)

Php. ini-development for development

Php. ini-produciton

2. open D: \ webserver \ PHP5 \ php. ini and modify the following statement lines:

3. extension_dir = "D: \ webserver \ PHP5 \ ext"


4. default_charset = "UTF-8"

5. remove the semicolon ";" Before extension = php_exif.dll, php_gd2.dll, php_imap.dll, php_mbstring.dll, php_mcrypt.dll, connector, php_mysql.dll, connector, and php_pdf.dll.

6. add the following two values to Path of environment variable:; D: \ webserver \ PHP5; D: \ webserver \ PHP5 \ ext.

7. other configurations

A. Sometimes the following Warning occurs when writing a php program: PHP Warning: date (): It is not safe to rely on the system's timezonesettings. you are * required * to use the date. timezone setting or thedate_default_timezone_set () function. in case you used any of those methods andyou are still getting this warning, you most likely misspelled the timezoneidentifier. we selected 'utc' for '8. 0/no DST 'Instead in D: \ xxx. php online 10. This is because the time taken by PHP is Greenwich mean time, so there will be a difference between the GMT standard time and the Beijing time by about eight hours. we can solve this problem as follows:

① Use date_default_timezone_set () in the page header to set my default time zone to Beijing time, that is You can.

② In php. set date in ini. the value of timezone is PRC, and the value after setting is date. timezone = PRC, cancel the comments of this line of code at the same time, that is, remove the semicolon above.

8. httpd. conf configuration:

Location of the httpd. conf file: D: \ webserver \ Apache2.2 \ conf

This is my local installation directory. Note: There are many tutorials on the Internet saying that you need to copy the xx dll file under the php directory to system32. In fact, this is not necessary. you only need to load the php module in httpd. conf.

Add and modify the following statement lines:

LoadModule php5_module "E:/PHP5/php5apache2_2.dll" PHPIniDir "E:/Program Files/PHP5"AddType application/x-httpd-php .php.phtml 

Note:

① If you appear when connecting to the MySql database

Fatal error: Call to undefinedfunction mysql_connect () in C: \ xxxxx. php

This is because you have not added this attribute.

② If php5apache2_2.dll is not found in the php installation directory, the downloaded version must be incorrect.

Should be php-5.4.35-Win32-VC9-x86

The default path and default index can be modified as needed.

Note: The Apache Windows configuration file httpd. the directory separator required in conf is the slash "/", while the PHP Windows configuration file php. when writing a directory in ini, it requires a backslash "\". do not mix it up.

Configuration test: Create index. php in the specified directory (htdocs by default) to print the php configuration information.

The code is

 

The running results show that mysql and mysqli can be connected to mysql after being loaded.


IV. Integration of tomcat and Apache

1. why integration?

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

If you use Tomcat as a JSP server separately, there will be problems in terms of work efficiency. Tomcat's ability to process static HTML is not as good as Apache, and the maximum number of concurrent connections that can be tolerated is also limited;

During the test, when there are many concurrent connections, Tomcat will be in the "frozen" state and will lose response to the subsequent request connections. So now we propose a "integration" solution: to clearly divide the functional parts of html and jsp, so that tomcat can only process the jsp part, and the other parts are the web

Server. If Apache and Tomcat perform their respective duties, the overall server efficiency will be improved.

Because we need not only PHP but also JSP, but also tomcat and Apache integration for website creation.

2. java environment configuration

Jsp is required for running java

The installation package is properly installed, and environment variables are configured after completion.

Add a JAVA system variable in the environment variable "My Computer". Specifically, create a variable named "JAVA_HOME" in the "system variables" area, the variable value is the JDK installation Path, such as "D: \ Program Files \ Java \ jdk1.7.0". Then, add JAVA_HOME to the system variable Path by editing and opening the system variable Path, add the code "% JAVA_HOME %/bin;" in double quotation marks before the original variable value. The semicolon serves as a separator and is indispensable.

Run javac in cmd. information will appear after successful installation.

3. tomcat environment configuration

We use an installation-free version of tomcat and directly decompress it to D: \ webserver.

Choose my computer> Properties> Advanced> environment variables> System variables to add the following environment variables (assuming that your tomcat is installed on D: \ webserver \ apache-tomcat-6.0.18 ):

CATALINA_HOME: D: \ webserver \ apache-tomcat-6.0.18

CATALINA_BASE: D: \ webserver \ apache-tomcat-6.0.18

TOMCAT_HOME: D: \ webserver \ apache-tomcat-6.0.18

Start tomcat and access http: // localhost: 8080 in IE. if you see the welcome page of tomcat, the installation is successful.

4. Integration of Apache and tomcat

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

B. create the workers. properties File. the content is as follows:

Workers. tomcat_home = D: \ webserver \ apache-tomcat-6.0.18 # Let the mod_jk module know the Tomcat location workers. java_home = D: \ ProgramFiles \ Java \ jdk1.7.0 # Let the mod_jk module know the jre location worker. list = ajp13 # module version worker. ajp13.port = 8009 # working port. do not modify worker if it is not occupied. ajp13.host = localhost # this machine. if the above Apache host is not localhost, modify worker accordingly. ajp13.type = ajp13 # type worker. ajp13.lbfactor = 1 # Number of proxies, no need to modify

Copy to D: \ webserver \ apache-tomcat-6.0.18 \ conf \ jk. this is the installation directory of my tomcat.

C. add the configuration at the bottom of apache httpd. conf:

#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 configuration is complete, apache submits jsp, servlet, and. do requests to tomcat for processing. Other files are processed by apache because of its stability and

Security, as well as fast static page processing speed compared with tomcat, can also improve the load capability of the website, provided that there are many static pages on the website, such as static.

D. Unified apache and tomcat directories

This is the tomcat directory.

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

Find the default path where DocumentRoot and Directory are set to tomcat.


5. tomcat performance optimization

A. thread pool optimization

To improve the website access performance, we often choose an appropriate deployment environment on the server side. The simplest thing is a tomcat, but in the case of high concurrency
Easy to act as a machine. Because tomcat configuration is not optimized. I did not pay attention to these details at the earliest, because I know that the performance of a project is not reflected by setting up an environment, but by algorithm efficiency and code implementation.
The rationality of the current situation, the rational use of databases, and the use of optimization technologies. However, optimizing the deployment environment should be the most direct solution. I currently know a tomcat optimization method.
The solution is to use the tomcat thread pool. You only need to modify the configuration in server. xml. Core configuration code:

           
     
     
      
 

References:

1. PHP environment (apache, PHP, Mysql) detailed configuration method

Http://blog.csdn.net/jt521xlg/article/details/7533477

2. Apache2.2.11 + Tomcat6.0.18 integration with practical notes and Tomcat optimization

Http://www.cnblogs.com/shiyangxt/archive/2009/08/03/1537842.html

3. build an Apache + Tomcat + JSP + PHP + MYSQL environment in windows XP

Http://blog.csdn.net/annkie/article/details/7588033

4. Apache and Tomcat cluster configuration

Http://www.cnblogs.com/obullxl/archive/2011/06/09/apache-tomcat-cluster-config.html

5. tomcat environment variable configuration

Http://www.cnblogs.com/mingforyou/archive/2012/04/04/2432025.html

6. configure Apache + Mysql + PHP in Windows

Http://www.cnblogs.com/homezzm/archive/2012/08/01/2618062.html

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.