source: INSTALL @ 224:df55ed109374

Revision 224:df55ed109374, 17.8 KB checked in by tonio, 4 days ago (diff)

fix: the untildate field is not mandatory!

Line 
1Installation
2============
3
4Requirements
5------------
6
7- Python version 2.6+
8- Django version 1.2+ (http://docs.djangoproject.com/en/dev/intro/install/#intro-install)
9- south version 0.7+ (http://south.aeracode.org/)
10
11How to install
12--------------
13
14Download Modoboa's tarball and extract it::
15
16  # tar xzf modoboa-<version>.tar.gz
17  # mv modoboa-<version> modoboa
18
19Then, enter the modoboa directory, create a settings.py file (you can
20use settings-sample.py as a model). Specify database relative
21informations. You must choose between mysql and postgresql, other
22types are not supported by major email projects like postfix or
23dovecot.
24
25Create a database with the name you specified in settings.py. Make
26sure your database is using UTF8 as a default charset. If not, you
27will surely have problems (with MySQL at least). You will probably
28need to install a python database backend (like MySQLdb).
29
30Initialise the database by running the following command::
31
32  # python manage.py syncdb
33
34Create the super admin account (just follow the procedure).
35
36Since version 0.8, Modoboa is using south to handle schema
37migration. In order to finish the database creation, you must run the
38first migration like this::
39
40  # python manage.py migrate
41
42How to upgrade
43--------------
44
45First, decompress the new tarball at the same location than your
46current installation. Then, check if the new version you're installing
47requires a migration::
48
490.8 -> 0.8.1 : project renamed.
50
51 * First, rename your mailng folder to modoboa and copy all the
52   content from modoboa-0.8.1 to modoboa.
53 
54 * Edit your settings.py and replace all occurences of mailng by
55   modoboa. Make sure you don't modify the DATABASE section as you're
56   not going to rename your database.
57
58 * Rename the MAILNG_DIR variable to MODOBOA_DIR.
59
60 * Add 'django.contrib.messages.middleware.MessageMiddleware' to
61   MIDDLEWARE_CLASSES and 'django.contrib.messages' to
62   INSTALLED_APPS. Save your modifications.
63
64 * Run the following command::
65
66   # python manage.py syncdb
67
68 * For all activated extensions, run the following command::
69 
70   # export PYTHONPATH=<modoboa_dir>/..
71   # DJANGO_SETTINGS_MODULE=modoboa.settings \
72      <modoboa_dir>/scripts/extension.py <extension> on
73
74 * Update your webserver configuration and restart it.
75
76
770.7 -> 0.8 : SQL migration needed.
78
79Before you start migration, make sure you have updated your
80INSTALLED_APPS variable and that it contains at least::
81
82  INSTALLED_APPS = (
83     # Django's stuff before
84
85     'south',
86     'modoboa',
87     'modoboa.lib',
88     'modoboa.admin',
89     'modoboa.userprefs',
90  )
91
92Starting with 0.8, modoboa.main doesn't exist anymore. You need to
93remove it from your INSTALLED_APPS.
94
95NB: Before doing this migration, I recommend that you make a copy of your
96existing database.
97
98Finally, run the following commands:
99
100  # python manage.py syncdb
101  # python manage.py convert_to_south
102  # python manage.py migrate --all 0001 --fake
103  # python manage.py migrate --all 0002
104
1050.6 -> 0.7 : no SQL modifications.
1060.5 -> 0.6 : no SQL modifications.
107
108Time zone and language
109----------------------
110
111Modoboa is available in english, french and german. You can choose
112which language to use by modifying the LANGUAGE_CODE variable inside
113settings.py::
114
115  LANGUAGE_CODE = 'en-US' # English
116  # or
117  LANGUAGE_CODE = 'fr-FR' # French
118  # or
119  LANGUAGE_CODE = 'de-DE' # German
120
121You can also specify your time zone by modifying the TIME_ZONE
122variable. For example::
123
124  TIME_ZONE = 'Europe/Paris'
125
126Host configuration
127------------------
128
129Before testing Modoboa, you must create a group and a user that will be
130used to store mails on the host filesystem. There is only one
131group/user needed because we are in a virtual hosting configuration
132(ie. users with non-UNIX accounts).
133
134For example, create a vmail group::
135
136  # groupadd vmail
137
138Then create a vmail user::
139
140  # useradd -g vmail -d /var/vmail -m vmail
141
142At last, the system user used to run modoboa will need permissions to
143manipulate directories in vmail's homedir. To do so, edit your /etc/sudoers
144file and add the following inside::
145
146  <user_that_runs_modoboa> ALL=(vmail) NOPASSWD: ALL
147
148Testing installation
149--------------------
150
151As a typical Django application, Modoboa can be tested using a simple web
152server. Just run this command to start it::
153
154  # python manage.py runserver
155
156You will be able to play with Modoboa by looking at
157http://<youraddress>:8000/modoboa/admin/.
158
159Tips to link Modoboa with postfix
160--------------------------------
161
162First, define following maps on your server (this should work with
163Postfix versions >= 2.2)::
164
165# /etc/postfix/sql-domains.cf
166  user = <user>
167  password = <password>
168  dbname = <database>
169  hosts = 127.0.0.1
170  query = SELECT name FROM admin_domain WHERE name='%s' AND enabled='1'
171
172# /etc/postfix/sql-mailboxes.cf
173  user = <user>
174  password = <password>
175  dbname = <database>
176  hosts = 127.0.0.1
177  query = SELECT path FROM admin_mailbox WHERE full_address = '%s'
178
179# /etc/postfix/sql-aliases.cf
180  user = <user>
181  password = <password>
182  dbname = <database>
183  hosts = 127.0.0.1
184  query = SELECT t3.full_address FROM admin_alias AS t1, admin_alias_mboxes AS t2, admin_mailbox AS t3 WHERE t1.full_address='%s' AND t1.id=t2.alias_id AND t2.mailbox_id=t3.id AND t1.enabled='1'
185
186Then, use the following configuration in your /etc/postfix/main.cf file
187(this is one possible configuration)::
188
189  # Stuff before
190  mailbox_transport = virtual
191  home_mailbox = .maildir/
192  maildrop_destination_recipient_limit = 1
193  virtual_minimum_uid = <vmail user id>
194  virtual_gid_maps = static:<vmail group id>
195  virtual_uid_maps = static:<vmail user id>
196  virtual_mailbox_base = /var/vmail
197
198  relay_domains =
199  virtual_mailbox_domains = mysql:/etc/postfix/sql-domains.cf
200  virtual_mailbox_maps = mysql:/etc/postfix/sql-mailboxes.cf
201  virtual_alias_maps = mysql:/etc/postfix/sql-aliases.cf
202  # Stuff after
203
204NB: Modoboa supports both maildir and mbox formats. You can specify
205which format to use by modifying the MAILBOX_TYPE parameter available
206in the admin panel.
207
208Tips to activate auto-reply messages in Postifx
209-----------------------------------------------
210
211Since version 0.6, mail users can define an auto-reply message with Modoboa.
212
213To activate the extension, edit your settings.py and add the following
214line inside the INSTALLED_APPS variable::
215
216  'modoboa.extensions.postfix_autoreply',
217
218Run the following command to activate the component::
219
220  # export PYTHONPATH=<modoboa_dir>/..
221  # DJANGO_SETTINGS_MODULE=modoboa.settings \
222      <modoboa_dir>/scripts/extension.py postfix-autoreply on
223
224Then run the following commands to update Modoboa SQL schema and content::
225
226  # python manage.py syncdb
227  # python manage.py migrate postfix-autoreply
228  # export PYTHONPATH=$PWD/..
229  # DJANGO_SETTINGS_MODULE=modoboa.settings ./scripts/postfix_autoreply/upgrade_autoreply.py
230
231The user that executes the autoreply script needs to access
232settings.py. You must apply proper permissions on this file. For
233example, if settings.py belongs to www-data:www-data, you can add the
234vmail user to the www-data group and set the read permission for the
235group.
236
237To make Postfix understand this feature, you need to update your configuration
238files as follow::
239
240 # /etc/postfix/main.cf
241  transport_maps = mysql:/etc/postfix/maps/sql-transport.cf
242  virtual_alias_maps = mysql:/etc/postfix/maps/sql-aliases.cf
243          mysql:/etc/postfix/maps/sql-autoreplies.cf
244
245 # /etc/postfix/master.cf
246  autoreply unix        -       n       n       -       -       pipe
247            flags= user=vmail:<group> argv=<path_to_modoboa>/scripts/postfix_autoreply/autoreply $sender $mailbox
248
249Then, create new map files with the following content::
250
251 # /etc/postfix/maps/sql-transport.cf
252  user = <user>
253  password = <password>
254  dbname = <database>
255  hosts = 127.0.0.1
256  query = SELECT method FROM postfix_autoreply_transport WHERE domain='%s'
257
258 # /etc/postfix/maps/sql-autoreplies.cf
259  user = <user>
260  password = <password>
261  dbname = <database>
262  hosts = 127.0.0.1
263  query = SELECT full_address, autoreply_address FROM postfix_autoreply_alias WHERE full_address='%s'
264
265Finally, edit the shell script 'autoreply' located inside the
266'scripts' directory and change the value of BASEDIR. (just put absolute path
267of the directory where modoboa is installed)
268
269NB: auto-reply messages are just sent one time per sender for a
270pre-defined time period. By default, this period is equal to 1 day
271(86400s), you can adjust this value by modifying the AUTOREPLY_TIMEOUT
272parameter available in the admin panel.
273
274NB: Be sure that both 'autoreply' and 'autoreply.py' scripts (located
275inside the 'scripts/postfix_autoreply' directory) have good
276permissions (ie. 0755).
277
278Tips to link Modoboa with dovecot
279--------------------------------
280
281If you are using 'maildir' format to store mailboxes, add the
282following line inside your main Dovecot config file
283(/etc/dovecot/dovecot.conf)::
284
285  mail_location = maildir:<path_to_mailboxes>/%d/%n/.maildir
286
287If you are using 'mbox' format, put the following::
288 
289  mail_location = mbox:<path_to_mailboxes>/%d/%n/:INBOX=<path_to_mailboxes>/%d/%n/Inbox
290
291To make the authentication work, edit 'dovecot.conf' and add the
292following inside::
293
294  auth default {
295    # ... stuff before
296
297    passdb sql {
298      # Path for SQL configuration file, see /etc/dovecot/dovecot-sql.conf for
299      #  example
300      args = /etc/dovecot/dovecot-sql.conf
301    }
302   
303    userdb sql {
304      # Path for SQL configuration file
305      args = /etc/dovecot/dovecot-sql.conf
306    }
307
308    # ... stuff after
309  }
310
311Be sure to activate only one backend (per type) inside your configuration
312(comment other ones).
313
314Then, edit your /etc/dovecot/dovecot-sql.conf and modify following lines::
315
316  driver = mysql
317  connect = host=<mysqld socket> dbname=<database> user=<user> password=<password>
318  default_pass_scheme = CRYPT
319  password_query = SELECT full_address AS user, password FROM admin_mailbox WHERE full_address = '%u'
320  user_query = SELECT path AS home, uid, gid FROM admin_mailbox WHERE full_address = '%u'
321
322Enable quotas with Dovecot
323--------------------------
324
325Put the following lines inside your dovecot.conf file::
326
327    protocol imap {
328      mail_plugins = quota imap_quota
329    }
330
331Before continuing, you need to know which quota backend must be user
332(function of mailboxes format)::
333 * 'mbox' : backend=dirsize,
334 * 'maildir' : backend=maildir.
335
336If you use version prior to 1.1, add also the following configuration::
337
338  plugin {
339    # 10 MB default quota limit
340    quota = <backend>:storage=10240
341  }
342
343Then modify the above user_query inside dovecot-sql.conf file like
344that to activate per user quotas::
345
346  user_query = SELECT path AS home, uid, gid, concat('<backend>:storage=', quota / 1024) AS quota FROM admin_mailbox WHERE full_address = '%u'
347
348For version >= 1.1, put the following configuration inside dovecot.conf file::
349
350  plugin {
351    # Default 10M storage limit with an extra 5M limit when saving to Trash.
352    quota = <backend>:User quota
353    quota_rule = *:storage=10M
354    quota_rule2 = Trash:storage=5M
355  }
356
357Then modify the above user_query inside dovecot-sql.conf to activate
358user quotas::
359
360  user_query = SELECT path AS home, uid, gid, concat('*:storage=', quota, 'M') AS quota_rule FROM admin_mailbox WHERE full_address = '%u'
361
362Tips to serve Modoboa behind Apache2
363------------------------------------
364
365First, be sure to have apache2 and mod_python installed on your
366server.
367
368Create a new virtualhost in your Apache configuration and put the
369following inside::
370
371  <VirtualHost *:80>
372    <Location "/">
373      SetHandler mod_python
374      PythonHandler django.core.handlers.modpython
375      PythonPath "['<path to directory that contains modoboa dir>'] + sys.path"
376      SetEnv DJANGO_SETTINGS_MODULE modoboa.settings
377    </Location>
378    Alias "/static" "<path to modoboa dir>/static"
379    <Location "/static/">
380      SetHandler None
381    </Location>
382  </VirtualHost>
383
384This is one possible configuration. Note that you will certainly need more
385configuration in order to launch Apache.
386
387Using the amavisd-new quarantine plugin
388---------------------------------------
389
390This plugin allows you and your users to handle amavisd-new SQL
391quarantine. You can consult messages and/or release or delete them.
392
393If you plan to use it, first make sure to have those requirements
394installed on your server::
395
396- mysqldb python module (http://mysql-python.sourceforge.net/)
397- lxml python module (http://codespeak.net/lxml/)
398
399To activate the extension, edit your settings.py and add the following
400line inside the INSTALLED_APPS variable::
401
402  'modoboa.extensions.amavis_quarantine',
403
404Then run the following command to activate the component::
405 
406  # export PYTHONPATH=<modoboa_dir>/..
407  # DJANGO_SETTINGS_MODULE=modoboa.settings \
408      <modoboa_dir>/scripts/extension.py amavis-quarantine on
409
410Then, you need to specify where is the database that contains the
411quarantine. Inside settings.py, add a new connection to the
412DB_CONNECTIONS variable like this::
413
414  DB_CONNECTIONS = {
415    "amavis_quarantine" : {"driver"   : "mysql",
416                            "host"     : "<your_host>",
417                            "dbname"   : "<amavis_dbname>",
418                            "login"    : "<user>",
419                            "password" : "<password>"}
420  }
421     
422
423Replace values between <> with yours.
424
425When viewing messages, you can choose to display links (addresses,
426images). In order to display images correctly, you need to create a
427tmp directory under static/ for storing them. For example::
428
429  # mkdir <modoboa_dir>/static/tmp
430
431To be able to release messages, first take a look at this page::
432
433http://www.ijs.si/software/amavisd/amavisd-new-docs.html#quar-release
434
435It shows how to configure amavisd-new to listen somewhere for the
436AM.PDP protocol. This protocol is used to send release requests.
437
438Below is an example of a working configuration::
439
440  $interface_policy{'SOCK'} = 'AM.PDP-SOCK';
441  $interface_policy{'9998'} = 'AM.PDP-INET';
442
443  $policy_bank{'AM.PDP-SOCK'} = {
444    protocol => 'AM.PDP',
445    auth_required_release => 0,
446  };
447  $policy_bank{'AM.PDP-INET'} = {
448    protocol => 'AM.PDP',
449    inet_acl => [qw( 127.0.0.1 [::1] )],
450  };
451
452Don't forget to update the inet_acl list if you plan to release from
453the network.
454
455Once amavisd-new is configured, just tell Modoboa where it can find the
456"release server" by modifying following parameters in the admin panel::
457
458  # "unix" or "inet"
459  AM_PDP_MODE = "inet"
460
461  # "unix" mode only
462  AM_PDP_SOCKET = "/var/amavis/amavisd.sock"
463
464  # "inet" mode only
465  AM_PDP_HOST = "127.0.0.1"
466  AM_PDP_PORT = 9998
467
468Last point, Modoboa provides a simple script that periodically purge
469the amavisd-new quarantine database. If you plan to use it, you can
470add the following line inside root's crontab::
471
472  0 0 * * * PYTHONPATH=<modoboa_dir/..> \
473    DJANGO_SETTINGS_MODULE=modoboa.settings \
474    <modoboa_dir>/extensions/amavis_quarantine/cleanup.py
475
476Replace modoboa_dir with the installation path of Modoboa.
477
478By default, messages older than 14 days are automatically purged. You
479can modify this value by changing the MAX_MESSAGES_AGE parameter in the admin panel.
480
481Using the statistics plugin
482---------------------------
483
484This plugin allows you to collect various statistics about emails
485traffic on your server. It parses log file to collect information and
486then generates graphics in PNG format.
487
488If you plan to use it, first make sure to have those requirements
489installed on your server::
490
491- rrdtool python binding (http://oss.oetiker.ch/rrdtool/)
492
493To activate the extension, edit your settings.py and add the following
494line inside the INSTALLED_APPS variable::
495
496  'modoboa.extensions.stats',
497
498Then run the following command to activate the component::
499 
500  # export PYTHONPATH=<modoboa_dir>/..
501  # DJANGO_SETTINGS_MODULE=modoboa.settings \
502      <modoboa_dir>/scripts/extension.py stats on
503
504Then, adapt the following parameters to your environnement::
505
506  # Path to mail log file
507  LOGFILE = "/var/log/mail.log"
508
509  # Path to directory where rrd files are stored
510  RRD_ROOTDIR = "/tmp/modoboa"
511
512  # Path to directory where png files are stored
513  IMG_ROOTDIR = "<modoboa_dir>/static/graphs"
514
515Make sure the directories that will contain those files exist. If not,
516create them before going further. For example (according to previous
517parameters)::
518
519  $ mkdir /tmp/modoboa
520  $ mkdir <modoboa_dir>/static/graphs
521
522To finish, you need to collect information periodically in order to
523feed rrd files. To do so, just add the following lines into root's
524crontab::
525
526  */5 * * * * PYTHONPATH=<modoboa_dir/..> DJANGO_SETTINGS_MODULE=modoboa.settings <modoboa_dir>/scripts/stats/logparser.py
527
528Replace modoboa_dir with the installation path of Modoboa.
529
530Graphics are automatically created after each new parsing.
531
532Using the webmail component
533---------------------------
534
535Modoboa provides a simple webmail component (you can browse, read and
536compose messages).  With this feature, it is possible to deploy an almost
537standalone emails platform just with Modoboa.
538
539The following requirements are needed before going further::
540
541- lxml python module (http://codespeak.net/lxml/)
542- pycrypto python module (http://www.dlitz.net/software/pycrypto/)
543
544Just run the following command to activate the component::
545 
546  # export PYTHONPATH=<modoboa_dir>/..
547  # DJANGO_SETTINGS_MODULE=modoboa.settings \
548      <modoboa_dir>/scripts/extension.py webmail on
549
550Sometimes, inline images are integrated inside emails. To display
551them, Modoboa stores them inside a temporary folder. Make sure the
552following path exists, otherwise create it::
553
554  # mkdir <path_to_modoboa>/static/tmp
555
556The user that is running Modoboa will need the write permission inside
557this folder.
558
559Next, go to the admin panel and modify the following parameters in
560order to communicate with your IMAP and SMTP servers::
561
562  IMAP_SECURED = no
563  IMAP_SERVER = 127.0.0.1
564  IMAP_PORT = 143
565
566  SMTP_SECURED = no
567  SMTP_AUTHENTICATION = no
568  SMTP_SERVER = 127.0.0.1
569  SMTP_PORT = 25
570
571Last but not least, modify the SECRET_KEY parameter and choose a new
572value (exactly 16 characters). This key is really important, it is
573used to encrypt/decrypt user passwords stored inside sessions.
574
575Do not communicate this key to anyone!!
Note: See TracBrowser for help on using the repository browser.