home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / xampp / xampp-cocoon-addon-1.4.9-installer.exe / faq-configure-environment.xml < prev    next >
Encoding:
Extensible Markup Language  |  2004-07-12  |  9.9 KB  |  319 lines

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3.   Copyright 1999-2004 The Apache Software Foundation
  4.  
  5.   Licensed under the Apache License, Version 2.0 (the "License");
  6.   you may not use this file except in compliance with the License.
  7.   You may obtain a copy of the License at
  8.  
  9.       http://www.apache.org/licenses/LICENSE-2.0
  10.  
  11.   Unless required by applicable law or agreed to in writing, software
  12.   distributed under the License is distributed on an "AS IS" BASIS,
  13.   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.   See the License for the specific language governing permissions and
  15.   limitations under the License.
  16. -->
  17. <!DOCTYPE faqs PUBLIC "-//APACHE//DTD FAQ V1.0//EN" "faq-v10.dtd">
  18.  
  19. <faqs title="Environment Configuration FAQs">
  20.  
  21. <faq>
  22.  <question>How can I reach my Cocoon app from an URI other than
  23.    <your-server>/cocoon/<my-app>?
  24.  </question>
  25.  <answer>
  26.    <p>
  27.      Suppose the following.
  28.    </p>
  29.    <ol>
  30.      <li>You have a Cocoon application named "bar" which works fine when
  31.        called with this URI: http://www.foo.com/cocoon/bar/index.html
  32.      </li>
  33.      <li>You want the "bar" app to be called from
  34.        http://www.foo.com/bar/index.html instead (getting rid of "cocoon").
  35.      </li>
  36.    </ol>
  37.    <p>
  38.      There are, basically, two methods to achieve this.
  39.    </p>
  40.    <ol>
  41.      <li>
  42.        Set Cocoon as the root servlet in your servlet-container
  43.      </li>
  44.      <li>Rewrite the URI in the web-server. (When a user asks for
  45.        http://www.foo.com/bar/index.html, the web-server redirects him/her to
  46.        http://www.foo.com/cocoon/bar/index.html
  47.      </li>
  48.    </ol>
  49.    <p>
  50.      Let us explore the first method (Cocoon as the root servlet).
  51.    </p>
  52.    <note>
  53.      This entry was tested under: Windows 2000
  54.      Professional + IIS 5.0 + Tomcat 4.0.1 + Cocoon 2.0.2.
  55.    </note>
  56.    <ol>
  57.      <li>
  58.        Edit the server.xml file which is located under $TOMCAT_HOME/conf
  59.      </li>
  60.      <li>
  61.        Go to the line containing "Tomcat Root Context". (This should be a comment).
  62.      </li>
  63.      <li>
  64.        Add following line after that comment:
  65.        <code>
  66.          <context path="" docBase="/cocoon" debug="0"/>
  67.        </code>
  68.      </li>
  69.      <li>
  70.        Re-start Tomcat.
  71.      </li>
  72.      <li>
  73.        Try: http://www.foo.com:8080/ and the Cocoon welcome page should appear
  74.      </li>
  75.    </ol>
  76.    <p>
  77.      Now, http://www.foo.com/bar/index.html should also work.
  78.    </p>
  79.    <p>
  80.      Let us explore the second method (URI rewriting).
  81.    </p>
  82.    <note> This entry was tested under: Windows NT 4.0 + Apache 1.3.14 + Tomcat 3.2 +
  83.      Cocoon 2.0b1. It is Apache-specific.
  84.    </note>
  85.    <p>
  86.      The idea is just to redirect a portion of the desired URI (bar) to the one within
  87.      the cocoon context (cocoon/bar).
  88.    </p>
  89.    <p>
  90.      Apache has an handy feature called mod_rewrite that does just this: URI
  91.      rewriting. (See the "URL Rewriting Guide" in the Apache user's guide for
  92.      details).
  93.    </p>
  94.    <p>
  95.      First of all, you should instruct Apache to load the mod_rewrite. 
  96.      Add (on a Windows system) to httpd.conf the following line:
  97.    </p>
  98.    <source>
  99.      LoadModule rewrite_module modules/ApacheModuleRewrite.dll
  100.    </source>
  101.    <p>
  102.      (By the way it's quite likely that this line is already on the httpd.conf. You
  103.      just have to uncomment it).
  104.    </p>
  105.    <p>
  106.      Add this line to httpd.conf in order to activate mod_rewrite:
  107.    </p>
  108.    <source>
  109.      RewriteEngine On
  110.    </source>
  111.    <p>
  112.      It is highly recommended to use the logging option of mod_rewrite, in
  113.      order to check the correctness of the URI rewriting. Just add these lines
  114.      to the httpd.conf:
  115.    </p>
  116.    <source>
  117.      RewriteLog "C:/logs/rewrite.log"
  118.      RewriteLogLevel 9
  119.    </source>
  120.    <p>
  121.      The first line tells Apache to put the URI rewriting log in the
  122.      c:\logs\rewrite.log file (which happens to be on a Windows system, of
  123.      course). The second one tells Apache to record everything mod_rewrite
  124.      does. If you don't want to log anything, just set RewriteLogLevel to
  125.      0.
  126.    </p>
  127.    <p>
  128.      Now, it's time to do the URI rewriting trick.
  129.    </p>
  130.    <source>
  131.      RewriteRule bar/(.*) /cocoon/bar/$1 [PT]
  132.    </source>
  133.    <p>
  134.      This line instructs Apache to redirect everything under "bar" to
  135.      "cocoon/bar" and to pass it on for other processing ("[PT]" option),
  136.      like mod_alias.
  137.    </p>
  138.    <p>
  139.      Just restart Apache and point your browser to:
  140.    </p>
  141.    <source>
  142.      <your-server>:8080/bar/<something>
  143.    </source>
  144.    <p>
  145.      It should work just fine.
  146.    </p>
  147.    <note>
  148.      The RewriteRule may not work in all cases (notably under Slackware Linux with Apache 1.3),
  149.      if so, try replacing it with:
  150.      RewriteRule ^/Foo /cocoon/Foo/ [R]
  151.      RewriteRule ^/Foo(.*) /cocoon/Foo$1 [R]
  152.    </note>
  153.    <note>
  154. Another user adds: In my experience, session support is lost when you use mod_rewrite because the cookie path for the Cocoon session is "/cocoon". Because the browser sees the path differently, the session cookie is not granted access, and sessions don't work. I got around this by renaming Cocoon to ROOT, I imagine setting the default docBase would have the same effect.   
  155.   </note>
  156.  </answer>
  157. </faq>
  158.  
  159. <faq>
  160.  <question>How could I have my Cocoon app located in a directory other than
  161.    $TOMCAT_HOME/webapps/cocoon/<my-app>?
  162.  </question>
  163.  <answer>
  164.    <note>
  165.      This entry was tested under Windows NT 4.0 + Apache 1.3.14 + Tomcat 3.2 + Cocoon
  166.      2.0b1.
  167.    </note>
  168.    <p>Let's suppose the following.</p>
  169.    <ol>
  170.      <li>
  171.        You have an application called "foo" which works perfectly when
  172.        located under the %TOMCAT_HOME%\webapps\cocoon\foo directory.
  173.      </li>
  174.      <li>
  175.        You want it to be located under the "c:\foo" directory instead
  176.     </li>
  177.    </ol>
  178.    <p>
  179.      This could be accomplished quite easily by twisting the sitemap a little bit. The
  180.      idea is to mount the sub-sitemap of the "foo" application in a specific
  181.      location of the file system instead of under the default cocoon context.
  182.    </p>
  183.    <p>
  184.      Here's the sitemap.xmap fragment used to do this.
  185.    </p>
  186.    <source>
  187. <![CDATA[
  188. <map:pipeline>
  189.  <map:match pattern="foo/**">
  190.   <map:mount uri-prefix="foo" src="file:///c:/foo/"/>
  191.  </map:match>
  192. </map:pipeline>
  193. ]]>
  194.   </source>
  195.    <p>
  196.      The "file:" type of source instructs Cocoon to search the sub-sitemap
  197.      under the specified directory (which happens to be "c:\foo", since this
  198.      is a Windows system). See explanation of
  199.      <link href="../userdocs/concepts/sitemap.html#file-url">file: URLs</link>
  200.    </p>
  201.    <p>
  202.      Now, you just need to copy everything which was under the
  203.      %TOMCAT_HOME%\webapps\cocoon\foo directory to the c:\foo directory, and it should work
  204.      graciously.
  205.    </p>
  206.  </answer>
  207. </faq>
  208.  
  209. <faq>
  210.   <question>
  211.     How do I integrate Apache Server and Cocoon?
  212.   </question>
  213.   <answer>
  214.     <p>
  215.       See the Wiki page 
  216.       <link href="http://wiki.cocoondev.org/Wiki.jsp?page=ApacheModProxy">ApacheModProxy</link>
  217.       for a thorough discussion of this topic.
  218.     </p>
  219.     <p>
  220.       Another method is to use mod_jk. Add the following line to
  221.       <code>%APACHE_HOME%\conf\httpd.conf</code>
  222.     </p>
  223.     <source>
  224.       JkMount /cocoon/* ajp12
  225.     </source>
  226.     <p>
  227.       along with other directives that are already listed in mod_jk.conf-auto
  228.       in the tomcat/conf directory. The above directives can be added at the
  229.       end of httpd.conf.
  230.     </p>
  231.   </answer>
  232. </faq>
  233.  
  234. <faq>
  235.   <question>
  236.     How can I improve performance by making the web-server deliver the static contents ?
  237.   </question>
  238.   <answer>
  239.     <p>
  240.       Fairly easy to do.
  241.     </p>
  242.    <ol>
  243.      <li>
  244.        Put the static contents in a physical directory. (Let's call it "c:\foo\static-stuff".
  245.        On UNIX it may be "/foo/static-stuff".)
  246.      </li>
  247.      <li>
  248.        Make a virtual directory out of "c:\foo\static-stuff" (or, under UNIX "/foo/static-stuff")
  249.        in you favorite web-server, and name it "static-foo".
  250.      </li>
  251.      <li>
  252.        Reference the static contents in your Cocoon app by URIs starting with "/static-foo", as in:
  253.        "/static-foo/images/foo.gif" or "/static-foo/scripts/bar.js"
  254.      </li>
  255.    </ol>
  256.     <p>
  257.       The web-server will now handle the static contents, leaving Cocoon to take care of the
  258.       dynamic stuff only, delivering optimal performance.
  259.     </p>
  260.   </answer>
  261. </faq>
  262.  
  263. <faq>
  264.   <question>
  265.     Why won't my Batik .JPG and .PNG samples work? How can I run Cocoon without X11?
  266.     Why is a Display needed?
  267.   </question>
  268.   <answer>
  269.    <p>If your Batik .JPG and .PNG samples don't work it is probably because you have not
  270.      installed and configured a graphics display. You have a couple of options depending on
  271.      your environment.
  272.    </p>
  273.    <p>If you are using the Sun JDK 1.4 then you can use the 'headless' environment.
  274.      For more information about this see 
  275.      <link href="../installing/index.html#Headless+UNIX+and+PJA">Headless UNIX and PJA</link>.
  276.    </p>
  277.    <p>
  278.      Otherwise, an XServer is needed because of the Batik library that FOP uses.
  279.      Batik uses Java's graphics code, which in turn requires the XServer.
  280.      If you don't have an XServer on your system and can't set the DISPLAY
  281.      variable to one, then try out XVFB. XVFB gives you an 'in-memory'
  282.      XServer, which doesn't require any display hardware to run.
  283.    </p>
  284.  
  285.    <source><![CDATA[
  286. $> Xvfb :1 -screen 0 800x600x8 &
  287. $> export DISPLAY=:1
  288. $> $TOMCAT_HOME/bin/startup.sh -f server.xml
  289. ]]>
  290.    </source>
  291.    <p>See also <link href="../installing/index.html#UNIX+with+X+server">UNIX with X server</link></p>
  292.   </answer>
  293. </faq>
  294.  
  295. <faq>
  296.   <question>
  297.     How can I access Cocoon's status page in a mixed servlet environment
  298.     where "/" is not mapped to Cocoon (only *.xml, *.xsp)?
  299.   </question>
  300.   <answer>
  301.   <p>
  302. Just change the status pipeline so it matches a request with a ".xml" extension:
  303.   </p>
  304.   
  305.    <source><![CDATA[
  306.    <map:match pattern="status.xml">
  307.     <map:generate src="status" type="status"/>
  308.     <map:transform src="welcome/status2html.xsl"/>
  309.     <map:serialize/>
  310.    </map:match>
  311. ]]></source>
  312.   <p>
  313. Then you can access the status page with "status.xml".
  314.   </p>
  315. </answer>
  316. </faq>
  317.  
  318. </faqs>
  319.