/usr/share/doc/cherokee-doc/cookbook_drupal.html is in cherokee-doc 1.2.101-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 | <!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> → <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’t have it
available for some reason.</p></div>
<div class="paragraph"><p>Provided the above conditions are met, you could start Drupal’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’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’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’s supposed to do,
and it should work with Imagecache’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’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’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’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">^/(.<strong>)\?(.</strong>)$</p></td>
<td align="left" valign="top"><p class="table">/index.php?q=$1&$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’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’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">^/(.<strong>)\?(.</strong>)$</p></td>
<td align="left" valign="top"><p class="table">/blog/index.php?q=$1&$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>
|