Build Postfix From Source on CentOS
Building Postfix from source can be a rewarding experience with great results. This tutorial will show you how to do a basic build and then following tutorials will show you how to build in additional features.
Download Source Code From Here:
http://www.postfix.org/download.html

When you download the source and unpack it you will find a README_FILES directory that contains instructions for the aspects of compiling Postfix. This is very valuable information that you must read. All of the Postfix source files have their own manual page.
AAAREADME NFS_README
ADDRESS_CLASS_README OVERVIEW
ADDRESS_REWRITING_README PACKAGE_README
ADDRESS_VERIFICATION_README PCRE_README
BACKSCATTER_README PGSQL_README
BASIC_CONFIGURATION_README QMQP_README
BUILTIN_FILTER_README QSHAPE_README
CDB_README RELEASE_NOTES
CONNECTION_CACHE_README RESTRICTION_CLASS_README
CONTENT_INSPECTION_README SASL_README
CYRUS_README SCHEDULER_README
DATABASE_README SMTPD_ACCESS_README
DB_README SMTPD_POLICY_README
DEBUG_README SMTPD_PROXY_README
DSN_README SOHO_README
ETRN_README STANDARD_CONFIGURATION_README
FILTER_README STRESS_README
INSTALL TLS_LEGACY_README
IPV6_README TLS_README
LDAP_README TUNING_README
LINUX_README ULTRIX_README
LOCAL_RECIPIENT_README UUCP_README
MAILDROP_README VERP_README
MILTER_README VIRTUAL_README
MULTI_INSTANCE_README XCLIENT_README
MYSQL_README XFORWARD_README
Compile a Basic Postfix
CentOS
Once you have downloaded the source code, move it into the /usr/src directory, other options are available.
mv postfix-2.6.5.tar.gz /usr/lsrc/
Untar the file which will create a directory.
tar zxvf postfix-2.6.5.tar.gz
Move into the new postfix directory.
cd postfix-2.6.5
Install the prerequisites
CentOS
yum install db*-devel
Postfix is built in C so you will be compiling C code. Usually the options that you want to create for a project are contained in a Makefile. The make utility creates this Makefile which is used to determine dependencies, any requirements needed or changes you want to create like adding programs or locations of files. The compiler then takes this information and creates object files and links them together into executables.
However, since Postfix creates its own Makefile, you do not need to edit it at all. In fact, the problem with editing the Makefile for Postfix is that your edits will get written over. So, the way to make changes is to use the CCARGS.
Tools You will need
gcc
make
CentOS
yum install gcc make
When you start the dependencies will be located and installed for you.
Installing:
gcc i386 4.1.2-44.el5 base 5.2 M
Updating:
glibc i686 2.5-34.el5_3.1 updates 5.2 M
glibc-common i386 2.5-34.el5_3.1 updates 16 M
nscd i386 2.5-34.el5_3.1 updates 159 k
Installing for dependencies:
cpp i386 4.1.2-44.el5 base 2.7 M
glibc-devel i386 2.5-34.el5_3.1 updates 2.0 M
glibc-headers i386 2.5-34.el5_3.1 updates 598 k
kernel-headers i386 2.6.18-164.el5 updates 993 k
libgomp i386 4.3.2-7.el5 base 67 k
Since Postfix does not use GNU autotools and so does not have the configure script that you may be used to. Postfix will actually do this work for you by creating it’s own Makefile. Run make as a normal user.
make
Once the compile is complete you will need to create the user and groups for Postfix.
groupadd postfix
groupadd postdrop
The user postfix needs to have an account that cannot log in and be a part of the postfix group that was created.
CentOS
useradd postfix -c postfix -d /tmp -s /bin/false
postfix:x:500:500:postfix:/tmp:/bin/false
Now run the final command which will allow you to choose directories and locations that you want to use with your installation. Read each option closely so that when you run the command you have an idea on what you want to change, if anything. You can take the default settings by choosing ENTER. Note you will need to run this as root so you have permissions to write to these directories.
make install
Please specify the prefix for installed file names. Specify this ONLY if you are building ready-to-install packages for distribution to other machines.
install_root: [/]
Please specify a directory for scratch files while installing Postfix. You must have write permission in this directory.
tempdir: [/usr/local/src/postfix-2.5.5]
Please specify the final destination directory for installed Postfix configuration files.
config_directory: [/etc/postfix]
Please specify the final destination directory for installed Postfix administrative commands. This directory should be in the command search path of administrative users.
command_directory: [/usr/sbin]
Please specify the final destination directory for installed Postfix daemon programs. This directory should not be in the command search path of any users.
daemon_directory: [/usr/libexec/postfix]
Please specify the final destination directory for Postfix-writable data files such as caches or random numbers. This directory should not be shared with non-Postfix software.
data_directory: [/var/lib/postfix]
Please specify the destination directory for the Postfix HTML files. Specify “no” if you do not want to install these files.
html_directory: [no]
Please specify the owner of the Postfix queue. Specify an account with numerical user ID and group ID values that are not used by any other accounts on the system.
mail_owner: [postfix]
Please specify the final destination pathname for the installed Postfix mailq command. This is the Sendmail-compatible mail queue listing command.
mailq_path: [/usr/bin/mailq]
Please specify the destination directory for the Postfix on-line manual pages. You can no longer specify “no” here.
manpage_directory: [/usr/local/man]
Please specify the final destination pathname for the installed Postfix newaliases command. This is the Sendmail-compatible command to build alias databases for the Postfix local delivery agent.
newaliases_path: [/usr/bin/newaliases]
Please specify the final destination directory for Postfix queues.
queue_directory: [/var/spool/postfix]
Please specify the destination directory for the Postfix README files. Specify “no” if you do not want to install these files.
readme_directory: [no]
Please specify the final destination pathname for the installed Postfix sendmail command. This is the Sendmail-compatible mail posting interface.
sendmail_path: [/usr/sbin/sendmail]
Please specify the group for mail submission and for queue management commands. Specify a group name with a numerical group ID that is not shared with other accounts, not even with the Postfix mail_owner account. You can no longer specify “no” here.
setgid_group: [postdrop]
This should complete a basic setup for Postfix and you can then start postfix with:
/usr/sbin/postfix start
You should see port 25 listening when you run netstat.
netstat -aunt
Default Postfix Install
Here are the basic features compiled in the default Postfix. You can see several features missing that you may want to compile into Postfix, SASL and MySQL are two that come up often.
ldd `postconf -h daemon_directory`/smtpd
linux-gate.so.1 => (0×00601000)
libdb-4.3.so => /lib/libdb-4.3.so (0×00411000)
libnsl.so.1 => /lib/libnsl.so.1 (0x001a1000)
libresolv.so.2 => /lib/libresolv.so.2 (0x003fc000)
libc.so.6 => /lib/libc.so.6 (0x00bdc000)
libpthread.so.0 => /lib/libpthread.so.0 (0x00d28000)
/lib/ld-linux.so.2 (0x00bb9000)
Posted by mike 

You must be logged in to post a comment.