⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cse-apache-unix.xtp

📁 解压在c盘
💻 XTP
字号:
<s1 title="Resin with Apache on Unix"><summarylist/><p>Resin provides a fast servlet runner for Apache, allowing Apacheto run servlets and JSP files.  The servlet runner needs Apache 1.3.xand DSO support.</p><figure src='apache_srun.gif'/><s2 title='Installation'><p>To configure Resin with Apache, you must follow the following steps:</p><ol><li>Compiling Apache<li>Compile mod_caucho.so<li>Configure Apache<li>Set up environment<li>Configure resin.conf<li>Restart Apache and start srun</ol><s3 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">http://httpd.apache.org/docs/dso.html</a>.</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></s3><s3 title='Compiling mod_caucho.so'><p>To compile and install <var/mod_caucho/> on Unix, you'll need to runResin's <code/configure/> 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/> executable is, you can use --with-apxs.<var/apxs/> 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> makeunix> make install</example><p>Even if you don't know where <var/apxs/> is, the configure scriptcan often find it:</p><example>unix> ./configure --with-apxsunix> makeunix> make install</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>The Apache root directory.<tr><td>--with-apxs=apxs<td>Pointer to the Apache extension script<tr><td>--with-apache-include=dir<td>The Apache include directory<tr><td>--with-apache-libexec=dir<td>The Apache module directory<tr><td>--with-apache-conf=httpd.conf<td>The Apache config file</deftable></s3><s3 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=/&lt;installdir>/jdk1.2.2export JAVA_HOME# Resin location (optional).  Usually Resin can figure this out.RESIN_HOME=/&lt;installdir>/resin1.2export RESIN_HOME# If you're using additional class libraries, you'll need to put them# in the classpath.CLASSPATH=</example></s3><s3 title='Configuring resin.conf'><p>By default, Resin will look in resin-2.1.0/doc for JSP files andresin-2.1.0/doc/WEB-INF/classes for servlets and beans.  To tell Resinto use Apache's document area, you configure the <var/app-dir/>.Change <var/app-dir/> from 'doc' to something like '/usr/local/apache/htdocs'.</p><example title='resin.conf'>&lt;caucho.com>  &lt;http-server      app-dir='/usr/local/apache/htdocs'>    &lt;servlet-mapping url-pattern='/servlets/*'              servlet-name='invoker'/>    &lt;servlet-mapping url-pattern='*.xtp'                        servlet-name='com.caucho.jsp.XtpServlet'/>    &lt;servlet-mapping url-pattern='*.jsp'                        servlet-name='com.caucho.jsp.JspServlet'/>  &lt;/http-server>&lt;/caucho.com></example></s3><s3 title='Starting the Servlet Engine'><p>Now you need to start the servlet engine.  Starting Resin is the samewith Apache or standalone.  See the <a href="httpd.xtp#deploy">httpd</a> pagefor a detailed description.</p><example>unix> resin1.2/bin/httpd.shResin 1.2.s010113 -- Sat Jan 13 11:17:18 PST 2001http listening to *:8080srun listening to localhost:6802</example><p>Resin will print every port it's listening to.  In the above example,Resin is listening to port 8080 using HTTP and 6802 using its servletrunner protocol.  In other words, mod_caucho can connect to Resinwith 6802 only on same host, but you can browse port 8080 from any host.</p><p>The following snippet shows the <var/&lt;http>/> and <var/&lt;srun>/>configuration for the above example.</p><example>&lt;caucho.com>  &lt;http-server>    &lt;http port='8080'/>    &lt;srun host='localhost' port='6802'/>    ...  &lt;/http-server>&lt;/caucho.com></example></s3><s3 title='Testing the servlet engine'><p>Create a test file '/usr/local/apache/htdocs/test.jsp'</p><example>2 + 2 = &lt;%= 2 + 2 %></example><p>Browse http://localhost/test.jsp again.  You should now get</p><results>2 + 2 = 4</results></s3></s2><s2 title='Configuring Apache by hand'><p>Making mod_caucho will automatically change your httpd.conf file.You can also configure Apache directly, instead of letting mod_caucho readthe configuration from the resin.conf file. If you use this method, youneed to make sure you match the Apache configuration with the Resinconfiguration.</p><example title=httpd.conf>LoadModule caucho_module libexec/mod_caucho.soAddModule mod_caucho.c&lt;IfModule mod_caucho.c&gt;  CauchoConfigFile &lt;installdir>/resin1.2/conf/resin.conf  &lt;Location /caucho-status>    SetHandler caucho-status  &lt;/Location>&lt;/IfModule&gt;</example><note>The caucho-status is optional and probably should be avoided ina production site.  It lets you ask the Caucho Apache module about theCaucho status, valuable for debugging.</note><p>Restart Apache.  Now browse http://localhost/caucho-status.  Itshould return a table indicating that the servlet runner is stopped.</p><p>Browse http://localhost/test.jsp.  It should return a message like:<results>Cannot connect to Servlet Runner.</results><p>You can also dispatch to Resin directly from the httpd.conf.  The apache handler name is "caucho-request".</p><deftable><tr><th>Apache Handler<th>Meaning<tr><td>caucho-status<td>Handler to display /caucho-status<tr><td>caucho-request<td>Dispatch a request to Resin</deftable><p>Requests dispatched directly from the Apache httpd.conf will notappear in /caucho-status.  You can use caucho-request as follows:</p><example>&lt;Location /foo/*>  SetHandler caucho-request&lt;/Location></example><deftable><tr><th>Apache Command<th>Meaning<tr><td>CauchoConfigFile <var/conf/><td>Reads <var/conf/> for the Resin configuration.<tr><td>CauchoServerRoot <var/directory/><td>Configures the equivalent of -server-root.<tr><td>CauchoHost <var/host/> <var/port/><td>Adds the Resin JVM at <var/host:port/> as a servlet runner.<tr><td>CauchoBackup <var/host/> <var/port/><td>Adds the Resin JVM at <var/host:port/> as a backup servlet runner.<tr><td></deftable><s3 title="Virtual Hosts"><p>The <a href="virtual-host.xtp">virtual host</a> topic describes virtualhosts in detail.  If you're using a single JVM, you only need to configurethe resin.conf.  If you want a different JVM for each virtual host, yourhttpd.conf can load a different resin.conf for each JVM:</p><example title='httpd.conf'>&lt;VirtualHost foo.com>ServerName foo.comServerAlias www.foo.comCauchoConfigFile /home/foo/conf/foo.conf&lt;/VirtualHost>&lt;VirtualHost bar.com>ServerName bar.comServerAlias www.bar.comCauchoConfigFile /home/bar/conf/bar.conf&lt;/VirtualHost></example><p>The foo.conf might look something like:</p><example title='foo.conf'>&lt;caucho.com>&lt;http-server>  &lt;srun host='foo.com' port='6802'/>  &lt;host id='www.foo.com'>     ...  &lt;/host>&lt;/caucho.com></example></s3><s3 title="Dispatching"><p>mod_caucho selects URLs specified by the servlet-mapping directives to go toResin.  Other URLs stay with Apache.  There's a more completediscussion of the URL dispatching in the <ahref="../java_tut/plugin-dispatch.xtp">plugin-dispatch</a> tutorial.</p></s3></s2><s2 name="balance" title='Load Balancing' version='Resin 1.2'><p>In Resin 1.2, you can distribute requests to multiple machines.  Allrequests in a session will go to the same host.  In addition, if onehost goes down, Resin will send the request to the next available machine.</p><p>In addition, you can specify backup machines.  The backup only will serverequests if all primaries are down.</p><p>See the <a href='http-config.xtp'>http config</a> section for moredetails.</p><example title="resin.conf">&lt;caucho.com>&lt;http-server>  &lt;srun id="a" host='host1' port='6802'/>  &lt;srun id="b" host='host2' port='6802'/>  &lt;srun-backup id="c" host='backup port='6802'/>  ...&lt;/http-server>&lt;/caucho.com></example></s2><s2 title='Error Page' version='Resin 1.2'><p>When mod_caucho can't reach any JVM, it will send a default errorpage.  Sites can customize the error page with the<var/error-page/> directive in the resin.conf.</p><example title=resin.conf>...&lt;web-app>  &lt;error-page exception-type='connection'              location='/conn_error_page.html'/>  ...&lt;/web-app></example></s2><s2 title='Troubleshooting'><ol><li>First, check your configuration with the standalone httpd.sh.  In other words, add a &lt;http port='8080'/> and check port 8080.<li>Check http://localhost/caucho-status.  That will tell ifmod_caucho has properly read the resin.conf.  <li>Each srun host should be green and the mappings shouldmatch your resin.conf.<li>If caucho-status fails entirely, the problem is in the mod_cauchoinstallation and the Apache httpd.conf.<li>If caucho-status shows the wrong mappings, there's something wrongwith the resin.conf or the pointer to resin.conf in httpd.conf.<li>If caucho-status shows a red servlet runner, then httpd.sh hasn'tproperly started.<li>If you get a "cannot connect to servlet engine", caucho-statuswill show red, and httpd.sh hasn't started properly.<li>If httpd.sh doesn't start properly, you should look at the logsin resin1.2/log.  You should start <var/httpd.sh -verbose/> to getmore information.<li>If httpd.sh says "no servers defined", your resin.conf is missing a&lt;srun> or &lt;httpd> definition.<li>If httpd.sh never shows a "srun listening to *:6802" line,it's not paying attention to mod_caucho.  You'll need to add a &lt;srun>line.<li>If httpd.sh shows "srun listening to localhost:6802" line, only anApache on the same host can connect to the srun.  If you need an Apacheon a different host to connect to srun, you'll need to change the<var/host/> attribute in the srun configuration.<li>If you get Resin's "file not found", the Apache configurationis good but the resin.conf probably points to the wrong directories.</ol></s2></s1>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -