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