下载好tar好解压

接着make时出现错误提示

No <db.h> include file found.
Install the appropriate db*-devel package first.
See the RELEASE_NOTES file for more information.

 说明berkeley db的db.h还没有安装.

在makedefs中找到如下代码,原来它为了支持数据库,必须在usr/include下面有db.h的文件

而我的系统就是得出是linux 2.xx来的.

按它的提示我安装不了db*-devel

我以为这东西是存在的,直接

apt-get install db*-devel也安装成功,但是发现还是没有db.h

当时没注意看安装了什么.

后来发现应该是一个叫berkeke db,好像是叫这个名的数据c语言接口来的.

经过不停的尝试/查找库,终于发现有一个叫libdb4.8-dev(也有其它版本)apt-get install后终于在/usr/include下面有db.h文件出现了.

 

 这个说明在readme_files/db_readme中.

 

 makedefs判断逻辑,我的是ubuntu,可以使用uname -a查看版本信息

 

 Linux.2*)    SYSTYPE=LINUX2
        # Postfix no longer needs DB 1.85 compatibility
        if [ -f /usr/include/db.h ]
        then
            : we are all set
        elif [ -f /usr/include/db/db.h ]
        then
            CCARGS="$CCARGS -I/usr/include/db"
        else
            # No, we're not going to try db1 db2 db3 etc.
            # On a properly installed system, Postfix builds
            # by including <db.h> and by linking with -ldb
            echo "No <db.h> include file found." 1>&2
            echo "Install the appropriate db*-devel package first." 1>&2
            echo "See the RELEASE_NOTES file for more information." 1>&2
            exit 1
        fi

 

使用以下命令来查询db库存在那个版本.按它的说明,其它版本的linux中可能命名是db*-devel,而不是libdb*-dev

dpkg -l libdb*dev
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Cfg-files/Unpacked/Failed-cfg/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                        Version                     Description
+++-===========================-===========================-======================================================================
un  libdb1-dev                  <none>                      (no description available)
un  libdb2-dev                  <none>                      (no description available)
un  libdb3-dev                  <none>                      (no description available)
un  libdb4.2-dev                <none>                      (no description available)
un  libdb4.3-dev                <none>                      (no description available)
un  libdb4.4-dev                <none>                      (no description available)
un  libdb4.5-dev                <none>                      (no description available)
un  libdb4.6-dev                <none>                      (no description available)
un  libdb4.7-dev                <none>                      (no description available)
ii  libdb4.8-dev                4.8.24-1ubuntu1             Berkeley v4.8 Database Libraries [development]

 

找到后使用apt-get install libdb4.8-dev安装.再到/usr/include中看到db.h出现.有可能有些是出现在usr/include/db/db.h中

 

 

1 更改安装目录中的conf/main.cf中的参数

前面一些参数是用于运行时.可以以安装好后再使用postconf | more查看再详细的更改.
下面这些参数是在运行时需要用到的.在这里写好了它也会在安装时提示,但是这些修改将成为默认值.所以,安装时不需要输入直接回车就可以了.除了特别注明,一般有些参数是可以使用no来跳过的

# INSTALL-TIME CONFIGURATION INFORMATION
#
# The following parameters are used when installing a new Postfix version.
#
# sendmail_path: The full pathname of the Postfix sendmail command.
# This is the Sendmail-compatible mail posting interface.
# sendmail的路径,
sendmail_path =/usr/sbin/sendmail

# newaliases_path: The full pathname of the Postfix newaliases command.
# This is the Sendmail-compatible command to build alias databases.
#
newaliases_path =/usr/bin/newaliases

# mailq_path: The full pathname of the Postfix mailq command.  This
# is the Sendmail-compatible mail queue listing command.
#
mailq_path =/usr/bin/mailq

#配置目录,原文中是没有的,加入就可以,
#但是前提是必须手动创建此目录,且把./conf中的所有文件复制进去,
#它会在安装成功后会提示什么文件是没用的.
config_directory = /etc/postfix

# setgid_group: The group for mail submission and queue management
# commands.  This must be a group name with a numerical group ID that
# is not shared with other accounts, not even with the Postfix account.
#postfix group id ,groupadd posfix first
#必须写,且不能其它地方使用用过的,必须写名字
#好像我写id号时提示出错.
#也不能使用跟mail_owner相同的
#
setgid_group =postdrop

# html_directory: The location of the Postfix HTML documentation.
#
html_directory =no

# manpage_directory: The location of the Postfix on-line manual pages.
#没必要也可以no
manpage_directory =/usr/local/man

# sample_directory: The location of the Postfix sample configuration files.
# This parameter is obsolete as of Postfix 2.1.
#
sample_directory =/usr/share/doc/postfix/examples

# readme_directory: The location of the Postfix README files.
#
readme_directory =no

在./readme_files/install中有main.cf 在安装时的默认参数指定的例子.
如果使用编译过的代码安装,需要使用make tidy命令清除上次编译的依赖配置后再make
postfix依赖数据库来读取和保存信息.有很多数据库选择.有些还使得文件式来保存,但是性能不好.建议使用berkeley db 源码安装 http://www.oracle.com/database/berkeley-db/
    它在配置时使用的语法是:xx_maps=hash(或btree):文件路径(不需要后缀),有些系统将它做为第三方程序使用.所以它会有不同的目录名,如果有这种情况,你最好使用创建路径影射出一个
    永不变化的路径给postfix使用.防止你更新后,路径变化导致调用出错.postfix2.0前版本不支持db4,如果需要perl进行打操作db,请安装perl版本

以下文件,安装后需要删除,但是不懂是否能提前删除

Note: the following files or directories still exist but are no
    longer part of Postfix:

     /etc/postfix/postfix-files /etc/postfix/postfix-script
     /etc/postfix/post-install


安装完成后提示ipv4的设置情况,到/etc/postfix/main.cf中会看到它增加了一个参数
COMPATIBILITY: editing main.cf, setting inet_protocols=ipv4.
Specify inet_protocols explicitly if you want to enable IPv6.
In a future release IPv6 will be enabled by default.

编译 make 如果没有错误就可以进入安装了,如果有错误它最后面会提示****error,前行就会是错误提示

使用 make > ./make.txt 编译语法将可以把正常的编译输出到make.txt中,而出错提示能够直接显示在shell上.

root@chrd-edm:/home/chrd/mail# make >make.txt
ar: creating libutil.a
debug_process.c: In function 鈊ebug_process?
debug_process.c:61: warning: ignoring return value of 鈙ystem? declared with attribute warn_unused_result
mail_copy.c: In function 鈓ail_copy?
mail_copy.c:282: warning: ignoring return value of 鈌truncate? declared with attribute warn_unused_result
ar: creating libglobal.a
ar: creating libdns.a
ar: creating libtls.a
ar: creating libxsasl.a
ar: creating libmilter.a
ar: creating libmaster.a
postscreen.c: In function 鈖sc_service?
postscreen.c:618: warning: ignoring return value of 鈝rite? declared with attribute warn_unused_result
postscreen.c:631: warning: ignoring return value of 鈝rite? declared with attribute warn_unused_result
postscreen.c:647: warning: ignoring return value of 鈝rite? declared with attribute warn_unused_result
postscreen.c:660: warning: ignoring return value of 鈝rite? declared with attribute warn_unused_result
root@chrd-edm:/home/chrd/mail#


安装前必须创建用户组和名
    使用 cat /etc/group 查看是否已存在用户组,和cat /etc/passwd 查看用户
    增加mail_owner组和用户postfix
    root@chrd-edm:/home/chrd# addgroup postfix
Adding group `postfix' (GID 1002) ...
Done.
然后再查看一下
postfix:x:1002:

增加drop组,给setid_group用
addgroup postdrop

增加用户
 useradd -M -g postfix -d /no/no -s /no/no -c postfix -G postfix postfix

安装
make install

使用which postfix会看到/usr/sbin/postfix,说明安装成功.
postfix后它会提示所有的有用的参数.
postfix start来运行postfix
postfix status查看状态.之类
postqueue -p 查看队列.
然后可以使用telnet来使用smtp来试发了.

 

尝试了手动编译成功了.后面就可以尝试修改它的c代码修改一些功能了.

 

 

安装的配置部分和结束提示

 

/bin/sh postfix-install

    Warning: if you use this script to install Postfix locally,
    this script will replace existing sendmail or Postfix programs.
    Make backups if you want to be able to recover.

    Before installing files, this script prompts you for some definitions.
    Most definitions will be remembered, so you have to specify them
    only once. All definitions should have a reasonable default value.

Please specify the prefix for installed file names. Specify this ONLY
if you are building ready-to-install packages for distribution to OTHER
machines. See PACKAGE_README for instructions.
install_root: [/]

Please specify a directory for scratch files while installing Postfix. You
must have write permission in this directory.
tempdir: [/home/chrd/postfix-2.9-20111113]

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 adminstrative 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/lib/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: [/usr/share/doc]

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] 

部分移动文件或忽略操作提示
Skipping /usr/local/man/man8/verify.8...
Skipping /usr/local/man/man8/virtual.8...
Updating /usr/share/doc/AAAREADME...
Updating /usr/share/doc/ADDRESS_CLASS_README...
Updating /usr/share/doc/ADDRESS_REWRITING_README...

    Note: the following files or directories still exist but are no
    longer part of Postfix:

     /etc/postfix/postfix-files /etc/postfix/postfix-script
     /etc/postfix/post-install

COMPATIBILITY: editing main.cf, setting inet_protocols=ipv4.
Specify inet_protocols explicitly if you want to enable IPv6.
In a future release IPv6 will be enabled by default.
root@chrd-edm:/home/chrd/postfix-2.9-20111113#