website diff en/doc/handbook/web-server.html @ rev 39
Add LightTPD to Handbook (en) & typos
author | Paul Issott <paul@slitaz.org> |
---|---|
date | Wed May 04 21:16:27 2011 +0000 (2011-05-04) |
parents | |
children | 8c689138f7fd |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/en/doc/handbook/web-server.html Wed May 04 21:16:27 2011 +0000 1.3 @@ -0,0 +1,215 @@ 1.4 +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 1.5 +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head><title>SliTaz Handbook (en) - Template</title> 1.6 + 1.7 + 1.8 + 1.9 + <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" /> 1.10 + <meta name="description" content="slitaz English handbook" /> 1.11 + <meta name="expires" content="never" /> 1.12 + <meta name="modified" content="2008-02-26 18:30:00" /> 1.13 + <meta name="publisher" content="www.slitaz.org" /> 1.14 + <meta name="author" content="Christophe Lincoln" /> 1.15 + <link rel="shortcut icon" href="favicon.ico" /> 1.16 + <link rel="stylesheet" type="text/css" href="book.css" /></head><body bgcolor="#ffffff"> 1.17 + 1.18 +<!-- Header and quick navigation --> 1.19 +<div id="header"> 1.20 +<div id="quicknav" align="right"> 1.21 + <a name="top"></a> 1.22 + <a href="index.html">Table of contents</a> 1.23 +</div> 1.24 +<h1><font color="#3e1220">SliTaz Handbook (en)</font></h1> 1.25 +</div> 1.26 + 1.27 +<!-- Content. --> 1.28 +<div id="content"> 1.29 +<div class="content-right"></div> 1.30 + 1.31 +<h2><font color="#df8f06">LightTPD Web Server</font></h2> 1.32 + 1.33 +<ul> 1.34 + <li><a href="#about">About LightTPD.</a></li> 1.35 + <li><a href="#var-www">/var/www</a> - Root directory of documents.</li> 1.36 + <li><a href="#Public">~/Public</a> - Public directory of users.</li> 1.37 + <li><a href="#config">lighttpd.conf</a> - LightTPD Configuration File.</li> 1.38 + <li><a href="#start-stop-restart">Start, stop, restart the server.</a></li> 1.39 + <li><a href="#cgi-perl">Scripts CGI and Perl</a> - CGI scripts using Perl.</li> 1.40 + <li><a href="#cgi-python">Scripts CGI and Python</a> - CGI scripts using Python.</li> 1.41 + <li><a href="#auth">Authentication</a> - Protect directories using username and password.</li> 1.42 +</ul> 1.43 + 1.44 +<a name="about"></a> 1.45 +<h3>About LightTPD</h3> 1.46 +<p> 1.47 +This chapter describes the configuration and use of the LightTPD web server. It's a fast, secure, flexible HTTP 1.48 +server, using a small memory footprint. It enables intelligent management of the cpu load and offers 1.49 +FastCGI support, CGI, Auth, Output compression and the rewriting of URLs etc. LightTPD is a cheap way to host your 1.50 +own site on an old machine. 1.51 +</p> 1.52 +<p> 1.53 +On SliTaz the server is automatically launched at system startup and is preconfigured with PHP. The root 1.54 +of the documents served by the default server are in <code>/var/www</code> and contain a page <code>index.html</code>, 1.55 +displayed by default, images are stored in the <code>images/</code> directory. 1.56 +LightTPD website: <a href="http://www.lighttpd.net/">http://www.lighttpd.net/</a> 1.57 +</p> 1.58 +<a name="var-www"></a> 1.59 +<h3>/var/www - Root directory of documents</h3> 1.60 +<p> 1.61 +The directory /var/www is the root directory of documents by default. You can access this via the URL 1.62 +<a href="http://localhost/">http://localhost/</a>. If you want to host a site, you can save all your documents 1.63 +in here. If you want to host multiple sites, you'll need to create virtual hosts. Note you can also check the 1.64 +<a href="http://localhost/server-status">http://localhost/server-status</a>. 1.65 + 1.66 +</p> 1.67 +<a name="Public"></a> 1.68 +<h3>~/Public - Public directory of users</h3> 1.69 +<p> 1.70 +SliTaz offers the users of the system a public space to place documents, HTML in general. 1.71 +This directory is named Public and must be within the root of your user space, such as /home/hacker/Public. 1.72 +To create this directory use the mkdir command: 1.73 +</p> 1.74 +<pre> $ mkdir ~/Public 1.75 +</pre> 1.76 +<p> 1.77 +You can then have access via the URL: 1.78 +<a href="http://localhost/%7Ehacker/">http://localhost/~hacker/</a>. You can also use the machine name or IP 1.79 +address if you connect from another computer. 1.80 +</p> 1.81 +<a name="config"></a> 1.82 +<h3>/etc/lighttpd/lighttpd.conf - LightTPD configuration file</h3> 1.83 +<p> 1.84 +The main configuration file for LightTPD (<code>lighttpd.conf</code>) is located in /etc/lighttpd/. This file provided by 1.85 +SliTaz is self-explanatory, just browse. You can find other examples on the LightTPD website. On 1.86 +SliTaz you'll also find a <code>vhosts.conf</code> file for the configuration of any virtual hosts (hosting 1.87 +several sites on the same server). 1.88 +</p> 1.89 +<a name="start-stop-restart"></a> 1.90 +<h3>Start, stop, restart the web server</h3> 1.91 +<p> 1.92 +By default, SliTaz starts the server automatically at boot, to prevent this you need to remove 1.93 +<code>lighttpd</code> from the variable RUN_DAEMONS located in the system file 1.94 +<code>/etc/rcS.conf</code>. To start, stop, restart the server; you can use the commands: 1.95 +<code>/etc/init.d/lighttpd [start|stop|restart]</code>. Example to restart the server after 1.96 +changing the configuration file: 1.97 +</p> 1.98 +<pre> # /etc/init.d/lighttpd restart 1.99 +</pre> 1.100 + 1.101 +<a name="cgi-perl"></a> 1.102 +<h3>CGI scripts using Perl</h3> 1.103 +<p> 1.104 +To configure the LightTPD server to locate the path of the <code>perl</code> binary and use CGI/Perl, you'll need to 1.105 +install perl and modify the server configuration file. Example using Geany: 1.106 +</p> 1.107 +<pre> # tazpkg get-install perl 1.108 + # geany /etc/lighttpd/lighttpd.conf & 1.109 +</pre> 1.110 +<pre class="script"># CGI module. You can install Perl and assign .pl and .cgi scripts 1.111 +# to /usr/bin/perl 1.112 +$HTTP["url"] =~ "/cgi-bin/" { 1.113 + cgi.assign = ( 1.114 + ".sh" => "/bin/sh", 1.115 + ".cgi" => "/usr/bin/perl, 1.116 + ".pl" => "/usr/bin/perl 1.117 + ) 1.118 +} 1.119 +</pre> 1.120 + 1.121 +<a name="cgi-python"></a> 1.122 +<h3>CGI scripts using Python</h3> 1.123 +<p> 1.124 +To configure the LightTPD server to locate the path of the <code>python</code> binary and use CGI/Python, you'll need to 1.125 +to install python and modify the server configuration file. Example using Geany: 1.126 +</p> 1.127 +<pre> # tazpkg get-install python 1.128 + # geany /etc/lighttpd/lighttpd.conf & 1.129 +</pre> 1.130 +<pre class="script"># CGI module. You can install Python and assign .py and .cgi scripts 1.131 +# to /usr/bin/python 1.132 +$HTTP["url"] =~ "/cgi-bin/" { 1.133 + cgi.assign = ( 1.134 + ".sh" => "/bin/sh", 1.135 + ".cgi" => "/usr/bin/python, 1.136 + ".py" => "/usr/bin/python 1.137 + ) 1.138 +} 1.139 +</pre> 1.140 +<p> 1.141 +For the changes to be taken into effect and to use your first CGI scripts on SliTaz, just 1.142 +restart the LightTPD server: 1.143 +</p> 1.144 +<pre> # /etc/init.d/lighttpd restart 1.145 +</pre> 1.146 + 1.147 +<a name="auth"></a> 1.148 +<h3>Authentication - Protection for the directories</h3> 1.149 +<p> 1.150 +LightTPD provides authentication modules that can for example, protect a directory. The server 1.151 +offers several authentication methods, but we will begin by using the basic method without encrypting any 1.152 +passwords. In order to be able to use the module <code>mod_auth</code>, you must install the lighttpd-modules 1.153 +package (<code>tazpkg get-install lighttpd-modules</code>), once installed <code>mod_auth</code> 1.154 +must be added to the list of modules: 1.155 +</p> 1.156 +<pre class="script"># Modules to load. 1.157 +# See /usr/lib/lighttpd for all available modules. 1.158 +# 1.159 +server.modules = ( 1.160 + "mod_access", 1.161 + "mod_auth", 1.162 + "...", 1.163 +) 1.164 +</pre> 1.165 +<p> 1.166 +Now you can configure the modules by specifying the debug level and method (<code>plain</code>) and the 1.167 +path to the file containing a list of names using a protected password to access the directories. You must also 1.168 +define the directories that require authorization. In this example we'll protect the <code>admin/</code> directory 1.169 +and authorise it's access to user hacker (<code>user=hacker</code>): 1.170 +</p> 1.171 +<pre class="script"># Authentification for protected directory. 1.172 +auth.debug = 2 1.173 +auth.backend = "plain" 1.174 +auth.backend.plain.userfile = "/etc/lighttpd/plain.passwd" 1.175 +auth.require = ( "/admin/" => 1.176 +( 1.177 +"method" => "basic", 1.178 +"realm" => "Password protected area", 1.179 +"require" => "user=hacker" 1.180 +) 1.181 +) 1.182 +</pre> 1.183 +<p> 1.184 +Finally, we now create the file containing the passwords, add a user and restart the server for testing. 1.185 +The basic syntax for the file is <code>user:password</code>. You can create the file and add a user with the 1.186 +<code>echo</code> command or edit with your favorite text editor. To add <code>hacker:root</code> 1.187 +to the password file <code>/etc/lighttpd/plain.passwd</code>: 1.188 +</p> 1.189 +<pre> # echo "hacker:root" > /etc/lighttpd/plain.passwd 1.190 + Or : 1.191 + # nano /etc/lighttpd/plain.passwd 1.192 +</pre> 1.193 +<p> 1.194 +To test the address: http://localhost/admin/, just restart the server: 1.195 +</p> 1.196 +<pre> # /etc/init.d/lighttpd restart 1.197 +</pre> 1.198 + 1.199 +<!-- End of content --> 1.200 +</div> 1.201 + 1.202 +<!-- Footer. --> 1.203 +<div id="footer"> 1.204 + <div class="footer-right"></div> 1.205 + <a href="#top">Top of the page</a> | 1.206 + <a href="http://www.slitaz.org/en/doc/handbook/index.html">Table of contents</a> 1.207 +</div> 1.208 + 1.209 +<div id="copy"> 1.210 + Copyright © 2008 <a href="http://www.slitaz.org/en/">SliTaz</a> - 1.211 + <a href="http://www.gnu.org/licenses/gpl.html">GNU General Public License</a>;<br /> 1.212 + Documentation is under 1.213 + <a href="http://www.gnu.org/copyleft/fdl.html">GNU Free Documentation License</a> 1.214 + and code is <a href="http://validator.w3.org/">valid xHTML 1.0</a>. 1.215 +</div> 1.216 + 1.217 +</body></html> 1.218 +