root/cherokee/trunk/doc/config_quickstart.txt

Revision 2466, 10.6 kB (checked in by taher, 1 week ago)

--

Line 
1 == link:index.html[Index] -> link:config.html[Configuration]
2
3 Configuration Quickstart
4 ------------------------
5
6 This section briefly describes the whole administration web interface
7 provided by link:bundle_cherokee-admin.html[cherokee-admin]. This is
8 the only recommended way of configuring Cherokee. If you are looking
9 for development information, you should refer to the appropriate
10 section, especially link:dev_cherokee.conf.html[cherokee.conf] file
11 specification.
12
13 We will first show a quick overview of the available options, followed
14 by a simple walkthrough. You can learn more about the options in their
15 specific documentation entries.
16
17 [[overview]]
18 Overview
19 ~~~~~~~~
20 * link:config_status.html[Status]:
21   This gives a quick view of the server status.
22
23 * link:config_general.html[General]:
24   There are a number of entries that specify the most significant
25   configuration options such as the port - or ports - that the server
26   will listen to, the default timeout, whether to support keep-alive
27   connections and so on.
28
29 * link:config_virtual_servers.html[Virtual servers]:
30   If you want your web server to work with more than one domain you
31   will have to create link:config_virtual_servers.html[Virtual
32   servers] other than the `default` one. Each one will have a
33   completely independent configuration: paths, behavior, logging
34   facilities, etc.
35
36 * link:config_info_sources.html[Information Sources]:
37   Define the resources that will be providing information. For
38   instance, PHP.
39
40 * link:config_icons.html[Icons]:
41   Associate icon images with one or more file extensions. Used to
42   offer directory listings.
43
44 * link:config_mime_types.html[Mime Types]:
45   Manage MIME types.
46
47 * link:config_advanced.html[Advanced]:
48   This is to configure the most complex parameters of the server and how
49   it interacts with the operating system. If you are unsure about any of
50   the options here, better not mingle with them. Default values should
51   work just fine.
52
53 [[walkthrough]]
54 Walkthrough
55 ~~~~~~~~~~~
56 There is very little set up you must do to have a perfectly functional
57 web server out of the box. Cherokee's default configuration can be
58 used to serve any typical PHP-driven dynamic website.
59
60 If you have a specific need, you should check out the recipes present in
61 the 'Cookbook' section of the documentation. Among other subjects, you
62 can find information about
63 link:cookbook_optimizations.html[Cherokee optimizations],
64 setting up efficient link:cookbook_authentication.html[Authentication]
65 mechanisms, or configuring several popular application frameworks.
66
67 In this tutorial we will be setting up a system with a couple of
68 virtual servers, PHP support, some redirection rules and a simple
69 authentication mechanism.
70
71 To follow this walkthrough you need to be running
72 link:bundle_cherokee-admin.html[cherokee-admin]. This is an
73 administration tool, so you will need system administrator rights.
74
75 ----
76 # cherokee-admin
77
78 Login:
79   User:              admin
80   One-time Password: 72O3GRxZfTrE2zHx
81
82 Cherokee Web Server 0.11.0 (Nov 13 2008):: Listening on port 9090, TLS disabled,
83 IPv6 disabled, using epoll, 1024 fds system limit, max. 505 connections,
84 single thread
85 ----
86
87 Now you can access the administration interface simply by opening your
88 web browser and visiting link:http://localhost:9090[http://localhost:9090]
89
90 The User and One-time Password will be required initially. This is to
91 prevent other users of the local host from being able to configure the
92 server unless they have access to the password. This is also very
93 useful to allow temporary access to a remote administrator.
94
95 If your user doesn't have enough privileges you will be notified. Also
96 if no configuration file exists you will be prompted to create one
97 with the default settings.
98
99 image::media/images/admin_noconfig.png[cherokee.conf not present]
100
101 That is a good starting point. Right now your web server will not be
102 running yet. We will only be using two of the available tabs to adjust
103 some more settings: link:config_general.html[General] and
104 link:config_virtual_servers.html[Virtual Servers].
105
106 This is an example of what you'll be seeing:
107
108 image::media/images/admin_notrunning.png[Server not launched]
109
110 Of course, once we're done we will have to apply our changes and
111 launch the server. The configuration changes must be submitted to the
112 server, be it automatically if possible or by using the appropriate form
113 submitting buttons. But no change is reflected in the configuration
114 file until you `Save` the changes. You can be sure of not damaging
115 anything while playing around with `cherokee-admin`. At least not
116 until you `Save` the changes. Note that, if the Cherokee server is
117 running, the applied modifications will only affect the instance being
118 executed if either `Graceful restart` or `Hard restart` are selected.
119 No restart simply modifies the configuration file, but doesn't affect
120 the currently running instance. A `graceful restart` will preserve the
121 old set up for any prior connections, while a `hard restart` will
122 kill every connection and instantly apply the changes.
123
124 This is what the `General` tab looks like:
125
126 image::media/images/admin_general.png[General]
127
128 We will only be modifying the *Server Permissions*. It usually is a
129 poor choice to run services with super user privileges. Set both
130 *User* and *Group* to `www-data`. Your system might already have
131 another user account specifically for the purpose of running a
132 webserver. Use that instead if so, or create the `www-data` user if
133 you don't already have one.
134
135 Next is the link:config_virtual_servers.html[Virtual Servers] tab:
136
137 image::media/images/admin_vserver.png[Virtual server]
138
139 When you start, you will only have one virtual server called
140 `default`. You can begin by cloning it as `example`.
141 While you are at it you should also append the following line to your
142 `/etc/hosts` file (in Windows you will find this as
143 `%WINDIR%\system32\drivers\etc\hosts`).
144
145 ----
146 127.0.0.1       example.net example.org
147 ----
148
149 This is to allow your system to resolve requests for `example.net` or
150 `example.org` locally. Of course, once you are out in the Wild (you
151 know, in the Internet), you will need proper DNS records.
152
153
154 *`default`*::
155 We will leave default untouched except for the document root path,
156 which we will change. This is done through the `Basics` tab.
157 You could create by hand '/var/www/default' for example and set it up
158 in the appropriate field.
159 +
160 If you access your machine by IP or a DNS resolution points in that
161 direction for any particular domain, the contents of your document
162 root directory will be exposed ('/var/www' by default unless you
163 changed that during the build process). Whenever there is no match for
164 a virtual server specifically defined in your list, the `default`
165 virtual server will be the one responding.
166 +
167 Right now any file with the 'php' extension will be served after being
168 processed by the PHP interpreter (you should have `php-cgi` installed
169 in your system for this, though).
170 +
171 Any requested file would be sent. If a directory is requested, a file
172 called index.php or index.html will be served if it is present (the
173 search will be performed in that order; you can configure this in the
174 `Basics` tab). If not, a directory listing is offered instead. If you
175 would want to prevent this behavior but would like to keep up
176 serving whatever content is requested directly, simply change the
177 `List & Send` handler for the `Static Content` handler.
178
179
180 *`example`*::
181 For now this virtual server is an exact copy of the untouched
182 `default` virtual server. Create some new directories
183 '/var/wwww/example' and '/var/wwww/example/auth', and configure the
184 first one as default document root path.
185 +
186 Next, setup `example.net` and `example.com` in the `Domain names` tab.
187 We'll erase everything in the *Targets* list within the `Behavior`
188 tab, except the `default` rule. With this we'll only be able to serve
189 static content.
190 +
191 Accessing the URL http://example.org should now show a list of
192 available files and directories under '/var/www/example/'.
193 +
194 Now lets password protect the `auth` directory. Add a new `Directory`
195 class rule pointing to `/auth`. Then, through the `Security` tab, add
196 a `Validation Mechanism` under `Authentication`.
197 +
198 The field `Realm` is mandatory. Lets set it as `Secured Area`.
199 If you choose `PAM` and impose no more restrictions, only users with
200 a local account in your system will be able to access the secured zone
201 at http://example.net/auth
202 Other mechanisms would work in a similar fashion but with their
203 specific requirements. For example, had you chosen `Plain text file`
204 instead of PAM you would have had to specify a `Password File`.
205 For example, it could have been `/var/www/passwords.txt` with the
206 following contents:
207 +
208 ----
209 testuser1:password1
210 testuser2:password2
211 ----
212 +
213 Note that the rule must not be flagged as `Final`, or else no other
214 rules will be applied afterwards and no access will be given to any
215 contents. This is because at this point we have not defined any
216 handler for the `/auth` rule and nothing would be served.
217 +
218 Refer to the link:cookbook_authentication.html[Cookbook] for detailed
219 examples on the different options.
220 +
221 Lastly, lets configure a redirection rule by choosing a "Regular
222 Expression" as the new rule type. Type the following regex: `^/rss.*$`
223 Then, within the `Handler` selection tab specify a target: `/feed`
224 +
225 image::media/images/admin_rule_regex.png[Regex]
226 +
227 And voilà! A request of the form http://example.net/rss2 would be
228 redirected to http://example.net/feed
229 +
230 Any rule type can be used with the redirection handler: Directory,
231 Extensions, Regular Expression, etc. In this case the fact that the
232 rule type is "Regular Expression" affects only slightly. Refer to the
233 appropiate section of the documentation,
234 link:modules_handlers_redir.html[Redirection Handler], for more
235 details.
236 +
237 Note that the `Type` of the *Redirection* is `External`. This means
238 the server will instruct the requesting web client to fetch the
239 redirected URL, which means the client will always know what the
240 final URL is. This also means the redirection can be done to servers
241 other than your own. If it were internal, the redirection would be
242 invisible (not showing the target  URL), but it would be limited to
243 the same `virtual server`.
244 +
245 A much more general redirection could be one using these values:
246 +
247 *Regular Expression*;;
248   `^/(.*)$`
249 +
250 *Substitution*;;
251   http://www.example.com/example.net/$1
252
253 +
254 Note that this rule would have to be external since `example.com` is
255 not among the domains managed by our configuration.
256 +
257 This would redirect every petition to a site hosted under
258 `http://example.com/example.net`. For instance, the request for
259 `http://example.net/image.jpg` would return
260 `http://example.com/example.net/image.jpg`.
261 +
262 If you need more details, Check out the documentation for the
263 link:modules_handlers_redir.html[redirection] handler.
Note: See TracBrowser for help on using the browser.