📄 apache + tomcat howto - windows 2000 pro-xp pro.htm
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0048)http://www.johnturner.com/howto/winxp-howto.html -->
<HTML><HEAD><TITLE>Apache + Tomcat HOWTO - Windows 2000 Pro/XP Pro</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<META content="MSHTML 6.00.2900.2180" name=GENERATOR></HEAD>
<BODY>
<H2>Windows 2000/XP - Apache + JK + Tomcat HOWTO</H2>
<P>updated: 05/06/2003
<P>DISCLAIMER: this is for Windows 2000 Professional and XP Professional. It
does not cover setting up Apache + Tomcat on a server such as Windows 2000
Server/Advanced Server for production use. This is because I have no access to a
Windows 2000 server, nor do I use Windows servers for production use. My only
access to Windows are desktop installations of Windows 2000 Professional and XP
Professional. If you are a Windows 2000 server administrator, my guess is that
you have the skills to take these instructions and adapt them to your platform
accordingly. If you are unable to do this, please consult the tomcat-user
mailing list for help or go flag down your neighborhood Windows sys-admin and
ask them for help.
<P>This HOWTO is for Windows 2000 Professional and XP Professional. It assumes
that you have some basic knowledge of how to make things work on your Windows
computer, such as enabling and disabling services and creating new directories.
NOTE: this process is not a simple one-click "install this software and use the
defaults" process. If that's all you know how to do with your computer, find a
friend to help you, as things will be a little bit more complicated than that,
but certainly something someone with basic system administration skills can
handle. If you must have a JSP and Java servlet environment, and you aren't
comfortable configuring things manually, then stick with Tomcat by itself, don't
try to install Apache as well. You'll be able to get started with your JSP and
Java servlet development much faster and easier that way.
<P><B>Installing the JDK</B>
<P>1. You'll need to go to <A
href="http://java.sun.com/j2se/1.4.1/download.html">http://java.sun.com/j2se/1.4.1/download.html</A>
and get the JDK version of J2SE 1.4.1. The JRE version works for Tomcat in some
circumstances, but unless you know exactly what you are doing, the full JDK is
the better choice. Its a big download (38Mb), so plan accordingly.
<P>2. Run the installer. Take the defaults. This will install the JDK in
c:\j2sdk1.4.1_01.
<P>3. Setup the JAVA_HOME environment variable. Click Start->Control
Panel->System. Then click Advanced, then click "Environment Variables".
<P>4. Under System variables, click "New". For Variable Name, use JAVA_HOME
(exactly like that, case and all). For Variable Value, use c:\j2sdk1.4.1_01.
Click OK until the Control Panel is closed.
<P>5. Verify the setting. Click Start->Run, and in the command box type "cmd"
and click OK. At the command prompt, type <B>echo %JAVA_HOME%</B> and verify
that the value returned matches the Variable Value from step 4.
<P><B>Installing Apache</B>
<P>1. First, make sure there is no web server running on port 80 on your
machine. It's possible that you have IIS installed and running, and you don't
even know it. Go to Start->Administrative Tools->Services, and look for a
service named "World Wide Web Publishing". If that service is listed, click on
it's name, then click the "Stop" button in the toolbar. The stop button is a
square. Then, choose Properties in the toolbar, and set "Startup Type" to
"Manual" instead of "Automatic". This will prevent IIS from starting on your
machine when it is rebooted. Only one service can run on port 80 at a time, and
in this HOWTO that service will be Apache, not IIS.
<P>2. Download the Apache binary for Windows. Choose a mirror site, and get the
MSI installer. This will make things easier. The current version of Apache is
2.0.44. YOu can get the MSI installer from a mirror: <A
href="http://httpd.apache.org/download.cgi">http://httpd.apache.org/download.cgi</A>
<P>3. Save the MSI installer to a location on your hard drive. Wherever you put
it, remember that location.
<P>4. Click Start->Run->Browse, and browse to the location where you put
the MSI installer. Run the MSI installer. You will see a couple of screens
dealing with licenses, etc. Click through those, then you will see a screen that
says "Server Information" and has some values in the fields already. Delete the
Network Domain and Server Name values, and type "localhost" into both fields.
Put your email address in the field entitled "Administrator's Email Address".
Choose the option to install Apache for all users on port 80. Click Next.
<P>5. On the next screen, the default is "Typical". Select "Custom" and click
Next.
<P>6. The next screen says "Custom Setup". Click the "Change..." button to
change the installation directory.
<P>7. The next screen says "Change Current Destination Folder". Click UP to the
C drive, that is, C:\. Click the "new folder" icon (the folder with a "*" on it)
and call the new folder "apache". Click "OK", then click Next. The goal here is
to install Apache 2.0.43 in a folder called C:\apache, NOT in the default
installation folder that the installer wants to use. This is because the default
installation is a Windows-friendly location with spaces in the pathname. Spaces
in pathnames can cause problems with software developed for Linux, which is
where most open source software is developed.
<P>8. Click "Install". The installer will do its thing, and you will see various
windows popping up and disappearing. This is normal. When the installer is
finished, you should see a "successful" message and there should be a new icon
in your system tray.
<P>9. The installer starts Apache by default, so once the installer completes,
you can open up a browser window and browse to http://localhost. You should see
the default Apache home page. If you don't see this, go back to Step 3 and try
again. The MSI installer is about as painless as you can get. This will leave
you with c:\apache\Apache2 as your Apache home directory.
<P>10. Once you have verified that Apache is running on port 80, right click on
the Apache System Tray icon and choose "Open Apache Monitor". Then click the
"Stop" button to stop Apache. Apache will be started again after Tomcat and JK
are installed.
<P><B>Installing Tomcat</B>
<P>1. Create a folder on your hard drive. Call it tomcat, and put it in the C
drive root, so that you end up with C:\tomcat.
<P>2. Download the Tomcat binary. The latest version of Tomcat is 4.1.18. Get
the binary for Windows here: <A
href="http://apache.mirrorcentral.com/dist/jakarta/tomcat-4/binaries/tomcat-4.1.18.exe">http://apache.mirrorcentral.com/dist/jakarta/tomcat-4/binaries/tomcat-4.1.18.exe</A>.
Save the file to your hard drive, and remember where you put it.
<P>3. Execute the EXE file you downloaded in Step 2. This will start the
installer. Read the license, and if you agree, click "I Agree" and go to the
next screen.
<P>4. On the next screen, select the box that says "NT Service". If you want to
install the Tomcat source code (entirely optional, you don't need it to run
Tomcat) then select that option as well. Leave the default selections as they
are. Click Next.
<P>5. On the next screen, DON'T take the installation directory default. Click
the Browse button, and choose the folder you created in Step 1. This will leave
you with something like C:\tomcat\Tomcat 4.1. This isn't ideal...you don't want
spaces in the name. Change the last part of the path to something like
"tomcat-4-1-18" so that you end up with c:\tomcat\tomcat-4-1-18 in the directory
field.
<P>6. Click Next. The installer will start copying files. Eventually you will be
presented with a screen asking for a password for the admin user. Type in a
password, making sure that you can remember it later. Leave the port number at
8080. If you change it, you will have to manually edit Tomcat's config files.
Click Next.
<P>7. When the installer is finished, you will have a directory structure for
Tomcat at c:\tomcat\tomcat-4-1-18, and the service should be running. You can
verify the service is running by accessing <A
href="http://localhost:8080/">http://localhost:8080/</A>. Note that since Tomcat
is installed as a service, you can manage it with the Services tool by clicking
Start->Administrative Tools->Services and looking for service called
Apache Tomcat 4.1.
<P>8. Verify the JSP examples work at <A
href="http://localhost:8080/examples/jsp/index.html">http://localhost:8080/examples/jsp/index.html</A>
and that the servlet examples work at <A
href="http://localhost:8080/examples/servlets/index.html">http://localhost:8080/examples/servlets/index.html</A>.
<P><B>Installing the JK Connector</B>
<P>The JK connector is what Apache and Tomcat use to "speak" with each other.
It's a separate piece of software, distinct from both Apache and Tomcat. There
is also a JK2 connector, but in this HOWTO we will be working with the JK
connector. The goal here is to get JSP and servlets to run on port 80, without
having to set Tomcat to run on port 80. It is possible to run Tomcat on port 80
as a stand-alone web server, but in many situations, there is a need to use
Apache on port 80. The connector acts as the conduit between Apache and Tomcat
in that scenario.
<P>1. Download the JK connector here: <A
href="http://jakarta.apache.org/builds/jakarta-tomcat-connectors/jk/release/v1.2.1/bin/win32/">http://jakarta.apache.org/builds/jakarta-tomcat-connectors/jk/release/v1.2.1/bin/win32/</A>.
In our case, we want the file called mod_jk-2.0.43.dll because we are using
Apache 2.0.43.
<P>2. The file is an Apache module, it is NOT a Tomcat JAR file or WAR file. It
doesn't belong in Tomcat's directory structure, it belongs in a place where
Apache can find it. For Apache 2.0.43, that is APACHE_HOME\modules, where
APACHE_HOME is equal to your Apache install location. In our case, that is
c:\apache\Apache2, so we want to put the JK DLL file into
c:\apache\Apache2\modules. You should end up with a file called
c:\apache\Apache2\modules\mod_jk-2.0.43.dll on your hard drive. If you notice
that the other files in c:\apache\Apache2\modules end in "*.so", that's OK. Both
"*.so" and "*.dll" are valid Apache module extensions on Windows systems.
<P><B>NOTE:</B> from now on, APACHE_HOME = c:\apache\Apache2 or the name of your
Apache home directory.
<P>3. Edit Apache's configuration file. It is located in APACHE_HOME\conf and is
called httpd.conf. Don't be nervous, there is a copy in the same directory
called httpd.default.conf. You can always revert back to the default settings if
you need to by copying that file.
<P>4. Edit httpd.conf in your favorite text editor. DO NOT edit it in Microsoft
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -