Sophie

Sophie

distrib > Mageia > 7 > x86_64 > by-pkgid > ad68a08043dd538f790a10507bc4a38d > files > 1223

cherokee-1.2.103-17.1.mga7.x86_64.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
                "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
    <meta http-equiv="Content-Language" content="en-us" />
    <meta name="ROBOTS" content="ALL" />
    <meta http-equiv="imagetoolbar" content="no" />
    <meta name="MSSmartTagsPreventParsing" content="true" />
    <meta name="Keywords" content="cherokee web server httpd http" />
    <meta name="Description" content="Cherokee is a flexible, very fast, lightweight Web server. It is implemented entirely in C, and has no dependencies beyond a standard C library. It is embeddable and extensible with plug-ins. It supports on-the-fly configuration by reading files or strings, TLS/SSL (via GNUTLS or OpenSSL), virtual hosts, authentication, cache friendly features, PHP, custom error management, and much more." />
    <link href="media/css/cherokee_doc.css" rel="stylesheet" type="text/css" media="all" />
  </head>
<body>
<h2 id="_a_href_index_html_index_a_8594_a_href_cookbook_html_cookbook_a"><a href="index.html">Index</a> &#8594; <a href="cookbook.html">Cookbook</a></h2>
<div class="sectionbody">
</div>
<h2 id="_cookbook_setting_up_drupal">Cookbook: Setting up Drupal</h2>
<div class="sectionbody">
<div class="paragraph"><p>Setting up <a href="http://drupal.org/">Drupal</a> with Cherokee is really
easy. This recipe describes the Drupal 6.x installation, which is the
latest release at the time of writing.</p></div>
<div class="paragraph"><p>Of course you can always access Drupal and have it automatically
downloaded and deployed through the <tt>Market</tt> section, but should you
decide to install it manually here are the steps to follow.</p></div>
<div class="paragraph"><p>You will need PHP support correctly configured in Cherokee, and PHP
with the MySQL module installed. The default configuration already
provides a valid PHP configuration for Cherokee if you have php-cgi
installed, but you can follow the appropriate recipe about
<a href="cookbook_php.html">setting up PHP</a> in case you don&#8217;t have it
available for some reason.</p></div>
<div class="paragraph"><p>Provided the above conditions are met, you could start Drupal&#8217;s
installation and you would already be able to have your site up and
running.</p></div>
<div class="paragraph"><p>However, we can add several refinements to Cherokee&#8217;s
settings. Mainly:</p></div>
<div class="olist arabic"><ol class="arabic">
<li>
<p>
Forward all requests for www.example.net (or whatever domain is
  resolved to our machine) to example.net
</p>
</li>
<li>
<p>
Set up an appropriate url rewriting configuration for Drupal.
</p>
</li>
<li>
<p>
Serve directly the static content to avoid the dynamic-processing
  bottle-neck.
</p>
</li>
<li>
<p>
Use the regex from Drupal&#8217;s .htaccess for denying access to certain
  paths.
</p>
</li>
</ol></div>
<div class="paragraph"><p>With this we should be able to do everything Drupal&#8217;s supposed to do,
and it should work with Imagecache&#8217;s dynamic thumbnail generation.</p></div>
<div class="paragraph"><p>There are two ways of installing Drupal: it can either be installed as
a new virtual server or be installed inside a directory of some of the
virtual servers that already exist. We&#8217;ll begin by covering the first
scenario, and will then make a trivial adaptation to cover the second
case.</p></div>
<h3 id="cherokee">Setting up Cherokee on a new virtual server</h3><div style="clear:left"></div>
<h4 id="_default_virtual_server">Default virtual server</h4>
<div class="paragraph"><p>We&#8217;ll begin by cloning the default virtual server, just to keep the
default PHP configuration. Create a clone named <tt>example.net</tt>.</p></div>
<div class="paragraph"><p>Then, we&#8217;ll delete every erasable rule in the default virtual server
since we are going to use it to redirect every petition not matched by
the example.net virtual server. We will set the remaining one to be
managed by the <tt>Redirection</tt> handler, like this:</p></div>
<div class="tableblock">
<table rules="all"
width="100%"
frame="border"
cellspacing="0" cellpadding="4">
<col width="33%" />
<col width="33%" />
<col width="33%" />
<thead>
<tr>
<th align="left" valign="top">Type     </th>
<th align="left" valign="top">Regular Expression </th>
<th align="left" valign="top">Redirection</th>
</tr>
</thead>
<tbody>
<tr>
<td align="left" valign="top"><p class="table">External</p></td>
<td align="left" valign="top"><p class="table">(.*)$</p></td>
<td align="left" valign="top"><p class="table"><a href="http://example.net/$1">http://example.net/$1</a></p></td>
</tr>
</tbody>
</table>
</div>
<div class="paragraph"><p>This clears the first milestone. The remaining three will be
accomplished by tweaking the <tt>example.net</tt> virtual server.</p></div>
<h4 id="_example_net">example.net</h4>
<h5 id="_first_step">First step</h5>
<div class="paragraph"><p>Remember to set up the <tt>Document root</tt> to <tt>/var/www/drupal</tt>.</p></div>
<div class="paragraph"><p>Delete all the rules except <tt>php</tt> and <tt>Default</tt>.</p></div>
<div class="paragraph"><p>As previously, we will manage the <tt>Default</tt> rule with the redirection
handler.</p></div>
<div class="tableblock">
<table rules="all"
width="100%"
frame="border"
cellspacing="0" cellpadding="4">
<col width="33%" />
<col width="33%" />
<col width="33%" />
<thead>
<tr>
<th align="left" valign="top">Type     </th>
<th align="left" valign="top">Regular Expression </th>
<th align="left" valign="top">Redirection</th>
</tr>
</thead>
<tbody>
<tr>
<td align="left" valign="top"><p class="table">Internal</p></td>
<td align="left" valign="top"><p class="table">^/(.*)$</p></td>
<td align="left" valign="top"><p class="table">/index.php?q=$1</p></td>
</tr>
</tbody>
</table>
</div>
<h5 id="_second_step">Second step</h5>
<div class="paragraph"><p>Remember to set up Drupal as custom error handler for the virtual
server. Do so in the <tt>Error Handler</tt> tab, selecting the <tt>Custom
redirections</tt> option and sending 404 errors to Drupal.</p></div>
<div class="tableblock">
<table rules="all"
width="100%"
frame="border"
cellspacing="0" cellpadding="4">
<col width="50%" />
<col width="50%" />
<thead>
<tr>
<th align="left" valign="top">Error         </th>
<th align="left" valign="top">URL</th>
</tr>
</thead>
<tbody>
<tr>
<td align="left" valign="top"><p class="table">404 Not Found</p></td>
<td align="left" valign="top"><p class="table">/index.php</p></td>
</tr>
</tbody>
</table>
</div>
<h5 id="_third_step">Third step</h5>
<div class="paragraph"><p>Next, we need to address the clean URLs matter. To do so, create
another redirection rule.</p></div>
<div class="tableblock">
<table rules="all"
width="100%"
frame="border"
cellspacing="0" cellpadding="4">
<col width="33%" />
<col width="33%" />
<col width="33%" />
<thead>
<tr>
<th align="left" valign="top">Type     </th>
<th align="left" valign="top">Regular Expression </th>
<th align="left" valign="top">Redirection</th>
</tr>
</thead>
<tbody>
<tr>
<td align="left" valign="top"><p class="table">Internal</p></td>
<td align="left" valign="top"><p class="table">^/(.*)\?(.\*)$</p></td>
<td align="left" valign="top"><p class="table">/index.php?q=$1&amp;$2</p></td>
</tr>
</tbody>
</table>
</div>
<h5 id="_fourth_step">Fourth step</h5>
<div class="paragraph"><p>After this we will go straight to another milestone: directly serving
static files, which is an easy task to accomplish.  Just set up a
<tt>File Exists</tt>-type rule. Check the <tt>Match any</tt> checkbox, and manage it
with the <tt>Static file</tt> handler. Remember to activate the <tt>IO Cache</tt>
option and to specify whatever expiration period you see fit for these
files. If you ever edit the configuration just remember that this rule
should be located after the PHP rule. Otherwise you will end up
statically serving them instead of processing them via PHP. In fact it
is a good idea to keep your rules for dynamic contents in a high
position on your list of rules.</p></div>
<h5 id="_fifth_step">Fifth step</h5>
<div class="paragraph"><p>Now to block bad paths, as specified by the htaccess file provided
with Drupal. For this we will use an internal <tt>Regular
expression</tt>-type rule matching the following expression:</p></div>
<div class="listingblock">
<div class="content">
<pre><tt>\.(engine|inc|info|install|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl|svn-base)$|^(code-style\.pl|Entries.*|Repository|Root|Tag|Template|all-wcprops|entries|format)$</tt></pre>
</div></div>
<div class="paragraph"><p>Handle this with the <tt>HTTP error</tt> handler:</p></div>
<div class="tableblock">
<table rules="all"
width="100%"
frame="border"
cellspacing="0" cellpadding="4">
<col width="100%" />
<thead>
<tr>
<th align="left" valign="top">Error</th>
</tr>
</thead>
<tbody>
<tr>
<td align="left" valign="top"><p class="table">403 Forbidden</p></td>
</tr>
</tbody>
</table>
</div>
<h5 id="_sixth_step">Sixth step</h5>
<div class="paragraph"><p>The last thing to do on Cherokee&#8217;s side is to specify a sixth rule
that fixes an issue with how requests for the root are managed having
the <tt>File exists</tt> handler in place. Simply define yet another
redirection rule for this regular expression:</p></div>
<div class="tableblock">
<table rules="all"
width="100%"
frame="border"
cellspacing="0" cellpadding="4">
<col width="33%" />
<col width="33%" />
<col width="33%" />
<thead>
<tr>
<th align="left" valign="top">Type     </th>
<th align="left" valign="top">Regular Expression </th>
<th align="left" valign="top">Redirection</th>
</tr>
</thead>
<tbody>
<tr>
<td align="left" valign="top"><p class="table">Internal</p></td>
<td align="left" valign="top"><p class="table">^/$</p></td>
<td align="left" valign="top"><p class="table">/index.php</p></td>
</tr>
</tbody>
</table>
</div>
<div class="paragraph"><p>All done. After this you should have six rules in your list. This
configuration does work. Reorder your rules accordingly if you seem to
have any trouble.</p></div>
<div class="imageblock">
<div class="content">
<img src="media/images/cookbook_drupal_vserver_rules.png" alt="media/images/cookbook_drupal_vserver_rules.png" />
</div>
<div class="image-title">List of rules</div>
</div>
<div class="paragraph"><p>Now, to install Drupal!</p></div>
<h3 id="cherokee">Setting up Cherokee on an existing virtual server</h3><div style="clear:left"></div>
<div class="paragraph"><p>You will also have to define a set of 6 rules, although in this case
it will be a bit different.</p></div>
<div class="paragraph"><p>We will be using the default virtual server, a web directory <tt>/blog</tt>
and we will assume we are going to install Drupal under
<tt>/var/www/drupal</tt> on our directory tree.</p></div>
<h4 id="_first_step_2">First step</h4>
<div class="paragraph"><p>Regular Expression internal redirection.</p></div>
<div class="imageblock">
<div class="content">
<img src="media/images/cookbook_drupal_dir_rules_1.png" alt="media/images/cookbook_drupal_dir_rules_1.png" />
</div>
<div class="image-title">Redirection handler</div>
</div>
<div class="tableblock">
<table rules="all"
width="100%"
frame="border"
cellspacing="0" cellpadding="4">
<caption class="title">Redirection handler</caption>
<col width="33%" />
<col width="33%" />
<col width="33%" />
<thead>
<tr>
<th align="left" valign="top">Type     </th>
<th align="left" valign="top">Regular Expression </th>
<th align="left" valign="top">Redirection</th>
</tr>
</thead>
<tbody>
<tr>
<td align="left" valign="top"><p class="table">Internal</p></td>
<td align="left" valign="top"><p class="table">^/blog/([0-9]+)$</p></td>
<td align="left" valign="top"><p class="table">/blog/index.php?q=/node/$1</p></td>
</tr>
</tbody>
</table>
</div>
<h4 id="_second_step_2">Second step</h4>
<div class="paragraph"><p>Regular Expression internal redirection.</p></div>
<div class="imageblock">
<div class="content">
<img src="media/images/cookbook_drupal_dir_rules_2.png" alt="media/images/cookbook_drupal_dir_rules_2.png" />
</div>
<div class="image-title">Redirection handler</div>
</div>
<div class="tableblock">
<table rules="all"
width="100%"
frame="border"
cellspacing="0" cellpadding="4">
<caption class="title">Redirection handler</caption>
<col width="33%" />
<col width="33%" />
<col width="33%" />
<thead>
<tr>
<th align="left" valign="top">Type     </th>
<th align="left" valign="top">Regular Expression </th>
<th align="left" valign="top">Redirection</th>
</tr>
</thead>
<tbody>
<tr>
<td align="left" valign="top"><p class="table">Internal</p></td>
<td align="left" valign="top"><p class="table">/blog/index.php</p></td>
<td align="left" valign="top"><p class="table">^/blog/$</p></td>
</tr>
</tbody>
</table>
</div>
<h4 id="_third_step_2">Third step</h4>
<div class="paragraph"><p><tt>/blog</tt> directory rule with custom document root set to <tt>/var/www/drupal</tt></p></div>
<div class="imageblock">
<div class="content">
<img src="media/images/cookbook_drupal_dir_rules_3.png" alt="media/images/cookbook_drupal_dir_rules_3.png" />
</div>
<div class="image-title">Custom document root</div>
</div>
<h4 id="_fourth_step_2">Fourth step</h4>
<div class="paragraph"><p>Now to block bad paths, as specified by the htaccess file provided
with Drupal. For this we will use an internal <tt>Regular
expression</tt>-type rule matching the following expression:</p></div>
<div class="listingblock">
<div class="content">
<pre><tt>\.(engine|inc|info|install|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl|svn-base)$|^(code-style\.pl|Entries.*|Repository|Root|Tag|Template|all-wcprops|entries|format)$</tt></pre>
</div></div>
<div class="paragraph"><p>Handle this with the <tt>HTTP error</tt> handler:</p></div>
<div class="tableblock">
<table rules="all"
width="100%"
frame="border"
cellspacing="0" cellpadding="4">
<caption class="title">HTTP error</caption>
<col width="100%" />
<thead>
<tr>
<th align="left" valign="top">Error</th>
</tr>
</thead>
<tbody>
<tr>
<td align="left" valign="top"><p class="table">403 Forbidden</p></td>
</tr>
</tbody>
</table>
</div>
<div class="imageblock">
<div class="content">
<img src="media/images/cookbook_drupal_dir_rules_4.png" alt="media/images/cookbook_drupal_dir_rules_4.png" />
</div>
<div class="image-title">HTTP error</div>
</div>
<h4 id="_fifth_step_2">Fifth step</h4>
<div class="paragraph"><p>Send static files as such. For this you will define a complex rule
using both a <tt>Directory</tt> (set to <tt>/blog</tt>), and a <tt>File Exist</tt> types.</p></div>
<div class="paragraph"><p>Remember to enable caching, as in the screenshot.</p></div>
<div class="imageblock">
<div class="content">
<img src="media/images/cookbook_drupal_dir_rules_6.png" alt="media/images/cookbook_drupal_dir_rules_6.png" />
</div>
<div class="image-title">Rule for static files</div>
</div>
<div class="tableblock">
<table rules="all"
width="100%"
frame="border"
cellspacing="0" cellpadding="4">
<caption class="title">First sub-rule</caption>
<col width="50%" />
<col width="50%" />
<thead>
<tr>
<th align="left" valign="top">Field        </th>
<th align="left" valign="top"> Value</th>
</tr>
</thead>
<tbody>
<tr>
<td align="left" valign="top"><p class="table">Rule type</p></td>
<td align="left" valign="top"><p class="table">Directory</p></td>
</tr>
<tr>
<td align="left" valign="top"><p class="table">Web directory</p></td>
<td align="left" valign="top"><p class="table">/blog</p></td>
</tr>
</tbody>
</table>
</div>
<div class="paragraph"><p><strong>AND</strong></p></div>
<div class="tableblock">
<table rules="all"
width="100%"
frame="border"
cellspacing="0" cellpadding="4">
<caption class="title">Second sub-rule</caption>
<col width="50%" />
<col width="50%" />
<thead>
<tr>
<th align="left" valign="top">Rule type                 </th>
<th align="left" valign="top"> File Exists</th>
</tr>
</thead>
<tbody>
<tr>
<td align="left" valign="top"><p class="table">Match any file</p></td>
<td align="left" valign="top"><p class="table">Enabled</p></td>
</tr>
<tr>
<td align="left" valign="top"><p class="table">Use I/O cache</p></td>
<td align="left" valign="top"><p class="table">Enabled</p></td>
</tr>
<tr>
<td align="left" valign="top"><p class="table">Only match files</p></td>
<td align="left" valign="top"><p class="table">Enabled</p></td>
</tr>
<tr>
<td align="left" valign="top"><p class="table">If dir, check index files</p></td>
<td align="left" valign="top"><p class="table">Disabled</p></td>
</tr>
</tbody>
</table>
</div>
<h4 id="_sixth_step_2">Sixth step</h4>
<div class="paragraph"><p>The last rule related to Drupal&#8217;s configuration should be a catch-all
internal redirection for a couple of regular expressions.</p></div>
<div class="imageblock">
<div class="content">
<img src="media/images/cookbook_drupal_dir_rules_7.png" alt="media/images/cookbook_drupal_dir_rules_7.png" />
</div>
<div class="image-title">Redirection handler</div>
</div>
<div class="tableblock">
<table rules="all"
width="100%"
frame="border"
cellspacing="0" cellpadding="4">
<caption class="title">Redirection handler</caption>
<col width="33%" />
<col width="33%" />
<col width="33%" />
<thead>
<tr>
<th align="left" valign="top">Type     </th>
<th align="left" valign="top">Regular Expression </th>
<th align="left" valign="top">Redirection</th>
</tr>
</thead>
<tbody>
<tr>
<td align="left" valign="top"><p class="table">Internal</p></td>
<td align="left" valign="top"><p class="table">^/(.*)\?(.\*)$</p></td>
<td align="left" valign="top"><p class="table">/blog/index.php?q=$1&amp;$2</p></td>
</tr>
<tr>
<td align="left" valign="top"><p class="table">Internal</p></td>
<td align="left" valign="top"><p class="table">^/(.*)$</p></td>
<td align="left" valign="top"><p class="table">/blog/index.php?q=$1</p></td>
</tr>
</tbody>
</table>
</div>
<div class="paragraph"><p>At the end of the process you should end up with a list of 8
rules. Rearrange from top to bottom according to the order given in
the steps if you seem something is wrong with your setup.</p></div>
<div class="imageblock">
<div class="content">
<img src="media/images/cookbook_drupal_dir_rules.png" alt="media/images/cookbook_drupal_dir_rules.png" />
</div>
<div class="image-title">Rule list</div>
</div>
<div class="paragraph"><p>The last one and any subsequent rules will belong to the previously
defined virtual server.</p></div>
<div class="paragraph"><p>As before, once you are done configuring Cherokee you can proceed to
set up Drupal.</p></div>
<h3 id="drupal">Setting up Drupal</h3><div style="clear:left"></div>
<div class="paragraph"><p>First download and uncompress the distributed Drupal release into
<tt>/var/www/drupal</tt>, and create a database suitable for the installation.</p></div>
<div class="paragraph"><p>Log in to MySQL:</p></div>
<div class="listingblock">
<div class="content">
<pre><tt>mysql -u root -p</tt></pre>
</div></div>
<div class="paragraph"><p>And create the database for Drupal. We will be using the name
<em>drupal</em>, the user <em>drupaluser</em> and the password <em>drupalpassword</em>, but
you should set up your own.</p></div>
<div class="listingblock">
<div class="content">
<pre><tt>CREATE DATABASE drupal;
GRANT ALL PRIVILEGES ON drupal.* TO drupaluser@localhost IDENTIFIED BY 'drupalpassword';
GRANT ALL PRIVILEGES ON drupal.* TO drupaluser@localhost.localdomain IDENTIFIED BY 'drupalpassword';
FLUSH PRIVILEGES;
quit;</tt></pre>
</div></div>
<div class="paragraph"><p>Then point your web browser to <tt>http://localhost</tt> and follow the
instructions provided by the installer.</p></div>
<div class="paragraph"><p>You will need to copy the config file and change the permissions manually to proceed:</p></div>
<div class="listingblock">
<div class="content">
<pre><tt>cd /var/www/drupal/sites/default
cp default.settings.php settings.php
chmod 644 settings.php</tt></pre>
</div></div>
<div class="paragraph"><p>And the installation will be almost automatic. Just fill up the
requested values and you will obtain the following results once your
are through.</p></div>
<div class="imageblock">
<div class="content">
<img src="media/images/cookbook_drupal.png" alt="media/images/cookbook_drupal.png" />
</div>
<div class="image-title">Drupal in action</div>
</div>
<div class="admonitionblock">
<table><tr>
<td class="icon">
<div class="title">Note</div>
</td>
<td class="content">As of Drupal 6.14, a problem has been reported related to gzip
compression of multilingual contents. You are advised to disable gzip
compression for the rule that manages PHP in your Drupal <tt>Virtual
Server</tt>. If you are not using a multilingual Drupal or find another
workaround for the issue, you will probably want to enable gzip
encoding on the PHP rule to increase performance.</td>
</tr></table>
</div>
</div>
<div id="footer">
<div id="footer-text">
</div>
</div>
</body>
</html>