📄 install-apache.xtp
字号:
<document> <header> <product>resin</product> <title>Resin with Apache</title> <description> <p>Resin provides a fast servlet runner for Apache 1.3 or greater, allowing Apache to run servlets and JSP files. </p> </description> </header><body><s1><p>If you have not yet done so, we suggest you use the <a href="resin-web-server.xtp">Resin standalone web server</a> option first.</p></s1><localtoc/><s1 name="standalone" title="Before you integrate Resin with Apache"><p>Before integrating Resin with Apache, it is valuable to configure Resin as a<a href="resin-web-server.xtp">standalone server</a>, especially with morecomplicated setups such as those involving virtual hosts. Doing so isolatesthe steps and makes troubleshooting easier.</p> <p>Many users find that the performance, flexibility, and features of Resinmake Resin a desirable replacement for Apache.</p></s1><s1 name="dispatch" title="How Resin integrates with Apache"><p>When used with Apache, Resin serves JSPs and Servlets and Apache servesstatic content like html and images. Apache is a frontend server, it handlesthe request from the browser. Resin's <code>mod_caucho</code> plugin integrateswith Apache, it dispatches requests for JSPs and Servlets to one or morebackend Resin servers.</p><figure src="apache_srun.gif"/><p>mod_caucho queries the backend server to distinguish the URLs going to Resinfrom the URLs handled by Apache. The backend server uses the<servlet-mapping> directives to decide which URLs to send. Also, any *.warfile automatically gets all its URLs. Other URLs stay with Apache.</p><p>There's a more complete discussion of the URL dispatching in the<a href="plugin-dispatch.xtp">How the Plugins Dispatch to Resin</a> page.</p></s1> <!-- dispatch --><s1 name="unix" title="Unix Installation"><p>Resin needs Apache 1.3.x or greater and DSO support.</p><p>To configure Resin with Apache, you must follow the following steps:</p><ol><li>Compile Apache</li><li>Compile mod_caucho.so</li><li>Configure Apache</li><li>Set up environment</li><li>Configure resin.xml</li><li>Restart Apache and start the backend Resin server</li></ol><s2 title="Compiling Apache"><p>You need a version of Apache with DSO support enabled. Apache hasfull documentation at <a href="http://httpd.apache.org/docs/dso.html">their website</a>.To check if your apache has DSO support, you can check for<var>mod_so.c</var> in your your httpd<example title="checking apache httpd for mod_so.c">unix> /usr/local/apache/bin/httpd -lCompiled-in modules: ... mod_so.c ... </example></p><p>Many distributions, e.g. Red Hat Linux, will have Apache preinstalled.However, because the standard distribution has files all over theplace, some people prefer to recompile Apache from scratch.</p><p>Once you untar Apache, build it like:</p><example>unix> ./configure --prefix=/usr/local/apache --enable-module=sounix> makeunix> make install</example><p>Solaris versions of Apache may need additional flags, otherwiseyou'll get some linking errors when trying to load Resin. You may needto refer to the Apache documentation if you get linking errors. Here's anexample configuration on Solaris:</p><example>unix> ./configure --prefix=/usr/local/apache \ --enable-rule=SHARED_CORE \ --enable-rule=SHARED_CHAIN \ --enable-module=so \ --enable-module=most \ --enable-shared=max</example></s2><s2 title="Compiling mod_caucho.so"><p>To compile and install <var>mod_caucho</var> on Unix, you'll need to runResin's <code>configure</code> and then make. This step will create mod_caucho.so and put it in the Apache module directory. Usually,mod_caucho.so will end up in /usr/local/apache/libexec/mod_caucho.so.</p><p>If you know where your <var>apxs</var> executable is, you can use --with-apxs.<var>apxs</var> is a little Perl script that the Apache configurationmakes. It lets modules like Resin know how all the Apache directoriesare configured. It is generally in /usr/local/apache/bin/apxs or/usr/sbin/apxs. It's usually easiest to use --with-apxs so you don'tneed to worry where all the Apache directories are.</p><example>unix> ./configure --with-apxs=/usr/local/apache/bin/apxsunix> make</example><p>Even if you don't know where <var>apxs</var> is, the configure scriptcan often find it:</p><example>unix> ./configure --with-apxsunix> make</example><p>As an alternative to --with-apxs, if you've compiled Apache yourself,or if you have a simple configuration, you can generally just point tothe Apache directory:</p><example>unix> ./configure --with-apache=/usr/local/apacheunix> makeunix> make install</example><p>The previous --with-apxs or --with-apache should cover mostconfigurations. For some unusual configurations, you can have finer controlover each directory with the following arguments to ./configure.In general, you should use --with-apache or --with-apxs, but the othervariables are there if you know what you're doing.</p><deftable><tr><td>--with-apache=dir</td><td>The Apache root directory.</td></tr><tr><td>--with-apxs=apxs</td><td>Pointer to the Apache extension script</td></tr><tr><td>--with-apache-include=dir</td><td>The Apache include directory</td></tr><tr><td>--with-apache-libexec=dir</td><td>The Apache module directory</td></tr><tr><td>--with-apache-conf=httpd.conf</td><td>The Apache config file</td></tr></deftable></s2><s2 title="Configure the Environment"><p>If you don't already have Java installed, you'll need to download aJDK and set some environment variables.</p><p>Here's a typical environment that you might put in ~/.profile or/etc/profile</p><example># Java LocationJAVA_HOME=/<installdir>/jdk1.4export JAVA_HOME# Resin location (optional). Usually Resin can figure this out.RESIN_HOME=/<installdir>/resin-3.2.2export RESIN_HOME# If you're using additional class libraries, you'll need to put them# in the classpath.CLASSPATH=</example></s2></s1> <!-- unix --><s1 name="windows" title="Windows Installation"><p>The <code>setup.exe</code> program installs the mod_caucho.dllplugin for any Apache it finds, and modifies the Apache httpd.conf file.</p><p>The httpd.conf file is also easily modified manually:</p><example title="httpd.conf">LoadModule caucho_module \ <installdir>/resin-3.2.x/win32/apache-2.0/mod_caucho.dllResinConfigServer localhost 6800<Location /caucho-status> SetHandler caucho-status</Location></example></s1> <!-- windows --><s1 title="Configuring resin.xml"><p>The communication between <code>mod_caucho</code> and the backend Resinserver takes place using a <var>server</var> port.</p><p>The <code>resin.xml</code> for the backend server containsa <code>server</code> to enable the port. The default <code>resin.xml</code>has an server listener on port 6800.</p><example title="resin.xml"><resin xmlns="http://caucho.com/ns/resin" xmlns:resin="http://caucho.com/ns/resin/core"> ... <cluster id="app-tier"> ... <b><server id="" address="127.0.0.1" port="6800"/></b> ...</example><p>The resin.xml and the layout of your webapps should match thelayout that Apache expects. The mapping of urls to filesystem locationsshould be consistent between Apache and the backend Resin server.</p><p>The default resin.xml looks in<code>resin-3.2.x/webapps/ROOT</code> for JSP files and<code>resin-3.2.x/webapps/ROOT/WEB-INF/classes</code>for servlets and java source files. To tell Resinto use Apache's document area, you configure an explicit <var>web-app</var> with the appropriate document-directory:</p><example title="resin.xml"><resin xmlns="http://caucho.com/ns/resin" xmlns:resin="http://caucho.com/ns/resin/core"> ... <server> ... <host id=""> <web-app id='/' document-directory="/usr/local/apache/htdocs"/> </host> ... </server></resin></example></s1><s1 title="Starting the app-tier Resin server"><p>Now you need to start the app-tier Resin server. Starting Resin is the samewith Apache or standalone. See the <a href="resin-web-server.xtp#deploy">Resin Web Server</a> pagefor a detailed description.</p><example>unix> java -jar $RESIN_HOME/lib/resin.jarunix> bin/resin.shwin> resin.exe</example><results>Resin 3.2.2 (built Mon Aug 4 09:26:44 PDT 2006)Copyright(c) 1998-2006 Caucho Technology. All rights reserved. Starting Resin on Mon, 04 Aug 2006 09:43:39 -0700 (PDT)[09:43:40.664] Loaded Socket JNI library.[09:43:40.664] http listening to *:8080[09:43:40.664] ServletServer[] starting[09:43:40.879] hmux listening to *:6800[09:43:41.073] Host[] starting[09:43:41.446] Application[http://localhost:8080/resin-doc] starting[09:43:41.496] Application[http://localhost:8080] starting</results><p>Resin will print every port it's listening to. In the above example,Resin has an http listener on port 8080 and an server listener on port 6800(using its custom 'hmux' protocol). mod_caucho establishes connections toResin using port 6800, and a web browser can connect using port 8080. Usuallythe 8080 port will be unused, because web browsers will make requests to Apache,these requests get dispatched to Resin as needed by mod_caucho. A Resinconfigured http listener on port 8080 is a useful debugging tool, it allows youto bypass Apache and make a request straight to Resin.</p><p>The following snippet shows the<<a href="port-tags.xtp#http">http</a>>and <<a href="server-tags.xtp#server">server</a>>configuration for the above example.</p><example><resin xmlns="http://caucho.com/ns/resin"> <cluster id="app-tier"> <server-default> <http address="*" port="8080"/> </server-default> <server id="" address="192.168.2.10" port="6800"/> ... </cluster></resin></example></s1><s1 title="Testing the servlet engine">
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -