编译安装postfix


编译安装postfix

释放

[root@jason home]# tar xzf postfix-2.11.3.tar.gz -C /usr/src
[root@jason home]# cd /usr/src/postfix-2.11.3/


```bash
[root@jason postfix-2.11.3]# make makefiles \
> 'CCARGS=-DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/include/sasl' \
> 'AUXLIBS=-L/usr/lib/sasl2 -lsasl2'

如果出现Install the appropriate db*-devel package first

[root@jason postfix-2.11.3]# make makefiles \
> 'CCARGS=-DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/include/sasl' \
> 'AUXLIBS=-L/usr/lib/sasl2 -lsasl2'
make -f Makefile.in MAKELEVEL= Makefiles
(echo "# Do not edit -- this file documents how Postfix was built for your machine."; /bin/sh makedefs) >makedefs.tmp
No  include file found.
Install the appropriate db*-devel package first.
make: *** [Makefiles] Error 1
make: *** [makefiles] Error 2

解决办法

[root@jason postfix-2.11.3]# yum install db4-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package db4-devel.x86_64 0:4.7.25-18.el6_4 will be installed
--> Processing Dependency: db4-cxx = 4.7.25-18.el6_4 for package: db4-devel-4.7.25-18.el6_4.x86_64
--> Processing Dependency: libdb_cxx-4.7.so()(64bit) for package: db4-devel-4.7.25-18.el6_4.x86_64
--> Running transaction check
---> Package db4-cxx.x86_64 0:4.7.25-18.el6_4 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================
 Package                Arch                Version                        Repository              Size
========================================================================================================
Installing:
 db4-devel              x86_64              4.7.25-18.el6_4                CentOS6.5              6.6 M
Installing for dependencies:
 db4-cxx                x86_64              4.7.25-18.el6_4                CentOS6.5              588 k

Transaction Summary
========================================================================================================
Install       2 Package(s)

Total download size: 7.1 M
Installed size: 26 M
Is this ok [y/N]: y
Downloading Packages:
--------------------------------------------------------------------------------------------------------
Total                                                                   2.5 MB/s | 7.1 MB     00:02     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : db4-cxx-4.7.25-18.el6_4.x86_64                                                       1/2 
  Installing : db4-devel-4.7.25-18.el6_4.x86_64                                                     2/2 
  Verifying  : db4-devel-4.7.25-18.el6_4.x86_64                                                     1/2 
  Verifying  : db4-cxx-4.7.25-18.el6_4.x86_64                                                       2/2 

Installed:
  db4-devel.x86_64 0:4.7.25-18.el6_4                                                                    

Dependency Installed:
  db4-cxx.x86_64 0:4.7.25-18.el6_4                                                                      

Complete!
[root@jason postfix-2.11.3]#

安装完db*-devel包之后再次make makefiles

[root@jason postfix-2.11.3]# make makefiles 'CCARGS=-DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/include/sasl' 'AUXLIBS=-L/usr/lib/sasl2 -lsasl2'
make -f Makefile.in MAKELEVEL= Makefiles
(echo "# Do not edit -- this file documents how Postfix was built for your machine."; /bin/sh makedefs) >makedefs.tmp
set +e; if cmp makedefs.tmp conf/makedefs.out; then rm makedefs.tmp; \
    else mv makedefs.tmp conf/makedefs.out; fi >/dev/null 2>/dev/null
set -e; for i in src/util src/global src/dns src/tls src/xsasl src/milter src/master src/postfix src/fsstone src/smtpstone src/sendmail src/error src/pickup src/cleanup src/smtpd src/local src/trivial-rewrite src/qmgr src/oqmgr src/smtp src/bounce src/pipe src/showq src/postalias src/postcat src/postconf src/postdrop src/postkick src/postlock src/postlog src/postmap src/postqueue src/postsuper src/qmqpd src/spawn src/flush src/verify src/virtual src/proxymap src/anvil src/scache src/discard src/tlsmgr src/postmulti src/postscreen src/dnsblog src/tlsproxy src/posttls-finger; do \
     (set -e; echo "[$i]"; cd $i; rm -f Makefile; \
     make -f Makefile.in Makefile MAKELEVEL=) || exit 1; \
    done;
[src/util]
cat ../../conf/makedefs.out Makefile.in >Makefile
[src/global]
...//中间省略
cat ../../conf/makedefs.out Makefile.in >Makefile
[src/posttls-finger]
cat ../../conf/makedefs.out Makefile.in >Makefile
rm -f Makefile; (cat conf/makedefs.out Makefile.in) >Makefile
[root@jason postfix-2.11.3]#

编译安装

[root@jason postfix-2.11.3]# make && make install

查看支持相关的认证方式

[root@jason ~]# postconf -a
cyrus
dovecot
[root@jason ~]#

启动进程并查看进程状态信息

[root@jason ~]# postfix start 
postfix/postfix-script: fatal: the Postfix mail system is already running
[root@jason ~]# postfix status
postfix/postfix-script: the Postfix mail system is running: PID: 981
[root@jason ~]#

查看监听端口号

[root@jason ~]# netstat -utpln | grep master
tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      981/master          
tcp        0      0 ::1:25                      :::*                        LISTEN      981/master          
[root@jason ~]#

简化配置文件

[root@jason ~]# postconf -n > main.config
[root@jason ~]# ls
anaconda-ks.cfg  install.log  install.log.syslog  main.config
[root@jason ~]# mv /etc/postfix/main.cf /etc/postfix/main.cf.bak
[root@jason ~]# mv main.config /etc/postfix/main.cf

简化后的main.cf内容

[root@jason ~]# cat /etc/postfix/main.cf
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
command_directory = /usr/sbin
config_directory = /etc/postfix
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
debug_peer_level = 2
debugger_command = PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin ddd $daemon_directory/$process_name $process_id & sleep 5
html_directory = no
inet_interfaces = localhost
inet_protocols = all
mail_owner = postfix
mailq_path = /usr/bin/mailq.postfix
manpage_directory = /usr/share/man
mydestination = $myhostname, localhost.$mydomain, localhost
newaliases_path = /usr/bin/newaliases.postfix
queue_directory = /var/spool/postfix
readme_directory = /usr/share/doc/postfix-2.6.6/README_FILES
sample_directory = /usr/share/doc/postfix-2.6.6/samples
sendmail_path = /usr/sbin/sendmail.postfix
setgid_group = postdrop
unknown_local_recipient_reject_code = 550
[root@jason ~]#

更改主配置文件内容

[root@jason ~]# vim /etc/postfix/main.cf

alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
command_directory = /usr/sbin
config_directory = /etc/postfix
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
debug_peer_level = 2
debugger_command = PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin ddd $daemon_directory/$process_name $process_id & sleep 5
html_directory = no
inet_interfaces = 173.16.16.18
inet_protocols = all
mail_owner = postfix
mailq_path = /usr/bin/mailq.postfix
manpage_directory = /usr/share/man
mydestination = $myhostname,$mydomain
newaliases_path = /usr/bin/newaliases.postfix
queue_directory = /var/spool/postfix
readme_directory = /usr/share/doc/postfix-2.6.6/README_FILES
sample_directory = /usr/share/doc/postfix-2.6.6/samples
sendmail_path = /usr/sbin/sendmail.postfix
setgid_group = postdrop
unknown_local_recipient_reject_code = 550
myhostname = mail.benet.com
mydomain = benet.com
myorigin = $mydomain
home_mailbox = Maildir/
:wq

创建用户

[root@jason ~]# groupadd mailusers
[root@jason ~]# useradd -g mailusers -s /sbin/nologin jason
[root@jason ~]# passwd jason
Changing password for user jason.
New password: 
BAD PASSWORD: it does not contain enough DIFFERENT characters
BAD PASSWORD: is too simple
Retype new password: 
passwd: all authentication tokens updated successfully.
[root@jason ~]#
[root@jason ~]# useradd -g mailusers -s /sbin/nologin bourn
[root@jason ~]# passwd bourn
Changing password for user bourn.
New password: 
BAD PASSWORD: it does not contain enough DIFFERENT characters
BAD PASSWORD: is too simple
Retype new password: 
passwd: all authentication tokens updated successfully.
[root@jason ~]#

results matching ""

    No results matching ""