Tomcat 5 implements servlet 2.4 and jsp2.0, which has improved performance, especially, for us, real Chinese support, you can directly display Chinese content without adding special parameters, let Java and JSP Chinese issues Become history!
1. First apache2, UNIX / Linux, next to the source code, the most important configure parameter is --Nenalbe-modules = "so" other according to yourself, and Windows is directly installed with compiled binary versions. The specific installation method has been introduced, and details will not be described here. If necessary, please refer to http://httpd.apache.org or ChinaUnix's web server zone essence, the only thing to remind is that it is necessary to remind httpd.conf
[Code: 1: 141851C2A4] #adddefaultcharset ISO-8859-1 [/ Code: 1: 141851C2A4]
Front addition # 注销, many people ask why Apache2 shows Chinese garbled, the root source is here, the easiest way is to add a #, you can display Chinese normally, no need to set what GB2312.
2. Install the JDK, Tomcat's run requires J2SDK support, you can go to http://java.sun.com. Windows can download the OFFLINE Installation version, about 50m, download after downloading, LINUX is recommended to download the self-extract version, after downloading with chmod x j2sdk ... plus execution properties, then run the downloaded file, will come out License Agreement, after skipping a few pages in several spaces, enter YES to represent accept the protocol, and then the program will be released, and a subdirectory J2SDK1.4.2_04 is created.
3. Set the environment variable, Java's run requires setting the environment variable, usually as long as you set a java_home, in addition, put the Java executable to Path is going. Running under Linux
[Code: 1: 141851c2a4] java_home = / usr / local / j2sdk1.4.2-04; Export $ java_home
PATH = $ PATH: $ java_home / bin [/ code: 1: 141851c2a4] If you need all users, you can use Java, you can put this code in / etc / profile, so you will be on time. Will automatically set the relevant variables.
Windows Bet below the System Properties -> Environment Variables button, if you want all users to be used, establish it in "System Variable", click "New" button, the variable name is "Java_home", the variable value is the path to the Java installed, usually c: /j2sdk1.4.2-04, then edit the PATH variable, the final plus;% java_home% / bin
4. Install Tomcat, the simplest is to download the binary version, under Linux, directly tar -xzvf jakarta-tomcat-5.0.19. Windows Below, running the EXE file directly, it will be installed automatically. Windows installation process requires an Admin user and password, which can manage the Tomcat server's run and install and release web applications on the web. You can also create other management users, the permissions are very large, so the password should be careful, if It is Linux, no creation of this user, you need to edit Tomcat-Users.xml next to Jakarta-Tomcat-5.0.19 / Conf to handle 2 Role and 1 user, the easiest example file is as follows: [Code: 1: 141851C2A4] XML Version = 1.0 Encoding = UTF-8?>
tomcat-users> [/ code: 1: 141851c2a4]
Launch Tomcat, Tomcat / bin directory has Startup.sh for Linux and Start.bat for Windows, Shutdown.sh and Shutdown.bat are used to close Tomcat, of course, Windows also has a special graphics interface startup, In fact, the effect is the same.
Of course, in Linux, you can also start with JSVC and make the startup script starts with the machine. JSVC is originally to download Commons-daaemon-1.0-alpha from http://jakarta.apache.org, but Tomcat has brought one itself, there is a jsvc.tar.gz decompressed in the tomcat / bin directory, compile:
Unzip tar -xzvf jsvc.tar.gz then CD JSVC-SRC then run
[Code: 1: 141851c2a4] shpport / buildconf.sh
./configure
Make [/ Code: 1: 141851C2A4]
(Note: Tomcat-5.0.18 version of JSVC source code has a low-level error - less a semicolon, will cause compilation unsuccessful, you can add this semicolon)
There are two scripts Tomcat.sh and tomcat5.sh, which can be used by Tomcat yourself, can be used as a script that starts and stop Tomcat, I will be slightly modified, the files are as follows: [Code: 1 : 141851C2A4] #! / Bin / sh
#
# Startup Script for Tomcat5
#
# chkconfig: 345 87 13
# Description: Tomcat daemon
# ProcessName: JSVC
# pidfile: /var/run/jsvc.pid
# config:
#
# Source Function Library.
. /etc/rc.d/init.d/functions
#
PROG = Tomcat
#
# Small Shell Script to show how to start / stop tomcat using jsvc
# If you want to have tomcat running on port 80 please modify the server.xml
# file:
#
#
# # port = "80" minprocessors = "5" maxprocessors = "75" # enablelookups = "true" redirectport = "8443" # acceptcount = "10" debug = "0" connectionTIMEOUT = "60000" /> # # You ued a development version of tomcat (apache tomcat / 4.1-dev) # # Adapt the folload lines to your configuration # Set your own parameters Java_home = / usr / local / j2sdk1.4.2-04 Catalina_Home = / usr / local / jakarta-tomcat-5.0.19 Daemon_Home = $ CATALINA_HOME / BIN # Need to set a no permission in the system # 用户 用户 来, this is more secure Tomcat_user = Tomcat5 TMP_DIR = / VAR / TMP Catalina_opts = Classpath = / $ Java_home / lib / Tools.jar: / $ Catalina_home / bin / commons-daemon.jar: / $ Catalina_home / bin / bootstrap.jar START () { echo -n $ "Starting $ PROG:" # # Start Tomcat # $ Daemon_Home / JSVC-SRC / JSVC / -user $ TOMCAT_USER / -home $ java_home / -Dcatalina.home = $ CATALINA_HOME / -Djava.io.tmpdir = $ TMP_DIR / -Outfile $ Catalina_Home / Logs / Catalina.out / -ERRFILE & 1 / $ Catalina_opts / -cp $ classpath /org.apache.catalina.startup.bootstrap # # T Get a verbose jvm # -verbose / # TO GET A Debug of JSVC. # -debug / RetVal = $? [$ RETVAL = 0] && touch / var / lock / subsys / jsvc [$ RETVAL = 0] && echo_success || echo_failure echo Return $ RetVal } STOP () { Echo -n $ "Stopping $ PROG:" # # 帖子 t t # PID = `cat / var / run / jsvc.pid` Kill $ PID RetVal = $? [$ RETVAL = 0] && RM / VAR / LOCK / SUBSYS / JSVC [$ RETVAL = 0] && echo_success || echo_failure echo Return $ RetVal } Case "$ 1" in START) Start ; STOP) STOP ; Restart | Reload) STOP Start ; *) Echo "Usage $ 0 START / STOP" EXIT 1 ;; ESAC [/ Code: 1: 141851C2A4] Save this code as /etc/rc.d/init.d/tomcat, then run [CODE: 1: 141851C2A4] ChkConfig --Add Tomcat [/ CODE: 1: 141851C2A4] You can add Tomcat to system service automatic The system is started. This script will start automatically in Runlevel 3/4/5. Note that this script is created for Tomcat5. If you use Tomcat4, you will need to modify it on another Tomcat.sh. 5. Compile and set up mod_jk Windows version of Mod_JK can download the binary version directly from Jakarta.apache.org, and then download the source code under Linux. Download Jakarta-Tomcat-Connectors-JK2-Src-Current.Tar.gz from http://jakarta.apache.org, then [CDE: 1: 141851C2A4] CD /JAKARTA-TOMCAT-CONNECTORS-JK2-2.0.2- SRC / JK / NATIVE2 ./buildconf.sh[/code:1:141851c2a4] then run [CODE: 1: 141851C2A4] ./ Configure --with-apxs2 = / usr / local / apache2 / bin / apxs --with-java-home = / usr / local / j2sdk1.4.2-04 [/ code: 1: 141851C2A4] (The specific path is adjusted according to your actual adjustment) run [Code: 1: 141851C2A4] MAKE JK2-Build-APXS CD Server / Apache2 Make -f makefile.apxs install [/ code: 1: 141851c2a4] In fact, this package has an ANT configuration file. It may be simple to compile with ANT, but it is necessary to install Ant, and some modules are not the function of Ant itself, but also add the corresponding functional module for Ant, so here Subject, the next time I have time to send an Ant application. In this way, your mod_jk is finally installed, and now starts to enter the configuration phase, in fact, the configuration is very simple 6. Set the virtual host For example, I have a virtual host vhosts.vicp.net I hope to turn JSP and servlet to Tomcat, while other files such as HTML pages, pictures, etc. Still use Apache parsing. Tomcat settings: Modify Tomcat / Conf / Server.xml, add one [Code: 1: 141851c2a4] AppBase = "/ OPT / JAKARTA-TOMCAT-4.1.12-Le-JDK14 / WebApps / Struts-EXAMPLE" Unpackwars = "true" autodeploy = "true"> Directory = "Logs" prefix = "vhost.vicp.net_access_log." suffix = ". txt" Pattern = "Common" resolvehosts = "false" /> Directory = "logs" prefix = "home_log_" suffix = "_ app_log.txt" TimeStamp = "true" /> Host> [/ code: 1: 141851c2a4] Adjust the parameters and settings to make your environment, of course, if you have other Create a workers2.properties under / usr / local / apache / confal, as follows: [Code: 1: 141851C2A4] # ---- Worker2.properties [Logger.Apache2] Level = Debug # Shared Memory Handling. Needs to be set. [SHM] File = / usr / local / apache2 / logs / shm.file SIZE = 1048576 # Example Socket Channel, Explicitly Set Port and Host. [Channel.socket: Localhost: 8009] Tomcatid = localhost: 8009 Port = 8009 Host = 127.0.0.1 # Define the worker [AJP13: Localhost: 8009] Channel = channel.socket: localhost: 8009 # [Status: status] # Uri mapping # [Uri: / jkstatus / *] # group = status: status # [URI: / JSP-EXAMPLES / *] # group = ajp13: localhost: 8009 # [uri: / servlets-example / *] # group = ajp13: localhost: 8009 # [Uri: / javaapp / *] # group = ajp13: localhost: 8009 # [uri: www.home.net / *. jsp] # worker = ajp13: localhost: 8009 # [Uri: 10.0.0.10/*] # worker = ajp13: localhost: 8009 # ---- End of workers2.properties [/ code: 1: 141851c2a4] Of course, you can delete the commentary to make the URI and Worker's configuration take effect, I don't have to configure this method because of finding a better way: Configure in httpd.conf: Before putting the following to VirtualHost, you can avoid users with Apache to access the web-infers from globally. [CODE: 1: 141851C2A4] ORDER ALOW, DENY Deny from all Directory> [/ Code: 1: 141851C2A4] Typical VirtualHost configuration sample [CODE: 1: 141851C2A4] Servername vhost.vicp.net Documentroot / Home / WebApp / Public_HTML / DirectoryIndex index.htm index.html default.htm index.php index.jsp JKuriSet worker ajp13: localhost: 8009 Location> Errorlog logs / vhosts.vicp.net-err_log Customlog logs / vhosts.vicp.net-ACC_LOG COMMON Virtualhost> [/ code: 1: 141851c2a4] This allows you to specify or use JSP functions for each different virtual host, respectively. Ok, you can start developing and using your web application! references: 1. http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jk2/jk2/vhosthowto.html 2. http://bbs.chinaunix.net/forum/6/20040214/259794.html 3. http://chinaUnix.net/jh/6/263220.html