~ubuntu-branches/ubuntu/natty/moin/natty-updates

« back to all changes in this revision

Viewing changes to wiki/underlay/pages/HelpOnInstalling(2f)ApacheOnLinux/revisions/00000001

  • Committer: Bazaar Package Importer
  • Author(s): Jonas Smedegaard
  • Date: 2008-06-22 21:17:13 UTC
  • mfrom: (0.9.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080622211713-fpo2zrq3s5dfecxg
Tags: 1.7.0-3
Simplify /etc/moin/wikilist format: "USER URL" (drop unneeded middle
CONFIG_DIR that was wrongly advertised as DATA_DIR).  Make
moin-mass-migrate handle both formats and warn about deprecation of
the old one.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
## Please edit system and help pages ONLY in the moinmaster wiki! For more
2
 
## information, please see MoinMaster:MoinPagesEditorGroup.
 
1
## Please edit system and help pages ONLY in the master wiki!
 
2
## For more information, please see MoinMoin:MoinDev/Translation.
3
3
## page was renamed from HelpOnInstalling/ApacheOnUnix
4
4
##master-page:Unknown-Page
5
5
##master-date:Unknown-Date
6
 
#acl MoinPagesEditorGroup:read,write,delete,revert All:read
 
6
#acl -All:write Default
7
7
#format wiki
8
8
#language en
9
9
This page describes the particular steps that need to be taken to create a wiki instance using MoinMoin on Linux with the Apache web server. '''You should have already performed the ../BasicInstallation. '''Installations on other Unices like FreeBSD are very similar.
10
10
 
11
 
Two scenarios are possible. You might be the administrator (root) of the server, able to install and modify files almost anywhere on the machine, and notably able to modifiy the Apache configuration. You might also be a simple user, only able to write files into your home directory, and unable to alter the master Apache config file. The two scenarios are discussed below.
12
 
 
13
 
'''Table of contents''' [[TableOfContents]]
14
 
 
15
 
== Administrator (root) ==
16
 
Most GNU/Linux distributions come with Apache pre-installed. There is, however, some variation as to where exactly the various Apache files are located. You should consult your distribution manual, or ask on the appropriate discussion board. In the following paragraphs, we assume a (quite standard) file system layout with:
17
 
 
18
 
 * `/etc/httpd/httpd.conf` - the main Apache configuration file
19
 
 * `/var/log/httpd/error_log` - the log file containing Apache error messages
20
 
 
21
 
Some distributions use `apache` instead of `httpd` for the directory names, others may use weirder settings.
 
11
On this page two installation scenarios are discussed:
 
12
 
 
13
 1. You have '''Administrator Rights '''(you are user 'root' or may use sudo)  for a server and are able to install and modify files almost anywhere on the machine, and notably able to modifiy the Apache configuration.
 
14
 1. You are a '''Simple User,''' only able to write files into your home directory, and unable to alter the master Apache configuration file.
 
15
 
 
16
The following options are not mentioned here:
 
17
 * using '''suEXEC'''
 
18
 * using '''FastCGI ''' (see ../FastCgi)
 
19
 * using '''mod_python''' (see ../ApacheWithModPython)
 
20
 * setting up a '''Root Wiki''' (see HelpOnConfiguration/ApacheVoodoo)
 
21
 * For more advanced configurations and some tricks see also HelpMiscellaneous.
 
22
 
 
23
 
 
24
'''Table of contents''' <<TableOfContents>>
 
25
 
 
26
== Administrator Scenario ==
 
27
The exact location of the various Apache configs varies - often used locations are: {{{/etc/httpd/, /etc/apache/ or /etc/apache2/}}}. You should have at least ''some'' know-how of how to set up and deal with Apache, especially when it comes to virtual host setup. If you do not know what we are talking about, please read about ''Configuration Files'' and ''Apache Virtual Host documentation ''in the [[http://httpd.apache.org/docs/|Apache documentation]].
 
28
 
 
29
On Apache2 it is quite usual to have a directory (like /etc/httpd/conf.d) for virtual hosts. So every file ending with ''.conf'' will be included into the main Apache configuration file. To look if this is true for your configuration, search for the word "Include".
22
30
 
23
31
=== Create a wiki instance ===
24
32
Creating a wiki instance involves copying files around and setting appropriate permissions. Before you can proceed, you need to know what user and group your Apache server runs as. The easiest way to know this is to issue this command:
28
36
User wwwrun
29
37
Group nogroup
30
38
}}}
31
 
 
32
39
This shows a typical result: "`wwwrun.nogroup`". Other common results are "`nobody.nogroup`", "`apache.apache`" and "`www-data.www-data`". You can of course use your own. What matters is that you know which ones are in use, because you will need them to set file permissions.
33
40
 
34
41
Once you have gathered this information, read ../WikiInstanceCreation and follow the steps described there.
55
62
sys.path.insert(0, '..')
56
63
}}}
57
64
 
58
 
You can also use the absolute name of the directory that contains the `wikiconfig.py` file instead of `'..'`.
 
65
An even better way is to use the absolute path name of the directory that contains the `wikiconfig.py` file instead of `'..'`.
59
66
 
60
67
=== Configure Apache ===
61
 
Now that every file is in place and properly locked down (as far as the filesystem is concerned), we need to configure Apache so that it offers access to the right files, and no others. However, since the default Apache configuration varies a lot according to the distribution you use, and since administrators often make important additions and changes to it, we cannot give exact instructions that cover all cases. Instead, we will first describe roughly what needs to be done, and then give a few specific lines that you should add at the appropriate place in your Apache config.
 
68
Now that every file is in place and properly locked down (as far as the filesystem is concerned), we need to configure Apache so that it offers access to the right files, and no others. However, since the default Apache configuration varies a lot depending on the distribution you use, and since administrators often make important additions and changes to it, we cannot give exact instructions that cover all cases. Instead, we will first describe roughly what needs to be done, and then give a few specific lines that you should add at the appropriate place in your Apache config.
62
69
 
63
70
Your Apache should be set up so that:
64
71
 
65
72
 * Access to your instance directory is denied (sane Apache installations should actually deny access to the whole server, and then only allow a few specific directories).
66
 
 * An alias is set up to redirect requests from `/wiki/` (in the URL) to the `htdocs` directory (in the `share` directory, as discussed at the bottom of ../BasicInstallation)
67
 
 * A script alias is set up to redirect requests from whatever you want (we suggest you use your instance name, for example `/mywiki`) to the CGI script you just copied.
 
73
 * An '''Alias''' is set up to redirect requests from `/moin_static160/` (in the URL - see also `url_prefix_static` configuration variable) to the `htdocs` directory (in the `share` directory, as discussed at the bottom of ../BasicInstallation). Please note that `url_prefix_static` will change with every moin release!
 
74
 * A '''!ScriptAlias''' is set up to redirect requests from whatever you want (we suggest you use your instance name, for example `/mywiki`) to the CGI script you just copied.
68
75
 
69
76
The following commands will add two lines at the bottom of your Apache config file. These lines only cover the last two items listed above. You have to check the first one by yourself (there is too much variation in Linux distributions). Note that you may have to move the two lines to the appropriate place in your config file -- maybe near other similar lines.
70
77
 
71
78
{{{
72
79
> echo "" >>/etc/httpd/httpd.conf
73
 
> echo "Alias /wiki/ \"$SHARE/htdocs/\"" >>/etc/httpd/httpd.conf
 
80
> echo "Alias /moin_static160/ \"$SHARE/htdocs/\"" >>/etc/httpd/httpd.conf
74
81
> echo "ScriptAlias /mywiki \"$WIKILOCATION/$INSTANCE/cgi-bin/moin.cgi\"" >>/etc/httpd/httpd.conf
75
82
}}}
76
83
 
77
 
You only need to define the alias for `htdocs` once. You need to define a different script alias for each wiki instance you intend to run.
 
84
So this would add two lines like the both below to a config file (possibly you use one for each virtual server):
 
85
 
 
86
{{{
 
87
Alias /moin_static160/ /usr/local/share/htdocs/
 
88
ScriptAlias /mywiki /usr/local/share/moin/mywiki/cgi-bin/moin.cgi
 
89
}}}
 
90
 
 
91
You only need to define the Alias for `htdocs` once, no matter how many wikis you run with the 1.6.0 version of moin. You need to define a different script alias for each wiki instance you intend to run. So you could also define the Alias in a central Apache configuration file and only define the ScriptAlias in virtual host configurations.
78
92
 
79
93
=== Configure MoinMoin ===
80
 
Finally, check that the `wikiconfig.py` file in the instance directory contains correct paths for the htdocs prefix, the instance data directory, and the instance underlay directory. You can use relative paths for the directories, but note that they are relative to the CGI script, not the configuration file! You can also use absolute paths, and save yourself some headaches.
 
94
Finally, check that the `wikiconfig.py` file in the instance directory contains correct paths for:
 
95
 * `url_prefix_static` (static stuff like css/img/js)
 
96
 * `data_dir` (the instance data directory) and
 
97
 * `data_underlay_dir` (the instance underlay directory).
 
98
 
 
99
You can use relative paths for the directories, but note that they are relative to the CGI script, not the configuration file! Better '''use absolute paths''', and save yourself some headaches.
81
100
 
82
101
Here are the settings you should have in the config file if you followed all our suggestions:
83
102
 
84
103
{{{
85
 
    data_dir = '../data/'
86
 
    data_underlay_dir = '../underlay/'
87
 
    url_prefix = '/wiki'
 
104
    data_dir = '../data/'  # better use absolute path
 
105
    data_underlay_dir = '../underlay/'  # better use absolute path
 
106
    url_prefix_static = '/moin_static160' # depends on moin version
88
107
}}}
89
 
 
90
108
There are other settings you will likely want to alter, look at the bottom of ../WikiInstanceCreation for more details about them.
91
109
 
92
110
=== Test the wiki ===
93
111
Everything should work fine now. It is time to '''restart the Apache server''' (usually with "`/etc/init.d/apache restart`", sometimes with "`apachectl restart`") and perform the following steps:
94
112
 
95
113
 * Run the ''Moin``Moin CGI Diagnosis'': connect to "`http://127.0.0.1/mywiki?action=test`" (or the name and port you have defined in the Apache configuration file). Verify that the displayed information is correct. Check that the directories listed under ''Checking directories...'' are ''OK''.
96
 
 * Access your new wiki with the URL "`http://127.0.0.1/mywiki/`" (or the name and port you have defined in the Apache configuration file). You should see the Front``Page.
97
 
 * If this is the case, try to edit it and save your changes.
 
114
 * Access your new wiki with the URL "`http://127.0.0.1/mywiki/`" (or the name and port you have defined in the Apache configuration file). You should see some wiki page - read it.
 
115
 * Then go to the WikiSandBox page.
 
116
 * Try to edit it and save your changes.
98
117
 * If that works, see if your edit is reflected on the Recent``Changes page.
99
118
 * If you see them, congratulations, your new wiki works! :)
100
 
 
101
119
If something goes wrong, have a look at Troubleshooting, at the bottom of this page.
102
120
 
103
 
=== Apache tricks ===
104
 
For more advanced configuration and some tricks see HelpMiscellaneous.
105
121
 
106
 
== Simple user (home directory installation) ==
 
122
== Simple User Scenario ==
107
123
On machines shared by many people, simple users typically have no access to the root account, cannot modify the `httpd.conf` file, and cannot copy files into the system-wide `cgi-bin` and `htdocs` directories. In that case, Apache can be set up so that each user can host a web site in the home directory of his or her shell account, using the `UserDir` directive. If the machine administrator decides to use it, all URLs that start with "`/~username`" will be redirected to a directory in the users' home directories, where they have write permission and can install Moin``Moin.
108
124
 
109
125
As an example, we will consider the case of a user named "`mm`". Of course, wherever you see "`mm`" below, you will replace it with your own username.
115
131
> ls -ld ~/public_html
116
132
drwxr-xr-x   2 mm       users        4096 Nov 30 00:29 public_html
117
133
}}}
118
 
 
119
134
If the directory does not exist, create it, and be sure it can be read and entered by the web server.
120
135
 
121
136
{{{
124
139
> ls -ld ~/public_html
125
140
drwxr-xr-x   2 mm       users        4096 Nov 30 00:35 public_html
126
141
}}}
127
 
 
128
142
Now, check if the "`/~mm`" URL works:
129
143
 
130
144
{{{
132
146
URL=http://localhost/~mm/ (GET)
133
147
STATUS=HTTP/1.1 200 OK
134
148
}}}
135
 
 
136
149
If you get a "`200 OK`" response code, then it works, and you can go on to the next check. If you get a "`403 Forbidden`" or a "`404 Not Found`" response, then maybe something is wrong with your directory, or maybe the whole thing has not been enabled by your administrator.
137
150
 
138
151
 * Check the permissions for your home directory (`~`) and your `public_html` directory. The first one should at least end with "`--x`", and the second one, as we saw above, with "`r-x`".
139
152
 * It also possible that the administrator has set up another name for the personal web site directory. "`public_html`" is just the usual default, but anything can actually be used. There is no way to know, you have to ask the administrator (root).
140
153
 * Finally, if the personal web site feature is disabled, maybe you can ask the administrator to enable it?
141
 
 
142
154
Once you have checked you can read the files in the directory, you need to check that you are also able to execute CGI scripts in that directory. Use the following commands to create a simple CGI script in the appropriate location:
143
155
 
144
156
{{{
153
165
> lynx -dump http://localhost/~jh/cgi-bin/test.cgi
154
166
CGI scripts work
155
167
}}}
156
 
 
157
168
If you get anything else than "`CGI scripts work`", then something went wrong. Check the directory permissions as above, try other names (or ask about them). The sad truth might be that you are not allowed to execute CGI scripts. You would then have to ask the administrator (root) for that permission.
158
169
 
159
170
Once you get it, you can set up your wiki instance in the `public_html` directory. :)
162
173
Creating a wiki instance involves copying files around and setting appropriate permissions. Read ../WikiInstanceCreation and follow the steps described there.
163
174
 
164
175
=== Install the htdocs files ===
165
 
The web server needs to access these files, so we need to copy them in the "`public_html`" directory. Just use this:
 
176
The web server needs to access these files, so we need to copy them into the "`public_html`" directory. Just use this:
166
177
 
167
178
{{{
168
179
> cd ~/public_html
169
 
> cp -R ~/share/moin/htdocs wiki
170
 
> chmod -R a+rX wiki
 
180
> cp -R ~/share/moin/htdocs moin_static160
 
181
> chmod -R a+rX moin_static160
171
182
}}}
172
183
 
173
184
=== Install moin.cgi ===
185
196
 
186
197
{{{
187
198
import sys
188
 
sys.path.insert(0, '/home/mm/lib/python2.3')
189
 
sys.path.insert(0, '/home/mm/lib/python2.3/site-packages')
 
199
sys.path.insert(0, '/home/mm/lib/python2.4')
 
200
sys.path.insert(0, '/home/mm/lib/python2.4/site-packages')
190
201
sys.path.insert(0, '/home/mm/share/moin/mywiki')
191
202
}}}
192
 
 
193
203
Of course, you need to adapt the paths to your situation. The first two lines should help locate the Moin``Moin modules, the last one should help locate the `wikiconfig.py` file.
194
204
 
195
 
'''Note:''' You might also need to edit the first line of the file, to point to the correct version of Python. The default should be fine, but a line like "`#! /usr/bin/python2.3`" might help you if the default does not work.
 
205
'''Note:''' You might also need to edit the first line of the file, to point to the correct version of Python. The default should be fine, but a line like "`#! /usr/bin/python2.4`" might help you if the default does not work.
196
206
 
197
 
'''Note 2:''' In this file there is a line reading {{{request = RequestCGI()}}}. If you have a complex mod_rewrite case, you might want to add {{{properties = {'script_name': '/mywiki'} }}} in the parenthesis. This will let MoinMoin generate URLs that start with {{{/mywiki}}} and not the path that the webserver passed to MoinMoin:
 
207
'''Note 2:''' In this file there is a line reading {{{request = RequestCGI()}}}. If you have a complex mod_rewrite case, you might want to add {{{properties = {'script_name': '/mywiki'} }}} in the parentheses. This will let MoinMoin generate URLs that start with {{{/mywiki}}} and not the path that the webserver passed to MoinMoin:
198
208
 
199
209
{{{
200
210
def handle_request(req, env, form):
203
213
}}}
204
214
 
205
215
=== Configure MoinMoin ===
206
 
Finally, check that the `wikiconfig.py` file in the instance directory contains correct paths for the htdocs directory, the instance data directory, and the instance underlay directory. You can use relative paths for the directories, but note that they are relative to the CGI script, not the configuration file! You can also use absolute paths, and save yourself some headaches.
 
216
Finally, check that the `wikiconfig.py` file in the instance directory contains correct paths for `url_prefix_static` (the htdocs directory), `data_dir` (the instance data directory) and `data_underlay_dir` (the instance underlay directory). You can use relative paths for the directories, but note that they are relative to the CGI script, not the configuration file! It is better to use '''absolute paths''', and save yourself some headaches.
207
217
 
208
218
{{{
209
219
    data_dir = '/home/mm/share/moin/mywiki/data/'
210
220
    data_underlay_dir = '/home/mm/share/moin/mywiki/underlay/'
211
 
    url_prefix = '/~mm/wiki'
 
221
    url_prefix = '/~mm/moin_static160'
212
222
}}}
213
 
 
214
223
=== Test the wiki ===
215
224
Everything should work fine, now. It is time to perform the following steps:
216
225
 
217
226
 * Run the ''Moin``Moin CGI Diagnosis'': {{{> lynx -dump http://localhost/~mm/cgi-bin/moin.cgi?action=test}}}
218
 
 * If it worked, try to access your new-born wiki with the URL "`http://127.0.0.1/~mm/cgi-bin/moin.cgi`". You should see the Front``Page.
219
 
 * If this is the case, try to edit it and save your changes.
 
227
 * If it worked, try to access your new-born wiki with the URL "`http://127.0.0.1/~mm/cgi-bin/moin.cgi`". You should see some wiki page - read it.
 
228
 * Now go to the WikiSandBox page.
 
229
 * Try to edit it and save your changes.
220
230
 * If that works, see if your edit is reflected on the Recent``Changes page.
221
231
 * If you see them, congratulations, you have a new wiki! :)
222
232
 
239
249
  Deny from all
240
250
</Directory>
241
251
}}}
242
 
 
243
252
To allow Apache to serve directories outside of the document root you have to add these lines to "`/etc/httpd/httpd.conf`" (in SuSE it is recommended to create a new "`http.conf.local`" and include this file in "`/etc/sysconfig/apache2`"):
244
253
 
245
254
{{{
248
257
   Order deny,allow
249
258
   Allow from all
250
259
</Directory>
251
 
 
252
260
ScriptAlias /mywiki "/usr/share/moin/mywiki/cgi-bin/moin.cgi"
253
261
<Directory "/usr/share/moin/mywiki/cgi-bin">
254
262
   Order deny,allow
255
263
   Allow from all
256
264
</Directory>
257
265
}}}
258
 
 
259
266
Of course, you need to adapt the paths to your particular situation.