?? guide-admin.xtp
字號:
<document><header><title>User Guide: Administration</title><description><p>Overview and introduction to Resin from an administration perspective.</p></description></header><body><localtoc/><s1 title="Terminology"><ul><li><b>cluster</b> - A set of <em>servers</em> configured to serveidentical content. Even a solo server will belong to its owncluster.</li><li><b>default host</b> - A virtual host configured to handle anyrequests not maching a specified host.</li><li><b>host</b> - An internet domain like www.slytherin.com whose contentis handled by a cluster. Also called virtual host.</li><li><b>keepalive</b> - A HTTP connection kept open after a request finishesso the next request to the server will be more efficient.</li><li><b>load-balancer</b> - A Resin <em>server</em> which forwards requeststo an application cluster for increased scalability and reliability.</li><li><b>machine</b> - A physical computer. Multiple <em>servers</em> can run on the same machine.</li><li><b>port</b> - A server's internet connection handling a specific protocol,e.g. a HTTP port 80 or HTTPS port 443 or XMPP (Jabber) port 5222.</li><li><b>proxy cache</b> - A content cache in front of a web application,storing the content and returning it quickly without running the application.Speedups for some applications can be 10x or 100x.</li><li><b>server</b> - A Resin instance running on a single JVM. One ormore servers can run on the same <em>machine</em>.</li><li><b>servlet</b> - A Java program responsible for serving web content. Allcontent is handled by a servlet, including static files,JSPs and PHP content.</li><li><b>thread</b> - An active execution of a Java program. Because Javais multithreaded, multiple Java programs are running simultaneously.For example, each HTTP user/request is handled by its own Java thread.</li><li><b>watchdog</b> - A Resin Java process responsible for starting andrestarting Resin <em>servers</em> for reliability.</li><li><b>webapp</b> - A web application is a content collection, like aDrupal or Mediawiki site. All content belongs to a webapp.</li></ul><figure src="cluster-load-balance.png"/><p>In the previous figure:</p><ul><li>The <em>servers</em> are "web-a", "app-a" and "app-b".</li><li>The <em>clusters</em> are "web-tier" and "app-tier".</li><li>The <em>virtual hosts</em> are "foo.com" and "bar.com".</li><li>The <em>webapps</em> are "/", "/wiki" and "/drupal".</li><li>Both <em>servers</em> "app-a" and "app-b" in the <em>cluster</em>"app-tier" serve identical content, i.e. the same <em>virtualhosts</em> and <em>webapps</em>.</li><li>web-a has a <em>proxy-cache</em> and <em>load balancer</em>.</li><li>web-a listens to HTTP <em>port</em> 80.</li><li>app-a and app-b listen to cluster <em>port</em> 6800 and 6801.</li><li>All three <em>servers</em> could be on the same <em>machine</em> oron separate <em>machines</em>.</li></ul></s1><s1 title="Dispatching Content"><p>All HTTP content in Resin is ultimately handled by a servlet. IfResin can't find a servlet for a URL, it will returna <code>404 Not Found</code> to the browser. So, if you see anunexpected <code>404 Not Found</code>, you not only need to check thatthe file exists, but make sure that the servlet and its URL mapping isproperly configured. If you turn on logging to "finer", you cantrace the request to figure out why the servlet is not gettingcalled.</p><p>To match up the URL to its final servlet and the content, you needall of the following properly configured:</p><ol><li><b>Server</b>. The Resin server must be active to do anything.Because servers belong to a cluster, you'll automatically have acluster even if it only has a single server.</li><li><b>HTTP port</b>. The server must be listening to the internetfor HTTP requests just to get started. If the HTTP port is missing ormisconfigured, you will get connection failure messages because thebrowser cannot connect to your server at all.</li><li><b>Host</b>. Resin must first match the<a href="host-tags.xtp"><host></a> specified by theHTTP request, e.g. www.slytherin.com. If no hosts match, Resin willuse the default host. If no default host exists, Resin willreturn a <code>404 Not Found</code> to the browser.</li><li><b>WebApp</b>. Inside the host, Resin finds aweb-application to handle the request by looking for the<a href="webapp-tags.xtp#webapp"><web-app></a> with the longest URLprefix. So, <code>http://www.slytherin.com/drupal/index.php</code>might match the <code>/drupal/</code>. The ROOT web-app matches allURLs. If Resin can't find a web-app, it will return<code>404 Not Found</code> to the browser.</li><li><b>servlet-mapping</b>. Inside the web-app, Resin searches for a<a href="webapp-tags.xtp#servlet-mapping"><servlet-mapping></a> matchingthe URL. For example, <code>test.php</code> would match the<code>QuercusServlet</code> and <code>test.jsp</code> would matchthe JSP servlet. If none match, Resin will try the default mapping,which is normally the <code>FileServlet</code> to handle static pages.If the default servlet isn't configured, Resin will return a <code>404Not Found</code> to the browser.</li><li><b>Servlet</b>. Finally, the selected servlet processes therequest and returns the content. The servlet itself might not findthe requested content, e.g. if <code>/foo.php</code> does not exist inthe expected location. The servlet itself is responsible for errorhandling, but most servlets will return a <code>404 Not Found</code>if any expected files are missing.</li></ol><p>Based on Resin's dispatching flow, here's a minimalresin.xml to serve some content out of <code>/var/www/htdocs</code>.Resin's philosophy of configuration files is that 1) for maintainability,all configuration should be traceable to the resin.xml, i.e. no magicdefaults or hidden state are allowed and 2) for security, if somethingis not configured, it doesn't exist. In Resin, you need to enablethings explicitly, not disable hidden defaults. The slight extraverbosity is outweighed by the improved security andmaintainability.</p><p>The following resin.xml specifies an Apache-style structure whereall content is served from the <code>/var/www/htdocs</code> directory,and is useful when upgrading from an old PHP site to use Quercusfor security and performance. When organizing a site from scratch,you'll typically use a more structured dynamichosting directory structure.</p><example title="Example: minimal /etc/resin/resin.xml for HTTP"><resin xmlns="http://caucho.com/ns/resin" xmlns:resin="http://caucho.com/ns/resin/core"> <cluster id="app-tier"> <development-mode-error-page/> <server id="" address="127.0.0.1" port="6800"> <http port="8080"/> </server> <resin:import path="/etc/resin/app-default.xml"/> <host id=""> <web-app id=""> <root-directory>/var/www/htdocs</root-directory> </web-app> </host> </cluster></resin></example><ul><li><a href="resin-tags.xtp#resin"><resin></a> starts a Resinconfiguration file and declares the validation namespaces.</li><li><a href="cluster-tags.xtp#cluster"><cluster></a> encloses thesingle-server cluster containing our content.</li><li><ahref="cluster-tags.xtp#development-mode-error-page"><development-mode-error-page></a>reports configuration and runtime errors to the browser, which isvery helpful during development. On a production server, you maywant to remove this tag so errors don't expose information to theinternet.</li><li><a href="server-tags.xtp#server"><server></a> configures theResin server, including its ports. The <var>id</var> matches thecommand-line <var>-server</var> argument at startup. The<var>address</var> and <var>port</var> open Resin's cluster port,which is used for deployment, management, clustering, anddistributed caching.</li><li><a href="server-tags.xtp#http"><http></a> listens for HTTPrequests. Production servers will change the port to 80.</li><li><a href="env-tags.xtp#import"><resin:import></a> defines thestandard servlet like JSP, PHP and the static file servlet. If youomit this <resin:import>, Resin will return <code>404 NotFound</code> because the <ahref="webapp-tags.xtp#servlet-mapping"><servlet-mapping></a> andservlets would not be defined.</li><li><a href="host-tags.xtp#host"><host></a> defines a defaultvirtual host. The default host will handle any host domain given bya HTTP request.</li><li><a href="webapp-tags.xtp#web-app"><web-app></a> defines a ROOTweb-app, serving all URLs for the host. The servlets in the web-appare defined by the <code>app-default.xml</code> specified by the <resin:import>.</li><li><a href="webapp-tags.xtp#root-directory"><root-directory></a>specifies the content directory, here matching a standard Apachedirectory.</li></ul><s2 title="rewrite-dispatch replaces mod_rewrite"><p>For many applications like Drupal and Mediawiki, it's important torewrite a user-friendly URL to an internal servlet or PHP URL.Resin's <a href="rewrite-tags.xtp"><rewrite-dispatch></a> replacesthe capabilities of mod_rewrite for Apache.</p><example title="Example: WEB-INF/resin-web.xml Drupal rewriting "><web-app xmlns="http://caucho.com/ns/resin"> <rewrite-dispatch> <dispatch regexp="\.(php|gif|css|jpg|png|ico|js|htm|html)"/> <forward regexp="^/" target="/index.php?q="/> </rewrite-dispatch></web-app></example><ul><li><a href="webapp-tags.xtp#web-app"><web-app></a> configures the<code>/drupal</code> web-application.</li><li><ahref="rewrite-tags.xtp#rewrite-dispatch"><rewrite-dispatch></a>starts the URL rewriting configuration.</li><li><ahref="rewrite-tags.xtp#dispatch"><dispatch></a>passes the URL untouched for content handling, e.g. static files or php.</li><li><ahref="rewrite-tags.xtp#forward"><forward></a>rewrites the URL and forwards.</li></ul></s2></s1><s1 title="Resin Processes"><ul><li><b>command-line</b> - the command-line process(<code>ResinBoot</code>) only exists longenough to send a message to the <em>watchdog</em> or the Resinprocess, like a "start", "deploy", or "stop". If necessary, thecommand-line process will start the watchdog.</li><li><b>watchdog</b> - the <a href="resin-watchdog.xtp">watchdogprocess</a> manages and monitors <em>Resin server</em> processes.If the Resin server exits, the watchdog will automatically restartResin, providing extra reliability in case of server failure.</li><li><b>Resin server</b> - the Resin server handles the HTTP requestsand serves the content.</li></ul><figure src="startup-watchdog.png"/><p>Because the Resin server is started as a child of the watchdogprocess, its own JVM arguments come from the resin.xml,not from the command-line of <code>ResinBoot</code>. The JVMconfiguration arguments are supplied as <ahref="server-tags#jvm-arg"><jvm-arg></a> in the <server>configuration.</p></s1><s1 title="Files and Directories"><p>Resin's configuration allows for great flexibility in choosing adirectory structure for your site, or adapting Resin to your existingsite configuration if you're upgrading from Apache/PHP for a Drupal orMediaWiki site. There are three main directory styles:</p><ul><li><b>Resin dynamic virtual host</b> - the most general solution,letting you easily add virtual hosts without modifying theconfiguration files.</li><li><b>Apache upgrade</b> - all content is placed ina <code>/var/www/htdocs</code> directory.</li><li><b>Servlet war style</b> - all content is deployed with .war filesin a webapps directory. The .war file is automatically expanded anddeployed from the webapps.</li></ul><s2 title="Dynamic Virtual Host"><p>In the dynamic virtual host configuration, your content is placedin <code>/var/www/hosts/foo.com/webapps/ROOT</code>.<code>/var/www</code> is the standard location for HTTP documents.<code>hosts/foo.com</code> contains your virtual host root directory.<code>webapps/ROOT</code> contains the root web-app for the virtualhost.</p><p>Adding a new virtual host is easy just by adding a new<code>hosts/bar.com</code> directory. The special directory<code>hosts/default</code> creates a default virtual host, which willserve pages for anything not matching a specific host. If you
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -