xref: /netbsd-src/external/ibm-public/postfix/dist/INSTALL (revision 8feb0f0b7eaff0608f8350bbfa3098827b4bb91b)
1Postfix Installation From Source Code
2
3-------------------------------------------------------------------------------
4
51 - Purpose of this document
6
7If you are using a pre-compiled version of Postfix, you should start with
8BASIC_CONFIGURATION_README and the general documentation referenced by it.
9INSTALL is only a bootstrap document to get Postfix up and running from scratch
10with the minimal number of steps; it should not be considered part of the
11general documentation.
12
13This document describes how to build, install and configure a Postfix system so
14that it can do one of the following:
15
16  * Send mail only, without changing an existing Sendmail installation.
17  * Send and receive mail via a virtual host interface, still without any
18    change to an existing Sendmail installation.
19  * Run Postfix instead of Sendmail.
20
21Topics covered in this document:
22
23 1. Purpose of this document
24 2. Typographical conventions
25 3. Documentation
26 4. Building on a supported system
27 5. Porting Postfix to an unsupported system
28 6. Installing the software after successful compilation
29 7. Configuring Postfix to send mail only
30 8. Configuring Postfix to send and receive mail via virtual interface
31 9. Running Postfix instead of Sendmail
3210. Mandatory configuration file edits
3311. To chroot or not to chroot
3412. Care and feeding of the Postfix system
35
362 - Typographical conventions
37
38In the instructions below, a command written as
39
40    # command
41
42should be executed as the superuser.
43
44A command written as
45
46    $ command
47
48should be executed as an unprivileged user.
49
503 - Documentation
51
52Documentation is available as README files (start with the file README_FILES/
53AAAREADME), as HTML web pages (point your browser to "html/index.html") and as
54UNIX-style manual pages.
55
56You should view the README files with a pager such as more(1) or less(1),
57because the files use backspace characters in order to produce bold font. To
58print a README file without backspace characters, use the col(1) command. For
59example:
60
61    $ col -bx <file | lpr
62
63In order to view the manual pages before installing Postfix, point your MANPATH
64environment variable to the "man" subdirectory; be sure to use an absolute
65path.
66
67    $ export MANPATH; MANPATH="`pwd`/man:$MANPATH"
68    $ setenv MANPATH "`pwd`/man:$MANPATH"
69
70Of particular interest is the postconf(5) manual page that lists all the 500+
71configuration parameters. The HTML version of this text makes it easy to
72navigate around.
73
74All Postfix source files have their own built-in manual page. Tools to extract
75those embedded manual pages are available in the mantools directory.
76
774 - Building on a supported system
78
79Postfix development happens on FreeBSD and MacOS X, with regular tests on Linux
80(Fedora, Ubuntu) and Solaris. Support for other systems relies on feedback from
81their users, and may not always be up-to-date.
82
83OpenBSD is partially supported. The libc resolver does not implement the
84documented "internal resolver options which are [...] set by changing fields in
85the _res structure" (documented in the OpenBSD 5.6 resolver(3) manpage). This
86results in too many DNS queries, and false positives for queries that should
87fail.
88
89Overview of topics:
90
91  * 4.1 - Getting started
92  * 4.2 - What compiler to use
93  * 4.3 - Building with Postfix position-independent executables (Postfix >=
94    3.0)
95  * 4.4 - Building with Postfix dynamically-linked libraries and database
96    plugins (Postfix >= 3.0)
97  * 4.5 - Building with optional features
98  * 4.6 - Overriding built-in parameter default settings
99  * 4.7 - Overriding other compile-time features
100  * 4.8 - Support for thousands of processes
101  * 4.9 - Compiling Postfix, at last
102
1034.1 - Getting started
104
105On Solaris, the "make" command and other development utilities are in /usr/ccs/
106bin, so you MUST have /usr/ccs/bin in your command search path. If these files
107do not exist, you need to install the development packages first.
108
109If you need to build Postfix for multiple architectures from a single source-
110code tree, use the "lndir" command to build a shadow tree with symbolic links
111to the source files.
112
113If at any time in the build process you get messages like: "make: don't know
114how to ..." you should be able to recover by running the following command from
115the Postfix top-level directory:
116
117    $ make -f Makefile.init makefiles
118
119If you copied the Postfix source code after building it on another machine, it
120is a good idea to cd into the top-level directory and first do this:
121
122    $ make tidy
123
124This will get rid of any system dependencies left over from compiling the
125software elsewhere.
126
1274.2 - What compiler to use
128
129To build with GCC, or with the native compiler if people told me that is better
130for your system, just cd into the top-level Postfix directory of the source
131tree and type:
132
133    $ make
134
135To build with a non-default compiler, you need to specify the name of the
136compiler. Here are a few examples:
137
138    $ make makefiles CC=/opt/SUNWspro/bin/cc	    (Solaris)
139    $ make
140
141    $ make makefiles CC="/opt/ansic/bin/cc -Ae"     (HP-UX)
142    $ make
143
144    $ make makefiles CC="purify cc"
145    $ make
146
147and so on. In some cases, optimization will be turned off automatically.
148
1494.3 - Building with Postfix position-independent executables (Postfix >= 3.0)
150
151On some systems Postfix can be built with Position-Independent Executables. PIE
152is used by the ASLR exploit mitigation technique (ASLR = Address-Space Layout
153Randomization):
154
155    $ make makefiles pie=yes ...other arguments...
156
157(Specify "make makefiles pie=no" to explicitly disable Postfix position-
158independent executable support).
159
160Postfix PIE support appears to work on Fedora Core 20, Ubuntu 14.04, FreeBSD 9
161and 10, and NetBSD 6 (all with the default system compilers).
162
163Whether the "pie=yes" above has any effect depends on the compiler. Some
164compilers always produce PIE executables, and some may even complain that the
165Postfix build option is redundant.
166
1674.4 - Building with Postfix dynamically-linked libraries and database plugins
168(Postfix >= 3.0)
169
170Postfix dynamically-linked library and database plugin support exists for
171recent versions of Linux, FreeBSD and MacOS X. Dynamically-linked library
172builds may become the default at some point in the future.
173
174Overview of topics:
175
176  * 4.4.1 Turning on Postfix dynamically-linked library support
177  * 4.4.2 Turning on Postfix database-plugin support
178  * 4.4.3 Customizing Postfix dynamically-linked libraries and database plugins
179  * 4.4.4 Tips for distribution maintainers
180
181Note: directories with Postfix dynamically-linked libraries or database plugins
182should contain only postfix-related files. Postfix dynamically-linked libraries
183and database plugins should not be installed in a "public" system directory
184such as /usr/lib or /usr/local/lib. Linking Postfix dynamically-linked library
185or database-plugin files into non-Postfix programs is not supported. Postfix
186dynamically-linked libraries and database plugins implement a Postfix-internal
187API that changes without maintaining compatibility.
188
1894.4.1 Turning on Postfix dynamically-linked library support
190
191Postfix can be built with Postfix dynamically-linked libraries (files typically
192named libpostfix-*.so). Postfix dynamically-linked libraries add minor run-time
193overhead and result in significantly-smaller Postfix executable files.
194
195Specify "shared=yes" on the "make makefiles" command line to build Postfix with
196dynamically-linked library support.
197
198    $ make makefiles shared=yes ...other arguments...
199    $ make
200
201(Specify "make makefiles shared=no" to explicitly disable Postfix dynamically-
202linked library support).
203
204This installs dynamically-linked libraries in $shlib_directory, typically /usr/
205lib/postfix or /usr/local/lib/postfix, with file names libpostfix-name.so,
206where the name is a source-code directory name such as "util" or "global".
207
208See section 4.4.3 "Customizing Postfix dynamically-linked libraries and
209database plugins" below for how to customize the Postfix dynamically-linked
210library location, including support to upgrade a running mail system safely.
211
2124.4.2 Turning on Postfix database-plugin support
213
214Additionally, Postfix can be built to support dynamic loading of Postfix
215database clients (database plugins) with the Debian-style dynamicmaps feature.
216Postfix 3.0 supports dynamic loading of cdb:, ldap:, lmdb:, mysql:, pcre:,
217pgsql:, sdbm:, and sqlite: database clients. Dynamic loading is useful when you
218distribute or install pre-compiled Postfix packages.
219
220Specify "dynamicmaps=yes" on the "make makefiles" command line to build Postfix
221with support to dynamically load Postfix database clients with the Debian-style
222dynamicmaps feature.
223
224    $ make makefiles dynamicmaps=yes ...other arguments...
225    $ make
226
227(Specify "make makefiles dynamicmaps=no" to explicitly disable Postfix
228database-plugin support).
229
230This implicitly enables dynamically-linked library support, installs the
231configuration file dynamicmaps.cf in $meta_directory (usually, /etc/postfix or
232/usr/local/etc/postfix), and installs database plugins in $shlib_directory (see
233above). Database plugins are named postfix-type.so where the type is a database
234type such as "cdb" or "ldap".
235
236    NOTE: The Postfix 3.0 build procedure expects that you specify database
237    library dependencies with variables named AUXLIBS_CDB, AUXLIBS_LDAP, etc.
238    With Postfix 3.0 and later, the old AUXLIBS variable still supports
239    building a statically-loaded database client, but only the new AUXLIBS_CDB
240    etc. variables support building a dynamically-loaded or statically-loaded
241    CDB etc. database client. See CDB_README, LDAP_README, etc. for details.
242
243    Failure to follow this advice will defeat the purpose of dynamic database
244    client loading. Every Postfix executable file will have database library
245    dependencies. And that was exactly what dynamic database client loading was
246    meant to avoid.
247
248See the next section for how to customize the location and version of Postfix
249database plugins and the location of the file dynamicmaps.cf.
250
2514.4.3 Customizing Postfix dynamically-linked libraries and database plugins
252
253Customizing build-time and run-time options for Postfix dynamically-linked
254libraries and database plugins
255
256The build-time environment variables SHLIB_CFLAGS, SHLIB_RPATH, and
257SHLIB_SUFFIX provide control over how Postfix libraries and plugins are
258compiled, linked, and named.
259
260    $ make makefiles SHLIB_CFLAGS=flags SHLIB_RPATH=rpath SHLIB_SUFFIX=suffix
261    ...other arguments...
262    $ make
263
264See section 4.7 "Overriding other compile-time features" below for details.
265
266Customizing the location of Postfix dynamically-linked libraries and database
267plugins
268
269As a reminder, the directories with Postfix dynamically-linked libraries or
270database plugins should contain only Postfix-related files. Linking these files
271into other programs is not supported.
272
273To override the default location of Postfix dynamically-linked libraries and
274database plugins specify, for example:
275
276    $ make makefiles shared=yes shlib_directory=/usr/local/lib/postfix ...
277
278If you intend to upgrade Postfix without stopping the mail system, then you
279should append the Postfix release version to the shlib_directory pathname, to
280eliminate the possibility that programs will link with dynamically-linked
281libraries or database plugins from the wrong Postfix version. For example:
282
283    $ make makefiles shared=yes \
284	shlib_directory=/usr/local/lib/postfix/MAIL_VERSION ...
285
286The command "make makefiles name=value..." will replace the string MAIL_VERSION
287at the end of a configuration parameter value with the Postfix release version.
288Do not try to specify something like $mail_version on this command line. This
289produces inconsistent results with different versions of the make(1) command.
290
291You can change the shlib_directory setting after Postfix is built, with "make
292install" or "make upgrade". However, you may have to run ldconfig if you change
293shlib_directory after Postfix is built (the symptom is that Postfix programs
294fail because the run-time linker cannot find the files libpostfix-*.so). No
295ldconfig command is needed if you keep the files libpostfix-*.so in the
296compiled-in default $shlib_directory location.
297
298    # make upgrade shlib_directory=/usr/local/lib/postfix ...
299    # make install shlib_directory=/usr/local/lib/postfix ...
300
301To append the Postfix release version to the pathname if you intend to upgrade
302Postfix without stopping the mail system:
303
304    # make upgrade shlib_directory=/usr/local/lib/postfix/MAIL_VERSION ...
305    # make install shlib_directory=/usr/local/lib/postfix/MAIL_VERSION ...
306
307See also the comments above for appending MAIL_VERSION with the "make
308makefiles" command.
309
310Customizing the location of dynamicmaps.cf and other files
311
312The meta_directory parameter has the same default setting as the
313config_directory parameter, typically /etc/postfix or /usr/local/etc/postfix.
314
315You can override the default meta_directory location at compile time or after
316Postfix is built. To override the default location at compile time specify, for
317example:
318
319    % make makefiles meta_directory=/usr/libexec/postfix ...
320
321Here is a tip if you want to make a pathname dependent on the Postfix release
322version: the command "make makefiles name=value..." will replace the string
323MAIL_VERSION at the end of a configuration parameter value with the Postfix
324release version. Do not try to specify something like $mail_version on this
325command line. This produces inconsistent results with different versions of the
326make(1) command.
327
328You can override the meta_directory setting after Postfix is built, with "make
329install" or "make upgrade".
330
331    # make upgrade meta_directory=/usr/libexec/postfix ...
332    # make install meta_directory=/usr/libexec/postfix ...
333
334As with the command "make makefiles", the command "make install/upgrade
335name=value..." will replace the string MAIL_VERSION at the end of a
336configuration parameter value with the Postfix release version. Do not try to
337specify something like $mail_version on this command line. This produces
338inconsistent results with different versions of the make(1) command.
339
3404.4.4 Tips for distribution maintainers
341
342  * The shlib_directory parameter setting also provides the default directory
343    for database plugin files with a relative pathname in the file
344    dynamicmaps.cf.
345
346  * The meta_directory parameter specifies the location of the files
347    dynamicmaps.cf, postfix-files, and some multi-instance template files. The
348    meta_directory parameter has the same default value as the config_directory
349    parameter (typically, /etc/postfix or /usr/local/etc/postfix). For
350    backwards compatibility with Postfix 2.6 .. 2.11, specify "meta_directory =
351    $daemon_directory" in main.cf before installing or upgrading Postfix, or
352    specify "meta_directory = /path/name" on the "make makefiles", "make
353    install" or "make upgrade" command line.
354
355  * The configuration file dynamicmaps.cf will automatically include files
356    under the directory dynamicmaps.cf.d, just like the configuration file
357    postfix-files will automatically include files under the directory postfix-
358    files.d. Thanks to this, you can install or deinstall a database plugin
359    package without having to edit postfix-files or dynamicmaps.cf. Instead,
360    you give that plugin its own configuration files under dynamicmaps.cf.d and
361    postfix-files.d, and you add or remove those configuration files along with
362    the database plugin dynamically-linked object.
363
364  * Each configuration file under the directory dynamicmaps.cf.d must have the
365    same format as the configuration file dynamicmaps.cf. There is no
366    requirement that these configuration file *names* have a specific format.
367
368  * Each configuration file under the directory postfix-files.d must have the
369    same format as the configuration file postfix-files. There is no
370    requirement that these configuration file *names* have a specific format.
371
3724.5 - Building with optional features
373
374By default, Postfix builds as a mail system with relatively few bells and
375whistles. Support for third-party databases etc. must be configured when
376Postfix is compiled. The following documents describe how to build Postfix with
377support for optional features:
378
379     _____________________________________________________________
380    |Optional feature		       |Document     |Availability|
381    |__________________________________|_____________|____________|
382    |Berkeley DB database	       |DB_README    |Postfix 1.0 |
383    |__________________________________|_____________|____________|
384    |LMDB database		       |LMDB_README  |Postfix 2.11|
385    |__________________________________|_____________|____________|
386    |LDAP database		       |LDAP_README  |Postfix 1.0 |
387    |__________________________________|_____________|____________|
388    |MySQL database		       |MYSQL_README |Postfix 1.0 |
389    |__________________________________|_____________|____________|
390    |Perl compatible regular expression|PCRE_README  |Postfix 1.0 |
391    |__________________________________|_____________|____________|
392    |PostgreSQL database	       |PGSQL_README |Postfix 2.0 |
393    |__________________________________|_____________|____________|
394    |SASL authentication	       |SASL_README  |Postfix 1.0 |
395    |__________________________________|_____________|____________|
396    |SQLite database		       |SQLITE_README|Postfix 2.8 |
397    |__________________________________|_____________|____________|
398    |STARTTLS session encryption       |TLS_README   |Postfix 2.2 |
399    |__________________________________|_____________|____________|
400
401Note: IP version 6 support is compiled into Postfix on operating systems that
402have IPv6 support. See the IPV6_README file for details.
403
4044.6 - Overriding built-in parameter default settings
405
4064.6.1 - Postfix 3.0 and later
407
408All Postfix configuration parameters can be changed by editing a Postfix
409configuration file, except for one: the parameter that specifies the location
410of Postfix configuration files. In order to build Postfix with a configuration
411directory other than /etc/postfix, use:
412
413    $ make makefiles config_directory=/some/where ...other arguments...
414    $ make
415
416The command "make makefiles name=value ..." will replace the string
417MAIL_VERSION at the end of a configuration parameter value with the Postfix
418release version. Do not try to specify something like $mail_version on this
419command line. This produces inconsistent results with different versions of the
420make(1) command.
421
422Parameters whose defaults can be specified in this way are listed below. See
423the postconf(5) manpage for a description (command: "nroff -man man/man5/
424postconf.5 | less").
425
426     __________________________________________
427    |parameter name	  |typical default     |
428    |_____________________|____________________|
429    |command_directory	  |/usr/sbin	       |
430    |_____________________|____________________|
431    |config_directory	  |/etc/postfix        |
432    |_____________________|____________________|
433    |default_database_type|hash 	       |
434    |_____________________|____________________|
435    |daemon_directory	  |/usr/libexec/postfix|
436    |_____________________|____________________|
437    |data_directory	  |/var/lib/postfix    |
438    |_____________________|____________________|
439    |html_directory	  |no		       |
440    |_____________________|____________________|
441    |mail_spool_directory |/var/mail	       |
442    |_____________________|____________________|
443    |mailq_path 	  |/usr/bin/mailq      |
444    |_____________________|____________________|
445    |manpage_directory	  |/usr/local/man      |
446    |_____________________|____________________|
447    |meta_directory	  |/etc/postfix        |
448    |_____________________|____________________|
449    |newaliases_path	  |/usr/bin/newaliases |
450    |_____________________|____________________|
451    |openssl_path	  |openssl	       |
452    |_____________________|____________________|
453    |queue_directory	  |/var/spool/postfix  |
454    |_____________________|____________________|
455    |readme_directory	  |no		       |
456    |_____________________|____________________|
457    |sendmail_path	  |/usr/sbin/sendmail  |
458    |_____________________|____________________|
459    |shlib_directory	  |/usr/lib/postfix    |
460    |_____________________|____________________|
461
4624.6.2 - All Postfix versions
463
464All Postfix configuration parameters can be changed by editing a Postfix
465configuration file, except for one: the parameter that specifies the location
466of Postfix configuration files. In order to build Postfix with a configuration
467directory other than /etc/postfix, use:
468
469    $ make makefiles CCARGS='-DDEF_CONFIG_DIR=\"/some/where\"'
470    $ make
471
472IMPORTANT: Be sure to get the quotes right. These details matter a lot.
473
474Parameters whose defaults can be specified in this way are listed below. See
475the postconf(5) manpage for a description (command: "nroff -man man/man5/
476postconf.5 | less").
477
478     ____________________________________________________________
479    |Macro name       |default value for    |typical default	 |
480    |_________________|_____________________|____________________|
481    |DEF_COMMAND_DIR  |command_directory    |/usr/sbin		 |
482    |_________________|_____________________|____________________|
483    |DEF_CONFIG_DIR   |config_directory     |/etc/postfix	 |
484    |_________________|_____________________|____________________|
485    |DEF_DB_TYPE      |default_database_type|hash		 |
486    |_________________|_____________________|____________________|
487    |DEF_DAEMON_DIR   |daemon_directory     |/usr/libexec/postfix|
488    |_________________|_____________________|____________________|
489    |DEF_DATA_DIR     |data_directory	    |/var/lib/postfix	 |
490    |_________________|_____________________|____________________|
491    |DEF_MAILQ_PATH   |mailq_path	    |/usr/bin/mailq	 |
492    |_________________|_____________________|____________________|
493    |DEF_HTML_DIR     |html_directory	    |no 		 |
494    |_________________|_____________________|____________________|
495    |DEF_MANPAGE_DIR  |manpage_directory    |/usr/local/man	 |
496    |_________________|_____________________|____________________|
497    |DEF_NEWALIAS_PATH|newaliases_path	    |/usr/bin/newaliases |
498    |_________________|_____________________|____________________|
499    |DEF_QUEUE_DIR    |queue_directory	    |/var/spool/postfix  |
500    |_________________|_____________________|____________________|
501    |DEF_README_DIR   |readme_directory     |no 		 |
502    |_________________|_____________________|____________________|
503    |DEF_SENDMAIL_PATH|sendmail_path	    |/usr/sbin/sendmail  |
504    |_________________|_____________________|____________________|
505
506Note: the data_directory parameter (for caches and pseudo-random numbers) was
507introduced with Postfix version 2.5.
508
5094.7 - Overriding other compile-time features
510
511The general method to override Postfix compile-time features is as follows:
512
513    $ make makefiles name=value name=value...
514    $ make
515
516The following is an extensive list of names and values.
517
518 _____________________________________________________________________________
519|Name/Value			|Description				      |
520|_______________________________|_____________________________________________|
521|				|Specifies one or more non-default object     |
522|				|libraries. Postfix 3.0 and later specify some|
523|				|of their database library dependencies with  |
524|AUXLIBS="object_library..."	|AUXLIBS_CDB, AUXLIBS_LDAP, AUXLIBS_LMDB,     |
525|				|AUXLIBS_MYSQL, AUXLIBS_PCRE, AUXLIBS_PGSQL,  |
526|				|AUXLIBS_SDBM, and AUXLIBS_SQLITE,	      |
527|				|respectively.				      |
528|_______________________________|_____________________________________________|
529|CC=compiler_command		|Specifies a non-default compiler. On many    |
530|				|systems, the default is gcc.		      |
531|_______________________________|_____________________________________________|
532|				|Specifies non-default compiler arguments, for|
533|CCARGS="compiler_arguments..." |example, a non-default include directory. The|
534|				|following directives turn off Postfix	      |
535|				|features at compile time:		      |
536|_______________________________|_____________________________________________|
537||				|Do not build with Berkeley DB support. By    |
538||				|default, Berkeley DB support is compiled in  |
539||-DNO_DB			|on platforms that are known to support this  |
540||				|feature. If you override this, then you      |
541||				|probably should also override DEF_DB_TYPE as |
542||				|described in section 4.6.		      |
543||______________________________|_____________________________________________|
544||-DNO_DNSSEC			|Do not build with DNSSEC support, even if the|
545||				|resolver library appears to support it.      |
546||______________________________|_____________________________________________|
547||				|Do not build with Solaris /dev/poll support. |
548||-DNO_DEVPOLL			|By default, /dev/poll support is compiled in |
549||				|on Solaris versions that are known to support|
550||				|this feature.				      |
551||______________________________|_____________________________________________|
552||				|Do not build with Linux EPOLL support. By    |
553||-DNO_EPOLL			|default, EPOLL support is compiled in on     |
554||				|platforms that are known to support this     |
555||				|feature.				      |
556||______________________________|_____________________________________________|
557||				|Do not build with EAI (SMTPUTF8) support. By |
558||-DNO_EAI			|default, EAI support is compiled in when the |
559||				|"icuuc" library and header files are found.  |
560||______________________________|_____________________________________________|
561||				|Do not require support for C99 "inline"      |
562||				|functions. Instead, implement argument       |
563||-DNO_INLINE			|typechecks for non-printf/scanf-like	      |
564||				|functions with ternary operators and	      |
565||				|unreachable code.			      |
566||______________________________|_____________________________________________|
567||				|Do not build with IPv6 support. By default,  |
568||				|IPv6 support is compiled in on platforms that|
569||				|are known to have IPv6 support. Note: this   |
570||-DNO_IPV6			|directive is for debugging And testing only. |
571||				|It is not guaranteed to work on all	      |
572||				|platforms. If you don't want IPv6 support,   |
573||				|set "inet_protocols = ipv4" in main.cf.      |
574||______________________________|_____________________________________________|
575||				|Do not build with FreeBSD / NetBSD / OpenBSD |
576||-DNO_KQUEUE			|/ MacOSX KQUEUE support. By default, KQUEUE  |
577||				|support is compiled in on platforms that are |
578||				|known to support it.			      |
579||______________________________|_____________________________________________|
580||				|Do not build with NIS or NISPLUS support. NIS|
581||-DNO_NIS			|is not available on some recent Linux	      |
582||				|distributions. 			      |
583||______________________________|_____________________________________________|
584||				|Do not build with NISPLUS support. NISPLUS is|
585||-DNO_NISPLUS			|not available on some recent Solaris	      |
586||				|distributions. 			      |
587||______________________________|_____________________________________________|
588||				|Do not build with PCRE support. By default,  |
589||-DNO_PCRE			|PCRE support is compiled in when the pcre-   |
590||				|config utility is installed.		      |
591||______________________________|_____________________________________________|
592||				|Disable support for POSIX getpwnam_r/	      |
593||-DNO_POSIX_GETPW_R		|getpwuid_r. By default Postfix uses these    |
594||				|where they are known to be available.	      |
595||______________________________|_____________________________________________|
596||-DNO_RES_NCALLS		|Do not build with the threadsafe resolver(5) |
597||				|API (res_ninit() etc.).		      |
598||______________________________|_____________________________________________|
599||				|Use setjmp()/longjmp() instead of sigsetjmp  |
600||-DNO_SIGSETJMP		|()/siglongjmp(). By default, Postfix uses    |
601||				|sigsetjmp()/siglongjmp() when they are known |
602||				|to be available.			      |
603||______________________________|_____________________________________________|
604||				|Use sprintf() instead of snprintf(). By      |
605||-DNO_SNPRINTF 		|default, Postfix uses snprintf() except on   |
606||				|ancient systems.			      |
607||______________________________|_____________________________________________|
608|				|Specifies a non-default compiler debugging   |
609|DEBUG=debug_level		|level. The default is "-g". Specify DEBUG= to|
610|				|turn off debugging.			      |
611|_______________________________|_____________________________________________|
612|				|Specifies a non-default optimization level.  |
613|OPT=optimization_level 	|The default is "-O". Specify OPT= to turn off|
614|				|optimization.				      |
615|_______________________________|_____________________________________________|
616|				|Specifies options for the postfix-install    |
617|POSTFIX_INSTALL_OPTS=-option...|command, separated by whitespace. Currently, |
618|				|the only supported option is "-keep-build-   |
619|				|mtime".				      |
620|_______________________________|_____________________________________________|
621|				|Specifies non-default compiler options for   |
622|SHLIB_CFLAGS=flags		|building Postfix dynamically-linked libraries|
623|				|and database plugins. The typical default is |
624|				|"-fPIC".				      |
625|_______________________________|_____________________________________________|
626|				|Specifies a non-default runpath for Postfix  |
627|SHLIB_RPATH=rpath		|dynamically-linked libraries. The typical    |
628|				|default is "'-Wl,-rpath,${SHLIB_DIR}'".      |
629|_______________________________|_____________________________________________|
630|				|Specifies a non-default suffix for Postfix   |
631|SHLIB_SUFFIX=suffix		|dynamically-linked libraries and database    |
632|				|plugins. The typical default is ".so".       |
633|_______________________________|_____________________________________________|
634|				|Specifies non-default compiler warning       |
635|WARN="warning_flags..."	|options for use when "make" is invoked in a  |
636|				|source subdirectory only.		      |
637|_______________________________|_____________________________________________|
638
6394.8 - Support for thousands of processes
640
641The number of connections that Postfix can manage simultaneously is limited by
642the number of processes that it can run. This number in turn is limited by the
643number of files and sockets that a single process can open. For example, the
644Postfix queue manager has a separate connection to each delivery process, and
645the anvil(8) server has one connection per smtpd(8) process.
646
647Postfix version 2.4 and later have no built-in limits on the number of open
648files or sockets, when compiled on systems that support one of the following:
649
650  * BSD kqueue(2) (FreeBSD 4.1, NetBSD 2.0, OpenBSD 2.9),
651  * Solaris 8 /dev/poll,
652  * Linux 2.6 epoll(4).
653
654With other Postfix versions or operating systems, the number of file
655descriptors per process is limited by the value of the FD_SETSIZE macro. If you
656expect to run more than 1000 mail delivery processes, you may need to override
657the definition of the FD_SETSIZE macro to make select() work correctly:
658
659    $ make makefiles CCARGS=-DFD_SETSIZE=2048
660
661Warning: the above has no effect on some Linux versions. Apparently, on these
662systems the FD_SETSIZE value can be changed only by using undocumented
663interfaces. Currently, that means including <bits/types.h> directly (which is
664not allowed) and overriding the __FD_SETSIZE macro. Beware, undocumented
665interfaces can change at any time and without warning.
666
667But wait, there is more: none of this will work unless the operating system is
668configured to handle thousands of connections. See the TUNING_README guide for
669examples of how to increase the number of open sockets or files.
670
6714.9 - Compiling Postfix, at last
672
673If the command
674
675    $ make
676
677is successful, then you can proceed to install Postfix (section 6).
678
679If the command produces compiler error messages, it may be time to search the
680web or to ask the postfix-users@postfix.org mailing list, but be sure to search
681the mailing list archives first. Some mailing list archives are linked from
682http://www.postfix.org/.
683
6845 - Porting Postfix to an unsupported system
685
686Each system type that Postfix knows is identified by a unique name. Examples:
687SUNOS5, FREEBSD4, and so on. When porting Postfix to a new system, the first
688step is to choose a SYSTEMTYPE name for the new system. You must use a name
689that includes at least the major version of the operating system (such as
690SUNOS4 or LINUX2), so that different releases of the same system can be
691supported without confusion.
692
693Add a case statement to the "makedefs" shell script in the source code top-
694level directory that recognizes the new system reliably, and that emits the
695right system-specific information. Be sure to make the code robust against user
696PATH settings; if the system offers multiple UNIX flavors (e.g. BSD and SYSV)
697be sure to build for the native flavor, instead of the emulated one.
698
699Add an "#ifdef SYSTEMTYPE" section to the central util/sys_defs.h include file.
700You may have to invent new feature macro names. Please choose sensible feature
701macro names such as HAS_DBM or FIONREAD_IN_SYS_FILIO_H.
702
703I strongly recommend against using "#ifdef SYSTEMTYPE" in individual source
704files. While this may look like the quickest solution, it will create a mess
705when newer versions of the same SYSTEMTYPE need to be supported. You're likely
706to end up placing "#ifdef" sections all over the source code again.
707
7086 - Installing the software after successful compilation
709
710This text describes how to install Postfix from source code. See the
711PACKAGE_README file if you are building a package for distribution to other
712systems.
713
7146.1 - Save existing Sendmail binaries
715
716IMPORTANT: if you are REPLACING an existing Sendmail installation with Postfix,
717you may need to keep the old sendmail program running for some time in order to
718flush the mail queue.
719
720  * Some systems implement a mail switch mechanism where different MTAs
721    (Postfix, Sendmail, etc.) can be installed at the same time, while only one
722    of them is actually being used. Examples of such switching mechanisms are
723    the FreeBSD mailwrapper(8) or the Linux mail switch. In this case you
724    should try to "flip" the switch to "Postfix" before installing Postfix.
725
726  * If your system has no mail switch mechanism, execute the following commands
727    (your sendmail, newaliases and mailq programs may be in a different place):
728
729    # mv /usr/sbin/sendmail /usr/sbin/sendmail.OFF
730    # mv /usr/bin/newaliases /usr/bin/newaliases.OFF
731    # mv /usr/bin/mailq /usr/bin/mailq.OFF
732    # chmod 755 /usr/sbin/sendmail.OFF /usr/bin/newaliases.OFF \
733	/usr/bin/mailq.OFF
734
7356.2 - Create account and groups
736
737Before you install Postfix for the first time you need to create an account and
738a group:
739
740  * Create a user account "postfix" with a user id and group id that are not
741    used by any other user account. Preferably, this is an account that no-one
742    can log into. The account does not need an executable login shell, and
743    needs no existing home directory. My password and group file entries look
744    like this:
745
746	/etc/passwd:
747	    postfix:*:12345:12345:postfix:/no/where:/no/shell
748
749	/etc/group:
750	    postfix:*:12345:
751
752    Note: there should be no whitespace before "postfix:".
753
754  * Create a group "postdrop" with a group id that is not used by any other
755    user account. Not even by the postfix user account. My group file entry
756    looks like:
757
758	/etc/group:
759	    postdrop:*:54321:
760
761    Note: there should be no whitespace before "postdrop:".
762
7636.3 - Install Postfix
764
765To install or upgrade Postfix from compiled source code, run one of the
766following commands as the super-user:
767
768    # make install	 (interactive version, first time install)
769
770    # make upgrade	 (non-interactive version, for upgrades)
771
772  * The interactive version ("make install") asks for pathnames for Postfix
773    data and program files, and stores your preferences in the main.cf file. If
774    you don't want Postfix to overwrite non-Postfix "sendmail", "mailq" and
775    "newaliases" files, specify pathnames that end in ".postfix".
776
777  * The non-interactive version ("make upgrade") needs the /etc/postfix/main.cf
778    file from a previous installation. If the file does not exist, use
779    interactive installation ("make install") instead.
780
781  * If you specify name=value arguments on the "make install" or "make upgrade"
782    command line, then these will take precedence over compiled-in default
783    settings or main.cf settings.
784
785    The command "make install/upgrade name=value ..." will replace the string
786    MAIL_VERSION at the end of a configuration parameter value with the Postfix
787    release version. Do not try to specify something like $mail_version on this
788    command line. This produces inconsistent results with different versions of
789    the make(1) command.
790
7916.4 - Configure Postfix
792
793Proceed to the section on how you wish to run Postfix on your particular
794machine:
795
796  * Send mail only, without changing an existing Sendmail installation (section
797    7).
798
799  * Send and receive mail via a virtual host interface, still without any
800    change to an existing Sendmail installation (section 8).
801
802  * Run Postfix instead of Sendmail (section 9).
803
8047 - Configuring Postfix to send mail only
805
806If you are going to use Postfix to send mail only, there is no need to change
807your existing sendmail setup. Instead, set up your mail user agent so that it
808calls the Postfix sendmail program directly.
809
810Follow the instructions in the "Mandatory configuration file edits" in section
81110, and review the "To chroot or not to chroot" text in section 11.
812
813You MUST comment out the "smtp inet" entry in /etc/postfix/master.cf, in order
814to avoid conflicts with the real sendmail. Put a "#" character in front of the
815line that defines the smtpd service:
816
817    /etc/postfix/master.cf:
818	#smtp	   inet  n	 -	 n	 -	 -	 smtpd
819
820Start the Postfix system:
821
822    # postfix start
823
824or, if you feel nostalgic, use the Postfix sendmail command:
825
826    # sendmail -bd -qwhatever
827
828and watch your maillog file for any error messages. The pathname is /var/log/
829maillog, /var/log/mail, /var/log/syslog, or something else. Typically, the
830pathname is defined in the /etc/syslog.conf file.
831
832    $ egrep '(reject|warning|error|fatal|panic):' /some/log/file
833
834Note: the most important error message is logged first. Later messages are not
835as useful.
836
837In order to inspect the mail queue, use one of the following commands:
838
839    $ mailq
840
841    $ sendmail -bp
842
843    $ postqueue -p
844
845See also the "Care and feeding" section 12 below.
846
8478 - Configuring Postfix to send and receive mail via virtual interface
848
849Alternatively, you can use the Postfix system to send AND receive mail while
850leaving your Sendmail setup intact, by running Postfix on a virtual interface
851address. Simply configure your mail user agent to directly invoke the Postfix
852sendmail program.
853
854To create a virtual network interface address, study your system ifconfig
855manual page. The command syntax could be any of:
856
857    # ifconfig le0:1 <address> netmask <mask> up
858    # ifconfig en0 alias <address> netmask 255.255.255.255
859
860In the /etc/postfix/main.cf file, I would specify
861
862    /etc/postfix/main.cf:
863	myhostname = virtual.host.tld
864	inet_interfaces = $myhostname
865	mydestination = $myhostname
866
867Follow the instructions in the "Mandatory configuration file edits" in section
86810, and review the "To chroot or not to chroot" text in section 11.
869
870Start the Postfix system:
871
872    # postfix start
873
874or, if you feel nostalgic, use the Postfix sendmail command:
875
876    # sendmail -bd -qwhatever
877
878and watch your maillog file for any error messages. The pathname is /var/log/
879maillog, /var/log/mail, /var/log/syslog, or something else. Typically, the
880pathname is defined in the /etc/syslog.conf file.
881
882    $ egrep '(reject|warning|error|fatal|panic):' /some/log/file
883
884Note: the most important error message is logged first. Later messages are not
885as useful.
886
887In order to inspect the mail queue, use one of the following commands:
888
889    $ mailq
890
891    $ sendmail -bp
892
893    $ postqueue -p
894
895See also the "Care and feeding" section 12 below.
896
8979 - Running Postfix instead of Sendmail
898
899Prior to installing Postfix you should save any existing sendmail program files
900as described in section 6. Be sure to keep the old sendmail running for at
901least a couple days to flush any unsent mail. To do so, stop the sendmail
902daemon and restart it as:
903
904    # /usr/sbin/sendmail.OFF -q
905
906Note: this is old sendmail syntax. Newer versions use separate processes for
907mail submission and for running the queue.
908
909After you have visited the "Mandatory configuration file edits" section below,
910you can start the Postfix system with:
911
912    # postfix start
913
914or, if you feel nostalgic, use the Postfix sendmail command:
915
916    # sendmail -bd -qwhatever
917
918and watch your maillog file for any error messages. The pathname is /var/log/
919maillog, /var/log/mail, /var/log/syslog, or something else. Typically, the
920pathname is defined in the /etc/syslog.conf file.
921
922    $ egrep '(reject|warning|error|fatal|panic):' /some/log/file
923
924Note: the most important error message is logged first. Later messages are not
925as useful.
926
927In order to inspect the mail queue, use one of the following commands:
928
929    $ mailq
930
931    $ sendmail -bp
932
933    $ postqueue -p
934
935See also the "Care and feeding" section 12 below.
936
93710 - Mandatory configuration file edits
938
939Note: the material covered in this section is covered in more detail in the
940BASIC_CONFIGURATION_README document. The information presented below is
941targeted at experienced system administrators.
942
94310.1 - Postfix configuration files
944
945By default, Postfix configuration files are in /etc/postfix. The two most
946important files are main.cf and master.cf; these files must be owned by root.
947Giving someone else write permission to main.cf or master.cf (or to their
948parent directories) means giving root privileges to that person.
949
950In /etc/postfix/main.cf, you will have to set up a minimal number of
951configuration parameters. Postfix configuration parameters resemble shell
952variables, with two important differences: the first one is that Postfix does
953not know about quotes like the UNIX shell does.
954
955You specify a configuration parameter as:
956
957    /etc/postfix/main.cf:
958	parameter = value
959
960and you use it by putting a "$" character in front of its name:
961
962    /etc/postfix/main.cf:
963	other_parameter = $parameter
964
965You can use $parameter before it is given a value (that is the second main
966difference with UNIX shell variables). The Postfix configuration language uses
967lazy evaluation, and does not look at a parameter value until it is needed at
968runtime.
969
970Whenever you make a change to the main.cf or master.cf file, execute the
971following command in order to refresh a running mail system:
972
973    # postfix reload
974
97510.2 - Default domain for unqualified addresses
976
977First of all, you must specify what domain will be appended to an unqualified
978address (i.e. an address without @domain.tld). The "myorigin" parameter
979defaults to the local hostname, but that is probably OK only for very small
980sites.
981
982Some examples (use only one):
983
984    /etc/postfix/main.cf:
985	myorigin = $myhostname	  (send mail as "user@$myhostname")
986	myorigin = $mydomain	  (send mail as "user@$mydomain")
987
98810.3 - What domains to receive locally
989
990Next you need to specify what mail addresses Postfix should deliver locally.
991
992Some examples (use only one):
993
994    /etc/postfix/main.cf:
995	mydestination = $myhostname, localhost.$mydomain, localhost
996	mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
997	mydestination = $myhostname
998
999The first example is appropriate for a workstation, the second is appropriate
1000for the mailserver for an entire domain. The third example should be used when
1001running on a virtual host interface.
1002
100310.4 - Proxy/NAT interface addresses
1004
1005The proxy_interfaces parameter specifies all network addresses that Postfix
1006receives mail on by way of a proxy or network address translation unit. You may
1007specify symbolic hostnames instead of network addresses.
1008
1009IMPORTANT: You must specify your proxy/NAT external addresses when your system
1010is a backup MX host for other domains, otherwise mail delivery loops will
1011happen when the primary MX host is down.
1012
1013Example: host behind NAT box running a backup MX host.
1014
1015    /etc/postfix/main.cf:
1016	proxy_interfaces = 1.2.3.4 (the proxy/NAT external network address)
1017
101810.5 - What local clients to relay mail from
1019
1020If your machine is on an open network then you must specify what client IP
1021addresses are authorized to relay their mail through your machine into the
1022Internet. The default setting includes all subnetworks that the machine is
1023attached to. This may give relay permission to too many clients. My own
1024settings are:
1025
1026    /etc/postfix/main.cf:
1027	mynetworks = 168.100.189.0/28, 127.0.0.0/8
1028
102910.6 - What relay destinations to accept from strangers
1030
1031If your machine is on an open network then you must also specify whether
1032Postfix will forward mail from strangers. The default setting will forward mail
1033to all domains (and subdomains of) what is listed in $mydestination. This may
1034give relay permission for too many destinations. Recommended settings (use only
1035one):
1036
1037    /etc/postfix/main.cf:
1038	relay_domains = 	   (do not forward mail from strangers)
1039	relay_domains = $mydomain  (my domain and subdomains)
1040	relay_domains = $mydomain, other.domain.tld, ...
1041
104210.7 - Optional: configure a smart host for remote delivery
1043
1044If you're behind a firewall, you should set up a relayhost. If you can, specify
1045the organizational domain name so that Postfix can use DNS lookups, and so that
1046it can fall back to a secondary MX host when the primary MX host is down.
1047Otherwise just specify a hard-coded hostname.
1048
1049Some examples (use only one):
1050
1051    /etc/postfix/main.cf:
1052	relayhost = $mydomain
1053	relayhost = [mail.$mydomain]
1054
1055The form enclosed with [] eliminates DNS MX lookups.
1056
1057By default, the SMTP client will do DNS lookups even when you specify a relay
1058host. If your machine has no access to a DNS server, turn off SMTP client DNS
1059lookups like this:
1060
1061    /etc/postfix/main.cf:
1062	disable_dns_lookups = yes
1063
1064The STANDARD_CONFIGURATION_README file has more hints and tips for firewalled
1065and/or dial-up networks.
1066
106710.8 - Create the aliases database
1068
1069Postfix uses a Sendmail-compatible aliases(5) table to redirect mail for local
1070(8) recipients. Typically, this information is kept in two files: in a text
1071file /etc/aliases and in an indexed file /etc/aliases.db. The command "postconf
1072alias_maps" will tell you the exact location of the text file.
1073
1074First, be sure to update the text file with aliases for root, postmaster and
1075"postfix" that forward mail to a real person. Postfix has a sample aliases file
1076/etc/postfix/aliases that you can adapt to local conditions.
1077
1078    /etc/aliases:
1079	root: you
1080	postmaster: root
1081	postfix: root
1082	bin: root
1083	etcetera...
1084
1085Note: there should be no whitespace before the ":".
1086
1087Finally, build the indexed aliases file with one of the following commands:
1088
1089    # newaliases
1090    # sendmail -bi
1091    # postalias /etc/aliases (pathname is system dependent!)
1092
109311 - To chroot or not to chroot
1094
1095Postfix daemon processes can be configured (via master.cf) to run in a chroot
1096jail. The processes run at a fixed low privilege and with access only to the
1097Postfix queue directories (/var/spool/postfix). This provides a significant
1098barrier against intrusion. The barrier is not impenetrable, but every little
1099bit helps.
1100
1101With the exception of Postfix daemons that deliver mail locally and/or that
1102execute non-Postfix commands, every Postfix daemon can run chrooted.
1103
1104Sites with high security requirements should consider to chroot all daemons
1105that talk to the network: the smtp(8) and smtpd(8) processes, and perhaps also
1106the lmtp(8) client. The author's own porcupine.org mail server runs all daemons
1107chrooted that can be chrooted.
1108
1109The default /etc/postfix/master.cf file specifies that no Postfix daemon runs
1110chrooted. In order to enable chroot operation, edit the file /etc/postfix/
1111master.cf. Instructions are in the file.
1112
1113Note that a chrooted daemon resolves all filenames relative to the Postfix
1114queue directory (/var/spool/postfix). For successful use of a chroot jail, most
1115UNIX systems require you to bring in some files or device nodes. The examples/
1116chroot-setup directory in the source code distribution has a collection of
1117scripts that help you set up Postfix chroot environments on different operating
1118systems.
1119
1120Additionally, you almost certainly need to configure syslogd so that it listens
1121on a socket inside the Postfix queue directory. Examples for specific systems:
1122
1123FreeBSD:
1124
1125    # mkdir -p /var/spool/postfix/var/run
1126    # syslogd -l /var/spool/postfix/var/run/log
1127
1128Linux, OpenBSD:
1129
1130    # mkdir -p /var/spool/postfix/dev
1131    # syslogd -a /var/spool/postfix/dev/log
1132
113312 - Care and feeding of the Postfix system
1134
1135Postfix daemon processes run in the background, and log problems and normal
1136activity to the syslog daemon. The names of logfiles are specified in /etc/
1137syslog.conf. At the very least you need something like:
1138
1139    /etc/syslog.conf:
1140	mail.err				    /dev/console
1141	mail.debug				    /var/log/maillog
1142
1143IMPORTANT: the syslogd will not create files. You must create them before
1144(re)starting syslogd.
1145
1146IMPORTANT: on Linux you need to put a "-" character before the pathname, e.g.,
1147-/var/log/maillog, otherwise the syslogd will use more system resources than
1148Postfix does.
1149
1150Hopefully, the number of problems will be small, but it is a good idea to run
1151every night before the syslog files are rotated:
1152
1153    # postfix check
1154    # egrep '(reject|warning|error|fatal|panic):' /some/log/file
1155
1156  * The first line (postfix check) causes Postfix to report file permission/
1157    ownership discrepancies.
1158
1159  * The second line looks for problem reports from the mail software, and
1160    reports how effective the relay and junk mail access blocks are. This may
1161    produce a lot of output. You will want to apply some postprocessing to
1162    eliminate uninteresting information.
1163
1164The DEBUG_README document describes the meaning of the "warning" etc. labels in
1165Postfix logging.
1166
1167