website annotate pt/doc/handbook/web-server.html @ rev 142

pt: Add newly translated pages (Many thanks Cladinei)
author Paul Issott <paul@slitaz.org>
date Mon Aug 25 22:36:03 2008 +0000 (2008-08-25)
parents
children e21dcdd56671
rev   line source
paul@142 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
paul@142 2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
paul@142 3 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
paul@142 4 <head>
paul@142 5 <title>SliTaz Handbook (en) - LightTPD web server</title>
paul@142 6 <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
paul@142 7 <meta name="description" content="slitaz English handbook" />
paul@142 8 <meta name="expires" content="never" />
paul@142 9 <meta name="modified" content="2008-07-18 07:00:00" />
paul@142 10 <meta name="publisher" content="www.slitaz.org" />
paul@142 11 <meta name="author" content="Christophe Lincoln" />
paul@142 12 <link rel="shortcut icon" href="favicon.ico" />
paul@142 13 <link rel="stylesheet" type="text/css" href="book.css" />
paul@142 14 </head>
paul@142 15 <body bgcolor="#ffffff">
paul@142 16
paul@142 17 <!-- Header and quick navigation -->
paul@142 18 <div id="header">
paul@142 19 <div id="quicknav" align="right">
paul@142 20 <a name="top"></a>
paul@142 21 <a href="chroot-env.html">Chroot Environment</a> |
paul@142 22 <a href="index.html">Table of contents</a>
paul@142 23 </div>
paul@142 24 <h1><font color="#3e1220">SliTaz Handbook (en)</font></h1>
paul@142 25 </div>
paul@142 26
paul@142 27 <!-- Content. -->
paul@142 28 <div id="content">
paul@142 29 <div class="content-right"></div>
paul@142 30
paul@142 31 <h2><font color="#df8f06">LightTPD Web Server</font></h2>
paul@142 32
paul@142 33 <ul>
paul@142 34 <li><a href="#about">About LightTPD.</a></li>
paul@142 35 <li><a href="#var-www">/var/www</a> - Root directory of documents.</li>
paul@142 36 <li><a href="#Public">~/Public</a> - Public directory of users.</li>
paul@142 37 <li><a href="#config">lighttpd.conf</a> - LightTPD Configuration File.</li>
paul@142 38 <li><a href="#start-stop-restart">Start, stop, restart the server.</a></li>
paul@142 39 <li><a href="#cgi-perl">Scripts CGI and Perl</a> - CGI scripts using Perl.</li>
paul@142 40 <li><a href="#cgi-python">Scripts CGI and Python</a> - CGI scripts using Python.</li>
paul@142 41 <li><a href="#auth">Authentication</a> - Protect directories using username and password.</li>
paul@142 42 </ul>
paul@142 43
paul@142 44 <a name="about"></a>
paul@142 45 <h3>About LightTPD</h3>
paul@142 46 <p>
paul@142 47 This chapter describes the configuration and use of the LightTPD web server. It's a fast, secure, flexible HTTP
paul@142 48 server, using a small memory footprint. It enables intelligent management of the cpu load and offers
paul@142 49 FastCGI support, CGI, Auth, Output compression and the rewriting of URLs etc. LightTPD is a cheap way to host your
paul@142 50 own site on an old machine.
paul@142 51 </p>
paul@142 52 <p>
paul@142 53 On SliTaz the server is automatically launched at system startup and is preconfigured with PHP. The root
paul@142 54 of the documents served by default are in <code>/var/www</code>, this contains the default page <code>index.html</code>,
paul@142 55 images are stored in the <code>images/</code> directory.
paul@142 56 LightTPD website: <a href="http://www.lighttpd.net/">http://www.lighttpd.net/</a>
paul@142 57 </p>
paul@142 58 <a name="var-www"></a>
paul@142 59 <h3>/var/www - Root directory of documents</h3>
paul@142 60 <p>
paul@142 61 The /var/www folder is the <em>root</em> directory of documents - you can access this via the URL
paul@142 62 <a href="http://localhost/">http://localhost/</a>. If you want to host a site, you can save all your documents
paul@142 63 in here. If you want to host multiple sites, you'll need to create virtual hosts. Note you can also check the
paul@142 64 <a href="http://localhost/server-status">http://localhost/server-status</a>.
paul@142 65
paul@142 66 </p>
paul@142 67 <a name="Public"></a>
paul@142 68 <h3>~/Public - Public directory of users</h3>
paul@142 69 <p>
paul@142 70 SliTaz provides the users of the system a public space to place documents, HTML in general.
paul@142 71 This directory is named Public and must be within the root of your user space, such as /home/hacker/Public.
paul@142 72 To create this directory use the mkdir command:
paul@142 73 </p>
paul@142 74 <pre> $ mkdir ~/Public
paul@142 75 </pre>
paul@142 76 <p>
paul@142 77 You can then have access via the URL:
paul@142 78 <a href="http://localhost/%7Ehacker/">http://localhost/~hacker/</a>. You can also use the machine name or IP
paul@142 79 address if you connect from another computer.
paul@142 80 </p>
paul@142 81 <a name="config"></a>
paul@142 82 <h3>/etc/lighttpd/lighttpd.conf - LightTPD configuration file</h3>
paul@142 83 <p>
paul@142 84 The main configuration file for LightTPD (<code>lighttpd.conf</code>) is located in /etc/lighttpd/. This file provided by
paul@142 85 SliTaz is self-explanatory, just browse. You can find other examples on the LightTPD website. On
paul@142 86 SliTaz you'll also find a <code>vhosts.conf</code> file for the configuration of any virtual hosts (hosting
paul@142 87 several sites on the same server).
paul@142 88 </p>
paul@142 89 <a name="start-stop-restart"></a>
paul@142 90 <h3>Start, stop, restart the web server</h3>
paul@142 91 <p>
paul@142 92 By default, SliTaz starts the server automatically at boot, to prevent this you need to remove
paul@142 93 <code>lighttpd</code> from the variable RUN_DAEMONS located in the system file
paul@142 94 <code>/etc/rcS.conf</code>. To start, stop or restart the server, you can use the commands:
paul@142 95 <code>/etc/init.d/lighttpd [start|stop|restart]</code>. Example to restart the server after
paul@142 96 changing the configuration file:
paul@142 97 </p>
paul@142 98 <pre> # /etc/init.d/lighttpd restart
paul@142 99 </pre>
paul@142 100
paul@142 101 <a name="cgi-perl"></a>
paul@142 102 <h3>CGI scripts using Perl</h3>
paul@142 103 <p>
paul@142 104 To configure the LightTPD server to locate the path of the <code>perl</code> binary and use CGI/Perl, you'll need to
paul@142 105 install perl and modify the server configuration file. Example using Geany:
paul@142 106 </p>
paul@142 107 <pre> # tazpkg get-install perl
paul@142 108 # geany /etc/lighttpd/lighttpd.conf &amp;
paul@142 109 </pre>
paul@142 110 <pre class="script"># CGI module. You can install Perl and assign .pl and .cgi scripts
paul@142 111 # to /usr/bin/perl
paul@142 112 $HTTP["url"] =~ "/cgi-bin/" {
paul@142 113 cgi.assign = (
paul@142 114 ".sh" =&gt; "/bin/sh",
paul@142 115 ".cgi" =&gt; "/usr/bin/perl,
paul@142 116 ".pl" =&gt; "/usr/bin/perl
paul@142 117 )
paul@142 118 }
paul@142 119 </pre>
paul@142 120
paul@142 121 <a name="cgi-python"></a>
paul@142 122 <h3>CGI scripts using Python</h3>
paul@142 123 <p>
paul@142 124 To configure the LightTPD server to locate the path of the <code>python</code> binary and use CGI/Python, you'll need to
paul@142 125 to install python and modify the server configuration file. Example using Geany:
paul@142 126 </p>
paul@142 127 <pre> # tazpkg get-install python
paul@142 128 # geany /etc/lighttpd/lighttpd.conf &amp;
paul@142 129 </pre>
paul@142 130 <pre class="script"># CGI module. You can install Python and assign .py and .cgi scripts
paul@142 131 # to /usr/bin/python
paul@142 132 $HTTP["url"] =~ "/cgi-bin/" {
paul@142 133 cgi.assign = (
paul@142 134 ".sh" =&gt; "/bin/sh",
paul@142 135 ".cgi" =&gt; "/usr/bin/python,
paul@142 136 ".py" =&gt; "/usr/bin/python
paul@142 137 )
paul@142 138 }
paul@142 139 </pre>
paul@142 140 <p>
paul@142 141 For the changes to be taken into effect and to use your first CGI scripts on SliTaz, just
paul@142 142 restart the LightTPD server:
paul@142 143 </p>
paul@142 144 <pre> # /etc/init.d/lighttpd restart
paul@142 145 </pre>
paul@142 146
paul@142 147 <a name="auth"></a>
paul@142 148 <h3>Authentication - Protection for the directories</h3>
paul@142 149 <p>
paul@142 150 LightTPD provides authentication modules that can for example, protect a directory. The server
paul@142 151 offers several authentication methods, but we will begin by using the basic method without encrypting any
paul@142 152 passwords. In order to be able to use the module <code>mod_auth</code>, you must install the lighttpd-modules
paul@142 153 package (<code>tazpkg get-install lighttpd-modules</code>), once installed <code>mod_auth</code>
paul@142 154 must be added to the list of modules:
paul@142 155 </p>
paul@142 156 <pre class="script"># Modules to load.
paul@142 157 # See /usr/lib/lighttpd for all available modules.
paul@142 158 #
paul@142 159 server.modules = (
paul@142 160 "mod_access",
paul@142 161 "mod_auth",
paul@142 162 "...",
paul@142 163 )
paul@142 164 </pre>
paul@142 165 <p>
paul@142 166 Now you can configure the modules by specifying the debug level and method (<code>plain</code>) and the
paul@142 167 path to the file containing a list of names using a protected password to access the directories. You must also
paul@142 168 define the directories that require authorization. In this example we'll protect the <code>admin/</code> directory
paul@142 169 and authorize it's access to user hacker (<code>user=hacker</code>):
paul@142 170 </p>
paul@142 171 <pre class="script"># Authentication for protected directory.
paul@142 172 auth.debug = 2
paul@142 173 auth.backend = "plain"
paul@142 174 auth.backend.plain.userfile = "/etc/lighttpd/plain.passwd"
paul@142 175 auth.require = ( "/admin/" =&gt;
paul@142 176 (
paul@142 177 "method" =&gt; "basic",
paul@142 178 "realm" =&gt; "Password protected area",
paul@142 179 "require" =&gt; "user=hacker"
paul@142 180 )
paul@142 181 )
paul@142 182 </pre>
paul@142 183 <p>
paul@142 184 Finally, we now create the file containing the passwords, add a user and restart the server for testing.
paul@142 185 The basic syntax for the file is <code>user:password</code>. You can create the file and add a user with the
paul@142 186 <code>echo</code> command or edit with your favorite text editor. To add <code>hacker:root</code>
paul@142 187 to the password file <code>/etc/lighttpd/plain.passwd</code>:
paul@142 188 </p>
paul@142 189 <pre> # echo "hacker:root" &gt; /etc/lighttpd/plain.passwd
paul@142 190 Or :
paul@142 191 # nano /etc/lighttpd/plain.passwd
paul@142 192 </pre>
paul@142 193 <p>
paul@142 194 To test the address: <strong>http://localhost/admin/</strong>, just restart the server:
paul@142 195 </p>
paul@142 196 <pre> # /etc/init.d/lighttpd restart
paul@142 197 </pre>
paul@142 198
paul@142 199 <!-- End of content -->
paul@142 200 </div>
paul@142 201
paul@142 202 <!-- Footer. -->
paul@142 203 <div id="footer">
paul@142 204 <div class="footer-right"></div>
paul@142 205 <a href="#top">Top of the page</a> |
paul@142 206 <a href="index.html">Table of contents</a>
paul@142 207 </div>
paul@142 208
paul@142 209 <div id="copy">
paul@142 210 Copyright © 2008 <a href="http://www.slitaz.org/en/">SliTaz</a> -
paul@142 211 <a href="http://www.gnu.org/licenses/gpl.html">GNU General Public License</a>;<br />
paul@142 212 Documentation is under
paul@142 213 <a href="http://www.gnu.org/copyleft/fdl.html">GNU Free Documentation License</a>
paul@142 214 and code is <a href="http://validator.w3.org/">valid xHTML 1.0</a>.
paul@142 215 </div>
paul@142 216
paul@142 217 </body>
paul@142 218 </html>
paul@142 219