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

Source: Internet
Author: User
Tags apache windows local time 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



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






Packaged:



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






My programs are installed separately to



D:\webserver\Apache2.2



D:\webserver\PHP5



D:\webserver\Tapache-tomcat-6.0.18












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 is, <?phpdate_default_timezone_set ("PRC"); > It's ready.



② 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 , httpd.conf configuration:



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:











Attention:



① 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





<?php
   phpinfo();
?>

Run effectwhere MySQL, mysqli after loading indicates that it can be connected with MySQL








Ⅳ, Tomcat and Apache integration



1 , why do we 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:



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






You can then start Tomcat, Access http://localhost:8080in 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 #Let mod_jk know the location of jre
 
worker.list = ajp13 #Module version
worker.ajp13.port = 8009 #Working port, if it is not occupied, you do not need to modify it
worker.ajp13.host = localhost #This machine, if the above Apache host is not localhost, modify it accordingly
worker.ajp13.type = ajp13 #type
worker.ajp13.lbfactor = 1 #Number of agents, 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:





#tomcat
LoadModule jk_module modules/mod_jk-1.2.28-httpd-2.2.3.so
JkWorkersFile"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
 
<VirtualHost localhost>
ServerAdmin @hbu.cn
#DocumentRoot D:/
ServerName localhost
DirectoryIndex index.html index.htm index.jsp
ErrorLog logs/shsc-error_log.txt
CustomLog logs/shsc-access_log.txt common
JkMount /servlet/* ajp13
JkMount /*.jsp ajp13
JkMount /*.do ajp13
</VirtualHost>

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:





<Executor name="tomcatThreadPool"namePrefix="catalina-exec-"
       maxThreads="1000" minSpareThreads="50"maxIdleTime="600000"/>
   
   
    <!-- A"Connector" represents an endpoint by which requests are received
         and responses arereturned. Documentation at :
         Java HTTPConnector: /docs/config/http.html (blocking & non-blocking)
         Java AJP  Connector: /docs/config/ajp.html
         APR (HTTP/AJP)Connector: /docs/apr.html
         Define a non-SSLHTTP/1.1 Connector on port 8080
    -->
    <!--
    <Connectorport="8086" protocol="HTTP/1.1"
              connectionTimeout="20000"
              redirectPort="8443" URIEncoding="UTF-8"/>
    -->
    <!-- A"Connector" using the shared thread pool-->
 
    <Connectorexecutor="tomcatThreadPool"
              port="8080" protocol="HTTP/1.1"
              connectionTimeout="20000"
              redirectPort="8443" />





Reference documents:



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 and actual combat notes,Tomcat optimization of communication



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



3. build apache+tomcat+jsp+php+mysql environment under 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 . Configuration of Tomcat environment variables



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



6.Windows Environment configuration apache+mysql+php



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









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


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.