Recently, an Apache + Tomcat environment needs to be created for some reasons. But the trouble is that you do not have a Linux machine on hand, but you do not want to use Windows or install Linux. Therefore, I chose a solution like Apache + Tomcat + cygwin. The following is my detailed installation and configuration process.
0 platform
Windows XP (SP2)
JDK 1.4.2
Cygwin
1. Preparations
1.1 install necessary packages on cygwin
Run the setup program of cygwin. In the Select Packages dialog box, select the following tool (click "Skip" before the package name ":
- Autoconf
Automake
Cygrunsrv
Gcc-core
Gcc-G ++
Make
Perl
Python
Click "Next" to start installation.
1.2 download code
These projects have many versions, and not all versions are suitable for this solution. The options are as follows:
- Apache 2.2.2
- Tomcat 4.1.31
- JK Connector 1.2.15
Source code of Apache and JK connector is directly decompressed to home/username under cygwin installation directory.
2 compile/install
First, run cygwin. A Window similar to a command line will appear, which is used in the same way as a Linux character terminal. The following installation process is not described in the cygwin window. JK connector connects to Apache statically.
2.1 compile/install JK Connector
Before compiling, you must first compile Apache once. Otherwise, some files cannot be found. For Apache compilation, see 2.2.
CD/home/usrename/jakarta-tomcat-connectors-1.2.15-src
./Configure -- With-Apache =/home/username/httpd-2.2.2
Make
Make install
2.2 compile/install Apache
Httpd-2.2.2/CD/home/username/
./Buildconf
./Configure -- with-mod_jk
Make
Make install
2.3 install Tomcat
Decompress the Tomcat package to USR/local under the cygwin installation directory. For convenience, create a connection.
Ln-S/usr/local/jakarta-tomcat-4.1.31/usr/local/tomcat
3 Configuration
3.1 configure Apache
- Create worker. properties, you can directly use JK connector's sample: CP/home/usrename/jakarta-tomcat-connectors-1.2.15-src/JK/CONF/worker. properties/usr/local/apache2/Conf
- Create the JK connector log file directory: mkdir/var/log/httpd
- Modify/usr/local/apache2/CONF/httpd. conf to add configuration for JK Connector
# JK connector configurations
Jkworkersfile/usr/local/apache2/CONF/workers. Properties
# Where to put JK logs
Jklogfile/var/log/httpd/mod_jk.log
# Set the jk log level [debug/error/info]
Jkloglevel info
# Select the log format
Jklogstampformat "[% A % B % d % H: % m: % S % Y]"
# Jkoptions indicate to send SSL key size,
Jkoptions + forwardkeysize + forwarduricompat-forwarddirectories
# Jkrequestlogformat set the request format
Jkrequestlogformat "% w % v % t"
# Send servlet for context/examples to worker named ajp13
Jkmount/examples/servlet/* ajp13
# Send JSPs for context/examples to worker named ajp13
Jkmount/examples/*. jsp ajp13
Jkmount/examples * ajp13
3.2 configure cygwin
- Modify/home/username/. bashrc and add environment variables.
Path =/usr/local/apache2/bin:/usr/local/tomcat/bin :$ {path}
Export path
Tomcat_home =/usr/local/tomcat
Export tomcat_home
Catalina_home =/usr/local/tomcat
Export catalina_home
Apache2_home =/usr/local/apache2
Export apache2_home
- Install cygwin server in Windows Service; otherwise, Apache cannot be started in the background and run the command
Cygserver-config
In addition, cygwin is set to server in the Windows environment variable.
4. Start
4.1 start Tomcat
Run the script:
Startup. Sh
Enter http: // localhost: 8080 in the address bar of the browser. If the Tomcat page appears, Tomcat is successfully installed.
4.1 start Apache
Run the script:
Apachectl start
Enter http: // localhost in the address bar of the browser. If "It works!" appears! ", Indicating that Apache is successfully installed.
4.3 Test Tomcat access from Apache
Enter http: // localhost/examples in the address bar of the browser. If the Tomcat page appears, the entire installation is successful.
You can access http: // localhost/examples/servlet to test whether the servlet is normal.
How is it? Is it very simple? Now I have an Apache + Tomcat environment running in Linux!