Comprehensive integration of Apache + MySQL + PHP + JSP (Tomcat) + CGI + ASP in Windows

Source: Internet
Author: User
Tags file info php website sapi install perl

The operating system used for installation in this article is Windows XP Professional Edition. Follow these steps to complete the installation!
NOTE: If IIS is pre-installed, stop or disable the IIS service first.

1. Preparations before installation
Program list:
Apache_2.0.47-win32-x86-no_ssl.msi
Mysql-4.0.12-win
Php-4.3.2-Win32
J2sdk-1_4_2-windows-i586-iftw.exe
Jakarta-tomcat-5.0.4.exe
Mod_jk-2.0.46.dll
ActivePerl-5.6.1.635-MSWin32-x86
Iasp2.1.01.exe
These programs are basically the latest version. You can download them from their official website. You can search for them using Google .com or other search engines!

2. install Apache
Click the file apache_2.0.47-win32-x86-no_ssl.msi to install, select the target directory: G:/amicrasy/myweb /... (Several services are installed in this directory ,... the directory name of the corresponding service, as shown in the following figure ).
Go to G:/amicrasy/myweb/Apache Group/apache2/CONF/httpd. conf and modify httpd. conf.
----------------------------------------
# Userdir "My Documents/my website" // added above #
Adddefacharcharset gb2312 // default encoding
Directoryindex index.html index.htm index. php index. jsp // default page
----------------------------------------
Start monitor Apache servers. Apache installation is complete at this time.

3. Install MySQL
Open setup. EXE in the mysql-4.0.12-win directory for installation, and select: G:/amicrasy/myweb /.... After the installation is complete, restart the computer and start winmysqladmin. MySQL can be started at this time.
After MySQL is started, perform the following operations to try MYSQL:
Start-> Run-> "cmd" and enter the following command:
G:
CD amicrasy/myweb/MySQL/bin
MySQL
Show databases;
Use MySQL;
Show tabales
Select host, user, password from user
Select User ();
Create Database mydata;
Drop database mydata;
Quit;
Exit
Through these operations, we can perform simple MySQL operations.

4. PHP installation
Copy the php-4.3.2-Win32 directory to the directory G:/amicrasy/myweb/... and change the directory name to PhP.
Next, configure G:/amicrasy/myweb/PHP, change the file name PHP. ini-Dist to PhP. ini, open PHP. ini, and modify the parameters:
----------------------------------------
Session. save_path C:/Windows/temp
----------------------------------------
Note: C:/Windows/temp. the Windows directory varies depending on the installed operating system. For example, if Win2000 is used, this directory is winnt. This temp directory must exist and will usually exist, this setting is critical because PHP is installed in windows and session configuration fails.
Then copy PHP. ini to C:/Windows (Windows 9x/ME/XP) C:/WINNT (Windows NT/2000 ).
Finally, php4ts. DLL to C:/Windows/system (for Windows 9x/ME) C:/winnt/system32 (for Windows NT/2000) C:/Windows/system32 (for Windows XP ).

So far, PHP installation and configuration are basically complete. Next, you need to configure Apache so that it can use PHP.
Enter G:/amicrasy/myweb/Apache Group/apache2/CONF/httpd. conf to modify httpd. conf and add the following code:
----------------------------------------
Loadmodule php4_module "G:/amicrasy/myweb/PHP/SAPI/php4apache2. dll"
Addtype application/X-httpd-PHP. php
----------------------------------------
// Note that the above G:/amicrasy/myweb/PHP/SAPI/php4apache2. dll varies according to the PHP Directory copied earlier.
At this point, our configuration is complete. Next we will test it:
Compile the test file info. php (copy to the directory G:/amicrasy/myweb/Apache Group/apache2/htdocs/). The file content is as follows: (just one line)
----------------------------------------

----------------------------------------
Restart Apache and start IE. Enter http: // localhost/info. php in the address bar to view the page.
For the installation and configuration of Apache and PHP, see the following two official PHP website Installation Guide: link 1, link 2.
Http://www.php.net/manual/zh/install.apache2.php#install.apache2.windows
Http://www.php.net/manual/zh/install.windows.php

Next we can download some source code programs for PHP + MySQL from the website, and try again. I downloaded a discuz! 2.0 of the Forum tried and completed successfully. All these programs are done online. You only need to configure a configuration file and enter the MySQL account and password. You do not need to set the other configuration files, then run install. PHP, including databases and tables, will help you build a PHP + MySQL Forum. Then, download an article program and a message program in the zone and modify the interface, A good personal website is coming out. Haha.
We have introduced the installation of Apache + MySQL + PHP on Windows systems. Next we need to enable Apache to run JSP.

5. j2sdk Installation
Let's talk about the relationship between JDK and j2sdk: j2sdk includes Java Development Kit (JDK), Java Runtime Environment (JRE), and Java Plug-in. Sun's Java software development kit was JDK and is now called j2sdk. JRE and plug-in: j2re contain Java Plug-in. J2sdk is provided for Java Development, and application users do not need development tools. As the name suggests, JRE is the environment required for Java programs to run. The so-called cross-platform means that all platforms have an intermediate proxy, that is, JRE. This is generally required for software developed using Java, So Sun provides a JRE Installation File for Java application release.
Click j2sdk-00004_2-windows-i586-iftw.exe to install the SDK. Select G:/amicrasy/myweb/... as the target directory /....
After the installation is complete, start-> Run-> "cmd" and enter the command: "Java" to see if the Java help file is displayed. If yes, the j2sdk installation is complete.

6. tomcat installation
Click jakarta-tomcat-5.0.4.exe to install the SDK. Select G:/amicrasy/myweb /.... Some parameters that need to be input during the intermediate installation process include (Port: 8080, account password for managing tomcat, j2re1.4.2 installation directory selection, etc ). In this way, tomcat installation is complete. Next, let's try our results! Start start Tomcat, open IE, enter http: // localhost: 8080/, and click the example routine to see If JSP can be executed!

Next we will try the Java runtime environment, that is, the helloworld to be learned by beginners.
First, set the environment variable: My computer-> right-click-> properties-> advanced-> environment variable
Add three projects:
Java_home = G:/amicrasy/myweb/j2sdk1.4.2
Tomcat_home = G:/amicrasy/myweb/tomcat
Classpath = G:/amicrasy/myweb/j2sdk1.4.2/lib/dt. jar; G:/amicrasy/myweb/j2sdk1.4.2/lib/tools. Jar
Modify the PATH project, add "; % java_home %/bin; % atat_home %/bin", and restart the computer.
For setting environment variables, I have a heated discussion in this article. It is worth looking!
Http://www.cn-java.com/forum/show_topic.php? Forum_id = 2 & topic_id = 40

Then we write the helloworld. Java file, enter the following content in notepad, and save it as helloworld. Java:
----------------------------------------
Public class helloworld
{
Public static void main (string ARGs [])
{
System. Out. println ("Hello world! ");
}
}
----------------------------------------
Start-> Run-> "cmd" and enter the following command:
G:
CD amicrasy/javafiles
Javac helloworld. Java // compile helloworld. Java to generate helloworld. Class
Java-classpath. helloworld // run helloworld and "Hello World!" appears! "
Now the Java Runtime Environment has been debugged!

7. Integrate Apache with Tomcat

First copy the mod_jk-2.0.46.dll to the G:/amicrasy/myweb/Apache Group/apache2/modules directory.
Next, configure httpd. conf of Apache:
Go to G:/amicrasy/myweb/Apache Group/apache2/CONF/httpd. conf to modify httpd. conf and add the following content:
----------------------------------------
Loadmodule jk_module modules/mod_jk_2.0.46.dll
Jkworkersfile "G:/amicrasy/myweb/tomcat/CONF/workers. properties"
Jklogfile "G:/amicrasy/myweb/tomcat/logs/mod_jk2.log"
Jkloglevel info
Jkmount/servlet/* ajp13
Jkmount/*. jsp ajp13
----------------------------------------
The purpose is to set the connection between APACHE and tomcat so that Apache can submit the JSP file to Tomcat for processing in the background. Note: the preceding directory should be modified according to the tomcat installation directory.

Note that a jkworkersfile is used in the preceding statement, and we will generate this file:
Go to the G:/amicrasy/myweb/tomcat/conf directory, write the workers. properties file, enter the following content in notepad, and save it as workers. properties:
----------------------------------------
Workers. tomcat_home = G:/amicrasy/myweb/tomcat
Workers. java_home = G:/amicrasy/myweb/j2sdk1.4.2
PS =/
Worker. List = ajp13
Worker. ajp13.port = 8009
Worker. ajp13.host = localhost
Worker. ajp13.type = ajp13
Worker. ajp13.lbfactor = 1
----------------------------------------
It is also noted that the preceding directory should be modified according to the Tomcat and j2sdk installation directories. Generally, host = localhost. If there are differences, you can modify the directory accordingly.

So far, Apache Tomcat integration has been successfully completed. Next we will perform a test and restart Apache (Click monitor Apache servers) and Tomcat (Click start Tomcat). Then we will start Apache and open the browser, in the address bar, enter http: // localhost: 8080/JSP-examples/jsp2/simpletag/hello. JSP; and http: // localhost/JSP-examples/jsp2/simpletag/hello. JSP, we found that the same content is displayed on the two pages. So far, we have successfully completed the Apache integrated Tomcat test!

8. Continue to configure Tomcat
In this step, we only make Apache run JSP (in fact, it only turns to). jsp cannot be run in the Apache main directory. in order to unify the website, we need to set the Tomcat home directory to the same directory as the Apache home directory, that is, the current G:/amicrasy/myweb/Apache Group/apache2/htdocs. To do this, we perform the following operations:

First in the htdocs directory to create a directory JSP, the directory to create a directory WEB-INF, WEB-INF directory to create a classes directory, and then we write the file web. XML, enter the following content in notepad, and save it as web. XML, put it in the WEB-INF directory:
----------------------------------------

Public "-// Sun Microsystems, Inc. // DTD web application 2.3 // en"
Http://java.sun.com/dtd/web-app_2_3.dtd;>

Welcome to Tomcat
 
Welcome to Tomcat
 

----------------------------------------
In summary, the files under the JSP directory are roughly: JSP files and WEB-INF directories (the WEB-INF directory contains the Web. xml and classes Directories ).

Next, modify Tomcat's server. XML to enter the G:/amicrasy/myweb/tomcat/conf directory, Open Server. XML, and mark it (note that it is before !) Add the following content:
----------------------------------------

----------------------------------------
Save server. xml and enable the default access mode for Serlvet. Open Web. XML in the conf directory. Find 273 rows to 278 rows, and remove the HTML annotator, that is, the Comment between and. Restart tomcat to use the JSP directory. The access address is http: // localhost/jspfiles/*. jsp (* indicates any file name ). So far, we have integrated the JSP file directory into the Apache main directory.

The next thing we should consider is how to make Tomcat only serve as an aid for Apache, instead of running it separately as a service, that is, let http: // localhost: 8080/jspfiles /*. JSP. The access is invalid. Only http: // localhost/jspfiles/* can be used /*. JSP access.

Disable Apache directory browsing and enter G:/amicrasy/myweb/Apache Group/apache2/CONF/httpd. conf: Modify httpd. conf: Delete the indexs attribute of the main directory options. Modify the attributes as follows:
----------------------------------------

Options followsymlinks # (remove indexs)
AllowOverride none

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

Disable Tomcat directory browsing (this step is not required and can be done or not). Modify the Web. XML and Web. XML, which may be distributed in several locations and are modified as follows:
----------------------------------------

Listings
False # (originally true, changed to false)

----------------------------------------
If the preceding statement is not used, add it as follows:
----------------------------------------

......
# Add it to the bottom of the local directory.

----------------------------------------
Modify the Web. xml in the WEB-INF subdirectory under the jspfiles directory we set earlier.

Disabling tomcat to run independently is actually very simple. You only need to remove Tomcat port 8080, enter the G:/amicrasy/myweb/tomcat/conf directory, and open the server. XML, find Port = "8080", delete this statement, and save it.

At this point, we have fully integrated Apache and tomcat. Tomcat can only be used as an aid for Apache. Of course, removing the port is not a strict policy. If the address bar browses JSP files, in this way, Apache will send it to Tomcat for parsing. If it exists, it will also be executed. Therefore, it is only a temporary solution, but it is also a relatively effective method.

9. Enable Apache to support CGI
This step is almost the final point, and everything is going well! Next, configure CGI. The configuration in Linux will not work. I don't know if it will work well today? First install Perl (ActivePerl-5.6.1.635-MSWin32-x86, now address: http://downloads.activestate.com/ActivePerl/Windows/5.6/ActivePerl-5.6.1.635-MSWin32-x86.zip), the installation process is very simple, open installer. BAT: Set the installation path of Perl to be consistent with the preceding path. Select G:/amicrasy/myweb/perl and press Enter. After the installation is complete, we will test whether Perl is successfully installed. We will write the file test. pl, enter the following content in notepad, and save it as test. pl, which is located in the directory G:/amicrasy/downloads:
----------------------------------------
Print "Hello, bincon! ";
----------------------------------------
Start-> Run-> "cmd" and enter the following command:
G:
CD amicrasy/myweb/perl/bin
Perl G:/amicrasy/downloads/test. pl
Hello, bincon !, Now Perl debugging is successful!

The rest is to make a simple configuration for Apache to support CGI and enter G:/amicrasy/myweb/Apache Group/apache2/CONF/httpd. conf: Modify httpd. conf, modify the following three items:
----------------------------------------
#1
ScriptAlias/cgi-bin/"G:/amicrasy/myweb/Apache Group/apache2/cgi-bin /"
#2

AllowOverride none
Options execcgi # Add execcgi
Order allow, deny
Allow from all

#3
Addhandler CGI-script. cgi. pl
----------------------------------------
Modify the above three items, save httpd. conf, and restart Apache. Apache now supports CGI. Let's test it and write the file test. CGI, enter the following content in notepad, and save it as test. CGI, in the directory G:/amicrasy/myweb/Apache Group/apache2/cgi-bin:
----------------------------------------
#! G:/amicrasy/myweb/perl/bin/perl.exe
Print "Content-Type: text/html/n ";
Print "Hello, bincon! ";
----------------------------------------
Open IE and enter http: // localhost/cgi-bin/test. cgi in the address bar. Hello, bincon !, The test is successful!

You can execute CGI, and then we will try to install a very well-known CGI forum on the Internet. Download the Simplified Chinese version of lb5000x300from cgier.com (ftp: // 218.104.78.88/lb5000xp300.zip ), decompress the package, copy the cgi-bin file to the G:/amicrasy/myweb/Apache Group/apache2/cgi-bin directory, and rename it lb5000xp, next we need to modify the CGI File in lb5000xp and change "#! /Usr/bin/Perl "changed "#! G:/amicrasy/myweb/perl/bin/perl.exe ". In this case, a tool" ultraedit "," replace in files "is required. The modification ends successfully and the IE browser is opened, enter http: // localhost/cgi-bin/lb5000xp/install in the address bar. CGI, you can see the installation interface, and then follow the prompts in the step by step, the address bar: http: // localhost/cgi-bin/lb5000xp/leoboard. CGI, the classic Forum appears, and all our tasks have been completed!

10. Enable Apache to execute ASP
Search for the metric data on the Internet and find the General Recommendation iasp(iasp2.1.01.exe). Download location: http://www.stryon.com/chooseproduct.asp. The installation of this program requires the support of j2sdk, which has been installed before. The installation process is very simple and there is no configuration. You only need to select some options. However, after the installation, the IASP service is successfully started. However, when the apache service is started, it is found that the startup fails and there is no reason. After reading the documentation on the internet, I found that IASP does not support the latest Apache version, I had to give up on this. Of course, there are other ways to solve the problem of Apache executing ASP scripts. Therefore, simply install IIS to solve the problem of executing ASP scripts. Although this is a great pity for me who like to seek perfection, I can say it again, ASP scripts can still seek the greatest support on IIS. After all, they belong to the same home. Over the past few years, with the continuous upgrading of IIS, their stability and performance have been continuously improved, the vulnerability can be easily solved.
The installation process is very simple. Put the installation disk into the optical drive. Choose "Control Panel"> "Add/delete programs"> "Add/delete Windows Components"> "Internet Information Service (IIS)", and check the installation details, select only (Internet Information Service Management Unit and public files)-> next-> select path-> complete installation. When configuring IIS, pay attention to port change because port 80 is already occupied by Apache. At this point, the IIS installation is complete, and the issue of executing the ASP script is solved.

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.