Apache and Tomcat Installation and Integration Installation Yedongshu2001 Original (Participation: 370, Experts: 200) Published: 2004-10-25 9:43 AM: 1.0 Read: 270 times
1. These days, several netizens asked me this question, there are a lot of information on the Internet, I summed it, I hope to use the beginners. II. Use Tomcat to do JSP servers alone, there will be problems in work efficiency, and the maximum number of concurrent connections that can withstand can also limit; Test, Tomcat is in the state of "zombie" when concurrent connection The subsequent request connection lost response. So now I have some "integration" solution: the HTML is clearly divided into labor, so that Tomcat only processes the JSP section, and other Web Server processing by Apache, IIS, which greatly saves Tomcat limited Work "thread". III. Installing Apache: (1) Apache installation is very simple, select the license agreement After entering the server information configuration interface 1 "Network Domain" domain information, fill in the domain name of your server, if you have applied for a domain name If you fill in the domain name you apply, (Note that the domain name here is just the first half of the complete domain name you applied, does not include "www". If you apply for the second-level domain name, the first " "After some), if you haven't yet, you will fill in the IP of this unit. The next line is the server name, fill in a complete domain name or IP address. Then the next column is the administrator Email address. These three must be filled out in installation, but you can also modify it after installation is complete, so you don't have to worry about filling out problems. The final option is not changed. (2) Click "Next" to enter the next step. Select "Typical" typical installation, the next step Select the installation directory, you can modify it, and then install it. (3) After the installation is complete, five options can be seen in the Apache HTTP Server 2.0.49 menu of the Start menu, now click on the "Start" startup server under the "Control Apache Server" directory. You can see that Apache's feather icon appears in the system status bar and has a green arrow, which means that the server starts successfully. (4) Open the browser, enter localhost or 127.0.0.1 (these two points to the unit address), enter, if you install correct, you can see the Apache's test page. 4. Install Tomcat (I use Tomcat5.0.14): Step 1: Download J2SDK and Tomcat: to Sun Official Site (http://java.sun.com/j2se/1.4.2/download.html) Download J2SDK, note that the download version is Windows Offline Installation SDK, it is best to download J2SE 1.4.2 documentation, then download Tomcat (http://www.apache.org/dist/jakarta/tomcat-4/) download Tomcat (download the latest 4.1.x version of Tomcat); Step 2: Install and configure your J2SDK and Tomcat: Perform the J2SDK and Tomcat installer, then press the default settings.
1. After installing J2SDK, you need to configure the environment variable, add the following environment variables in my computer -> Properties -> Advanced -> Environment Variables -> System Variables (assuming your J2SDK installed in C: /J2SDK1.4.2): Java_Home = C: /J2SDK1.4.2 ClassPath =.;% Java_home% / lib / dt.jar;% java_home% / lib / Tools.jar; (.; must not be less, because it represents the current path) Path =% java_home / bin then writes a simple Java program to test if J2SDK has been installed successfully: public class test {public static void main (string args []) {system.out.println ("this is a test program.");} } Save the above program as file named Test.java. Then open the command prompt window, cd to your directory where you test.java, and type the following command Javac Test.java Java Test At this time, if you see this is a test program. If you have successful installation, if you don't print This sentence, you need to check your configuration carefully. 2. After installing Tomcat, add the following environment variables in my computer -> Properties -> Advanced -> Environment Variables -> System Variables (assuming your Tomcat is installed in C: / Tomcat): Catalina_Home = C: / Tomcat; Catalina_Base = C: / Tomcat; then you can start Tomcat, access http: // localhost: 8080 in IE, if you see Tomcat's welcome page, the installation is successful.
Step 3: Establish your own JSP app directory 1. WebApps directory for the Tomcat installation directory, you can see the directory of Tomcat, which root, example, tomcat-docs, etc.; 2. Creating a directory in the webapps directory, Name called myapp; 3. MYApp New Directory Web-INF, note that the directory name is case sensitive; 4.Web-infers new file web.xml, the content is as follows: XML Version = "1.0" Encoding = "ISO-8859-1">
Step 4: Establish your own servlet: 1. Creating a servlet program with your most familiar editor (recommended using syntax-check Java IDE), the file name is Test.java, the file content is as follows: package test; import Java. io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class Test extends HttpServlet {protected void doGet (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {PrintWriter out = response.getWriter (); out.println ( "
Now WebApps / MyApp / Web-INF / CLASSES has the file directory structure 4. Modify WebApps / MyApp / Web-INF / Web.xml, add servlet and servlet-mapping, Web.xml as follows Sign, red is added: XML Version = "1.0" encoding = "ISO-8859-1">