Modjk: Running Dspace On Apache HTTPD and Tomcat Using The Mod - JK Connector
Modjk: Running Dspace On Apache HTTPD and Tomcat Using The Mod - JK Connector
Running DSpace on Apache HTTPD and Tomcat using the mod_jk connector
For some background on why you'd want to do this, and the principles behind
the configuration, see pages on Securing DSpace and Running DSpace on Standard Ports.
Note: These instructions are for Linux, and may be somewhat specific to Red Hat Enterprise Linux 3.2.3-52 and the following software versions (but
hopefully they are still helpful for other distros)
Anyone who has successfully set up mod_jk connector under different conditions should feel free to add their notes!
locate mod_jk
If there is no response, then mod_jk is not installed. Otherwise, if it is installed, you can obviously skip the next step!
(2) Before trying to build mod_jk, you must make sure you have the following pre-requisite programs installed (use the which command to check for
each):
libtool (ftp://ftp.gnu.org/gnu/libtool)
autoconf (http://ftp.gnu.org/gnu/autoconf)
ant (http://jakarta.apache.org/ant/)
ant should already be installed (since it's necessary for DSpace). If libtool or autoconf are missing (both should be in /usr/bin), download
the source and compile using the following commands:
./configure
make
make install
(3) In addition, you must have the Apache Web Server development tools installed. A quick way to check for this is to check for the APache eXtenSion tool
(apxs). It should probably be in /usr/sbin, if installed:
which apxs
If apxs is missing, you can use the following command in Red Hat to install the httpd-devel RPM as root (Other distros may need to find and install this
RPM through other means):
up2date -i httpd-devel
(4) Download the latest mod_jk source from the Tomcat Download site http://jakarta.apache.org/site/downloads/downloads_tomcat.html.
(6) Configure the connectors with the path to the apxs file on your system:
cd jakarta-tomcat-connectors-1.2.14.1-src
cd jk/native
./configure --with-apxs=/usr/sbin/apxs
make
(8) Assuming all went well, the mod_jk.so file will be created in the apache-2.0 subdirectory. You need to copy this file to Apache's shared object files
directory (e.g. /etc/httpd/modules/). From the same jk/native directory run the following:
cp apache-2.0/mod_jk.so /etc/httpd/modules
(9) In addition, copy the sample workers.properties file to the Apache configuration directory (e.g. /etc/httpd/conf/). Assuming you are still in the jk
/native directory, run the following commands:
cd ../conf
cp workers.properties /etc/httpd/conf
workers.tomcat_home=tomcat
workers.java_home=java
worker.list=ajp13,lb,jk-status
In addition, you may need to uncomment (and possibly change) the JVM for Unix:
For later versions of mod_jk (I installed 1.2.40) worker.iprocess.jvm_lib is deprecated and would throw an warning. I omitted this line with no
problems.
However, the correct path of the libjvm.so (at least for Red Hat) is java/jre/lib/i386/server/libjvm.so (i.e. "server/libjvm.so", not "clas
sic/libjvm.so")
#For extra security, deny direct access to any WEB-INF and META-INF directories
<LocationMatch "/WEB-INF/">
AllowOverride None
Deny from all
</LocationMatch>
<LocationMatch "/META-INF/">
AllowOverride None
Deny from all
</LocationMatch>
The big thing to pay attention to is the context which you specify in JkMount! If you specify /dspace/*, then only requests to http://my-host-name
/dspace/* will be forwarded to Tomcat! However, if you specify /*, then all requests to http://my-host-name/* will be forwarded to Tomcat.
Notice, first you specify that all requests should be forwarded to Tomcat. But, then for specific UI's you can specify to ignore mod_jk (using the no-jk
environment variable). So, the above specifies that everything except paths matching http://my-host-name/cgi-bin/* or http://my-host-name
/anotherApp/* are forwarded to Tomcat.
Step 5 - Configure Tomcat
Next, you need to take a look at the Tomcat server.xml configuration file (in the /conf} subdirectory, whereever Tomcat is installed). Ensure that the
following AJP 1.3 Connector is uncommented:
Make sure that the port specified corresponds to the port you defined for the ajp13 worker (this port number is defined in the workers.properties
file, as shown above). In addition, make sure the UIEncoding is set to UTF-8, and tomcatAuthentication is set to false (assuming you want
authentication taken care of in Apache rather than Tomcat). Finally, make sure you set the redirectPort to be the port that Tomcat is running on
(usually either 8443, for HTTPS, or 8080, for HTTP).
http://localhost:8080/dspace
http://localhost/dspace
Hopefully everything works for you! If it doesn't, ask questions to the Mailing Lists. If you find any problems with the above instructions, feel free to edit and
enhance them!