Apache 2.0.43 / Tomcat 4.1.12 / mod_jk for Solaris

发表于:2007-06-09来源:作者:点击数: 标签:
First, you need a sane build environment. In the open source world, that means GNU tools, not the tools included with a Sun Dev cluster install. Also make sure you've installed the Sun Solaris 8_Recommended patch cluster. You'll also need
First, you need a sane build environment. In the open source world, that means GNU tools, not the tools included with a Sun Dev cluster install. Also make sure you've installed the Sun Solaris 8_Recommended patch cluster.

You'll also need openssl and openssh installed. I'm assuming here that if you have a Sun server and you have root access to it that you have some basic familiarity with system administration and know your way around a UNIX command line.

So, bop on over to sunfreeware.com, pick your OS, and grab the following GNU tools in Sun package format:

  • autoconf
  • automake
  • binutils
  • gcc (I used version 2.95.3)
  • glib
  • gzip
  • libtool
  • make
  • tar (don't use the tar included with Solaris...make sure GNU tar is first in your path)
  • wget
  • zlib

Install all of the packages listed above. Note that you'll need to install gzip first, as the other packages are compressed. The gzip package is not.

Apache + Tomcat is five major steps: build/install Apache, install JDK, build/install Tomcat, build/install a connector, configure. Since Tomcat is 100% Java, we'll use the binary install instead of having to deal with ant. I spend more time with Red Hat Linux than I do with Solaris, so my preference is to put things in /usr/local. Die-hard Solaris folks will need to substitute /opt, /var, or whatever as needed to suit their own preferences. Paths, in this scenario, don't have much effect as long as you can guarantee that they are consistent.

Build/Install APACHE
=====================

  1. grab Apache source from a mirror. You want version 2.0.43. The filename is httpd-2.0.43.tar.gz.
  2. unpack it
  3. read INSTALL file for instructions
  4. build apache with: ./configure --prefix=/usr/local/apache2 --enable-ssl --enable-module=so

    If you see a message that says "configuring package in srclib/apr now" and the build process seems to hang for several minutes, leave it alone, it will continue after a bit.

  5. when configure completes, run make.
  6. when make completes, run make install.
  7. You should now have an Apache instance in /usr/local/apache2. Verify config: /usr/local/apache2/bin/apachectl configtest
  8. If you get a "Syntax OK" message, startup Apache: /usr/local/apache2/bin/apachectl start
  9. Verify Apache is running: http://some.server.name You should see the Apache welcome page

NOTE: Apache2 uses a shorthand notation for the group ID in httpd.conf. If you have problems getting Apache2 to start on Solaris 8 from a default install, check the Apache error log (/usr/local/apache2/logs/error_log) for an error message. If you see one that says something like "[alert] (22)Invalid argument: setgid: unable to set group id to Group 4294967295" then edit httpd.conf, and change the line that says "Group #-1" to "Group nobody" then start/restart Apache. The Solaris kernel has difficulty with the "#-1" shorthand notation if the Group ID (gid) is over 60000 for the group nobody, which it is in Solaris 8 64-bit.

Install JDK
=====================

  1. go to java.sun.com and download J2SE for Solaris: http://java.sun.com/j2se/1.4.1/download.html Note that if you have a 64-bit Solaris install, you need to install the 32-bit J2SE first, then install the 64-bit J2SE. I prefer the SDK versions over the JRE versions.
  2. Install the 32-bit J2SE, and, if needed, the 64-bit J2SE. The 64-bit install simply overwrites some files and installs some new ones into the same location used for the 32-bit install, so do the 32-bit install first.
  3. Set JAVA_HOME as an environment variable, pointing to the location of the J2SE you just installed.

Build/Install TOMCAT
=====================

  1. grab the Tomcat binary package for 4.1.12. Get it here: http://jakarta.apache.org/builds/jakarta-tomcat-4.0/release/v4.1.12/bin/jakarta-tomcat-4.1.12.tar.gz
  2. unpack it to /usr/local. You should end up with /usr/local/jakarta-tomcat-4.1.12
  3. add a symbolic link: ln -s /usr/local/jakarta-tomcat-4.1.12 /usr/local/tomcat
  4. set CATALINA_HOME as an environment variable, pointing to /usr/local/tomcat
  5. startup Tomcat to test your installation: /usr/local/tomcat/bin/startup.sh. Verify the Tomcat examples are available at http://some.server.name:8080/examples

Build/Install Connector
=======================

The two connectors (JK and JK2) are different; JK2 is a complete rewrite of the earlier JK/AJP13 protocol. We'll cover building JK, with JK2 to come later.

Building JK Connector
=======================

NOTE: you can get a JK binary for Solaris 8 here: http://jakarta.apache.org/builds/jakarta-tomcat-connectors/jk/release/v1.2.0/bin/solaris8/. The version there was compiled against Apache 2.0.42 and should be compatible with 2.0.43. You are welcome to skip building JK from source and use the binary instead, but if you would rather build from source, here's how to do it:

  1. Grab the connector source from the Jakarta site: http://jakarta.apache.org/builds/jakarta-tomcat-connectors/jk/release/v1.2.0/src/jakarta-tomcat-connectors-jk-1.2.0-src.tar.gz
  2. Unpack it to /usr/local/src/
  3. From this point on, CONNECTOR_HOME = /usr/local/src/jakarta-tomcat-connectors-jk-1.2.0-src
  4. cd CONNECTOR_HOME/jk/native. Be sure to READ the file named BUILDING.
  5. run the buildconf script: ./buildconf.sh
  6. you may see some error messages about aclocal and autom4te...these can be ignored.
  7. run the configure script: ./configure --with-apxs=/some/path/to/apache2/bin/apxs
  8. run make
  9. the mod_jk.so file will be in CONNECTOR_HOME/jk/native/apache-2.0. Copy it to your Apache modules directory.

Final Configuration
=======================

NOTE: these steps will allow access to the Tomcat examples via Apache on port 80. Successful use of the examples on port 80 shows that mod_jk is working correctly, since Tomcat is configured to run on port 8080 by default for HTTP requests.

  1. Edit server.xml in CATALINA_HOME/conf.
  2. look for a line that says "Server" and has a port of 8005. Add the following directly below:

    <Listener className="org.apache.ajp.tomcat4.config.ApacheConfig" modJk="/usr/local/apache2/modules/mod_jk.so" />

  3. in the Host container add the following Listener directive (yes, it looks very similar to the one above):

    <Listener className="org.apache.ajp.tomcat4.config.ApacheConfig" append="true" forwardAll="false" modJk="/usr/local/apache2/modules/mod_jk.so" />

  4. change the name parameter in the Host directive to your apache ServerName (the default is localhost)
  5. Edit httpd.conf in APACHE_HOME/conf.

    - make sure your ServerName matches the name="" parameter in your tomcat Host element in server.xml
    - add the following line at the very end:

    Include /usr/local/tomcat/conf/auto/mod_jk.conf

    Note: the mod_jk.conf file gets created by tomcat when tomcat starts. It gets created every time tomcat starts. So, if you have your server.xml configured, you can ignore httpd.conf (in most cases) except to add the Include directive for mod_jk.conf. You don't need to create or edit mod_jk.conf. Click here for a sample mod_jk.conf file generated automatically by tomcat on each startup.

  6. Create a file in CATALINA_HOME/conf/jk called workers.properties. That file should look like this:

    # BEGIN workers.properties
    worker.list=ajp13
    worker.ajp13.port=8009
    # change this line to match apache ServerName and Host name in server.xml
    worker.ajp13.host=localhost
    worker.ajp13.type=ajp13
    # END workers.properties
  7. Startup tomcat: $CATALINA_HOME/bin/startup.sh
  8. Wait at least 10 seconds for tomcat to finish. Start apache: /usr/local/apache2/bin/apachectl start
  9. Verify examples at http://localhost:8080/examples. On success, tomcat is working correctly.
  10. Verify examples at http://localhost/examples. On success, apache is working correctly, and JSP and servlet requests are being passed to tomcat.

Back To Menu

Please send comments, suggestions, or changes to john AT johnturner DOT com. Be advised that I will be happy to help where I can, but I am not available for free one-on-one tech support to the whole world. :)

Copyright © 2002 John Turner. All rights reserved.

原文转自:http://www.ltesting.net