热门标签 | HotTags
当前位置:  开发笔记 > 后端 > 正文

编译安装Postfix邮件服务器

Postfix的安装方式与其它的软件有些不同,其做为悠久的邮件服务器,它支持众多的特性,包括与第三方软件的交互整合功能。这里对其的编译、安装过程进行了一个简单总结。---------------InstallationofPostfixAddingUsersandGroups--添加用户及其组Be
Postfix的安装方式与其它的软件有些不同,其做为悠久的邮件服务器,它支持众多的特性,包括与第三方软件的交互整合功能。这里对其的编译、安装过程进行了一个简单总结。

---------------
Installation of Postfix

Adding Users and Groups--添加用户及其组

Before you compile the program, you need to create users and groups that will be expected to be in place during the installation. Add the users and groups with the following commands issued by the root user:

groupadd -g 32 postfix &&
groupadd -g 33 postdrop &&
useradd -c "Postfix Daemon User" -d /var/spool/postfix -g postfix -s /bin/false -u 32 postfix &&
chown -v postfix:postfix /var/mail

Configuring the Build--编译配置
Postfix的编译安装与其它通用的软件安装不同,它有自己的一套规则。

The Postfix source tree does not contain a configure script, rather the makefile in the top-level directory contains a makefiles target that regenerates all the other makefiles in the build tree. If you wish to use additional software such as a database back-end for virtual users, or TLS/SSL authentication, you will need to regenerate the makefiles using one or more of the appropriate CCARGS and AUXLIBS settings listed below.

Cyrus-SASL
To use Cyrus-SASL with Postfix, use the following arguments:
CCARGS='-DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/include/sasl'
AUXLIBS='-lsasl2'

OpenLDAP
To use OpenLDAP with Postfix, use the following arguments:
CCARGS='-DHAS_LDAP'
AUXLIBS='-lldap -llber'

Sqlite
To use Sqlite with Postfix, use the following arguments:
CCARGS='-DHAS_SQLITE'
AUXLIBS='-lsqlite3 -lpthread'

MySQL
To use MySQL with Postfix, use the following arguments:
CCARGS='-DHAS_MYSQL -I/usr/include/mysql'
AUXLIBS='-lmysqlclient -lz -lm'

PostgreSQL
To use PostgreSQL with Postfix, use the following arguments:
CCARGS='-DHAS_PGSQL -I/usr/include/postgresql'
AUXLIBS='-lpq -lz -lm'

CDB/TinyCDB
To use CDB or TinyCDB with Postfix, use the following arguments:
CCARGS='-DHAS_CDB'
AUXLIBS='/libcdb.a'

StartTLS Authentication
To use OpenSSL with Postfix, use the following arguments:
CCARGS='-DUSE_TLS -I/usr/include/openssl/'

AUXLIBS='-lssl -lcrypto'

具体的编译参数和选项选项:
1.AUXLIBS
2.CC
3.CCARGS  
4.DEBUG
5.OPT

参数:-I ,-D, -L, -R, -r, -l。各个参数的说明如下:
-I 指明某一包的库文件所在的地方

-D The -D option provides a way to define macros at the time you compile Postfix. Add-on packages for Postfix require that you define a particular macro to tell Postfix to include it when building. For example, if you want to include support for MySQL, you define the HAS_MYSQL macro:CCARGS='-DHAS_MYSQL'

-L 加入对某一包的额外库的支持。如:AUXLIBS='-L/usr/local/lib'

-l 和-L一块儿使用,具体到某一库。如:AUXLIBS='-L/usr/local/lib -lmysqlclient'

-R -r
The linker uses an argument to include directories in a runtime search path for dynamic libraries. The argument differs depending on your linker and platform. The GNU linker (Linux, FreeBSD) uses -rpath, as does IRIX. Solaris, on the other hand uses -R, and HP-UX uses +b. Consult the manpage for your linker, ld(1), to see which argument you should use to set the runtime library search path.

如:Using the SSL library as an example, if your libssl.so file is located in /usr/local/lib and you are building Postfix on FreeBSD or another system that uses rpath, define AUXLIBS as follows:
AUXLIBS='-L/usr/local/lib -rpath/usr/local/lib -lssl'

下面给出一个例子:可以将它保存成shell,如:install.sh文件

#make tidy
# Specify all of our options and supporting libraries
make makefiles \
CCARGS='-DUSE_SASL_AUTH -DHAS_SSL -DHAS_MYSQL -DHAS_LDAP \
-I/usr/local/include/sasl -I/usr/local/ssl/include \
-I/usr/local/include/mysql -I/usr/local/include' \

AUXLIBS='-L/usr/local/lib -L/usr/local/ssl/lib \
-L/usr/local/lib/mysql -L/usr/local/lib \
-lsasl2 -lcrypto -lssl -lmysqlclient -lz -lm -lldap -llber \
-rpath /usr/local/lib/mysql -rpath /usr/local/lib \
-rpath /usr/local/ssl/lib'

To build Postfix, type:
$ sh build.sh
$ make

Installing Postfix--安装

If you have Cyrus SASL and OpenSSL installed, install Postfix by running the following commands:
make CCARGS="-DNO_NIS -DUSE_TLS -I/usr/include/openssl/ -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/include/sasl" \
AUXLIBS="-lssl -lcrypto -lsasl2"                              \
makefiles &&
make

This package does not come with a useful test suite.

Now, as the root user:
sh postfix-install -non-interactive \
   daemon_directory=/usr/lib/postfix \
   manpage_directory=/usr/share/man \
   html_directory=/usr/share/doc/postfix-2.10.0/html \
readme_directory=/usr/share/doc/postfix-2.10.0/readme

Command Explanations--指令解析

make makefiles: This command rebuilds the makefiles throughout the source tree to use the options contained in the CCARGS and AUXLIBS variables.

-DNO_NIS: This option disables building Network Information Service/Yellow Pages support. The RPC implementation in Glibc (on which NIS/YP depends) is deprecated.

对于使用'-DNO_'这样的选项是为了在默认的选项中禁止掉一些组件,像nis、Berkeley DB、ipv6、等这些没有使用的功能块。

sh postfix-install -non-interactive: This keeps the install script from asking any questions, thereby accepting default destination directories in all but the few cases. If the html_directory and readme_directory options are not set then the documentation will not be installed.

---------------
Configuring Postfix--配置

Config Files
/etc/aliases, /etc/postfix/main.cf, and /etc/postfix/master.cf

Configuration Information

Create (or append to an existing) /etc/aliases with the following command. Change for your non-root login identity so mail addressed to root can be forwarded to you. As the root user:

cat >> /etc/aliases <<"EOF"
# Begin /etc/aliases

MAILER-DAEMON: postmaster
postmaster: root

root:
# End /etc/aliases
EOF

To protect an existing /etc/aliases file, the above command appends these aliases to it if it exists. This file should be checked and duplicate aliases removed, if present.

Note
The /etc/postfix/main.cf and /etc/postfix/master.cf files must be personalized for your system. The main.cf file needs your fully qualified hostname. You will find that main.cf is self documenting, so load it into your editor to make the changes you need for your situation.

Note
Postfix can also be set up to run in a chroot jail. See the file in the source examples/chroot-setup/LINUX2 for details.

If you have an existing configuration, you can run the postfix utility to add any necessary definitions to your existing files. As the root user:
/usr/sbin/postfix upgrade-configuration

Before starting Postfix, you should check that your configuration and file permissions will work properly. Run the following commands as the root user to check and start your Postfix server:
/usr/sbin/postfix check &&
/usr/sbin/postfix start

Boot Script--启动脚本

To automate the running of Postfix at startup, install the /etc/rc.d/init.d/postfix init script included in the blfs-bootscripts-20130721 package.

make install-postfix

---------------
Contents--所产生的文件

Installed Programs:
mailq, newaliases, postaliases, postcat, postconf, postdrop, postfix, postkick, postlock, postlog, postmap, postmulti, postqueue, postsuper and sendmail

Installed Libraries:
None

Installed Directories:
/etc/postfix, /usr/lib/postfix, /usr/share/doc/postfix-2.10.0, /var/lib/postfix and /var/spool/postfix

Short Descriptions--简短描述

mailq--A symlink to sendmail.

newaliases--A symlink to sendmail.

postaliases--is a utility for Postfix alias database maintenance

postcat--Prints the contents of files from the Postfix queue in human readable format.

postconf--Displays or changes the value of Postfix configuration parameters.

postdrop--Creates a file in the maildrop directory and copies its standard input to the file.

postfix--is the Postfix control program.

postkick--Sends requests to the specified service over a local transport channel.

postlock--Locks a mail folder for exclusive use, and executes commands passed to it.

postlog--A Postfix-compatible logging interface for use in, for example, shell scripts.

postmap--Creates or queries one or more Postfix lookup tables, or updates an existing one.

postmulti--is the Postfix multi-instance manager. It allows a system administrator to manage multiple Postfix instances on a single host.

postqueue--The Postfix user interface for queue management.

postsuper--The Postfix user interface for superuser queue management.

sendmail--is the Postfix to Sendmail compatibility interface.

---------------


推荐阅读
  • 本文介绍了在开发Android新闻App时,搭建本地服务器的步骤。通过使用XAMPP软件,可以一键式搭建起开发环境,包括Apache、MySQL、PHP、PERL。在本地服务器上新建数据库和表,并设置相应的属性。最后,给出了创建new表的SQL语句。这个教程适合初学者参考。 ... [详细]
  • Nginx使用AWStats日志分析的步骤及注意事项
    本文介绍了在Centos7操作系统上使用Nginx和AWStats进行日志分析的步骤和注意事项。通过AWStats可以统计网站的访问量、IP地址、操作系统、浏览器等信息,并提供精确到每月、每日、每小时的数据。在部署AWStats之前需要确认服务器上已经安装了Perl环境,并进行DNS解析。 ... [详细]
  • 本文介绍了如何使用php限制数据库插入的条数并显示每次插入数据库之间的数据数目,以及避免重复提交的方法。同时还介绍了如何限制某一个数据库用户的并发连接数,以及设置数据库的连接数和连接超时时间的方法。最后提供了一些关于浏览器在线用户数和数据库连接数量比例的参考值。 ... [详细]
  • 本文介绍了在Hibernate配置lazy=false时无法加载数据的问题,通过采用OpenSessionInView模式和修改数据库服务器版本解决了该问题。详细描述了问题的出现和解决过程,包括运行环境和数据库的配置信息。 ... [详细]
  • Oracle Database 10g许可授予信息及高级功能详解
    本文介绍了Oracle Database 10g许可授予信息及其中的高级功能,包括数据库优化数据包、SQL访问指导、SQL优化指导、SQL优化集和重组对象。同时提供了详细说明,指导用户在Oracle Database 10g中如何使用这些功能。 ... [详细]
  • 在说Hibernate映射前,我们先来了解下对象关系映射ORM。ORM的实现思想就是将关系数据库中表的数据映射成对象,以对象的形式展现。这样开发人员就可以把对数据库的操作转化为对 ... [详细]
  • 本文介绍了在Mac上搭建php环境后无法使用localhost连接mysql的问题,并通过将localhost替换为127.0.0.1或本机IP解决了该问题。文章解释了localhost和127.0.0.1的区别,指出了使用socket方式连接导致连接失败的原因。此外,还提供了相关链接供读者深入了解。 ... [详细]
  • Java实战之电影在线观看系统的实现
    本文介绍了Java实战之电影在线观看系统的实现过程。首先对项目进行了简述,然后展示了系统的效果图。接着介绍了系统的核心代码,包括后台用户管理控制器、电影管理控制器和前台电影控制器。最后对项目的环境配置和使用的技术进行了说明,包括JSP、Spring、SpringMVC、MyBatis、html、css、JavaScript、JQuery、Ajax、layui和maven等。 ... [详细]
  • 数据库(外键及其约束理解)(https:www.cnblogs.comchenxiaoheip6909318.html)My ... [详细]
  • yum安装_Redis —yum安装全过程
    篇首语:本文由编程笔记#小编为大家整理,主要介绍了Redis—yum安装全过程相关的知识,希望对你有一定的参考价值。访问https://redi ... [详细]
  • 解决VS写C#项目导入MySQL数据源报错“You have a usable connection already”问题的正确方法
    本文介绍了在VS写C#项目导入MySQL数据源时出现报错“You have a usable connection already”的问题,并给出了正确的解决方法。详细描述了问题的出现情况和报错信息,并提供了解决该问题的步骤和注意事项。 ... [详细]
  • 本文详细介绍了MySQL表分区的创建、增加和删除方法,包括查看分区数据量和全库数据量的方法。欢迎大家阅读并给予点评。 ... [详细]
  • mysql-cluster集群sql节点高可用keepalived的故障处理过程
    本文描述了mysql-cluster集群sql节点高可用keepalived的故障处理过程,包括故障发生时间、故障描述、故障分析等内容。根据keepalived的日志分析,发现bogus VRRP packet received on eth0 !!!等错误信息,进而导致vip地址失效,使得mysql-cluster的api无法访问。针对这个问题,本文提供了相应的解决方案。 ... [详细]
  • 众筹商城与传统商城的区别及php众筹网站的程序源码
    本文介绍了众筹商城与传统商城的区别,包括所售产品和玩法不同以及运营方式不同。同时还提到了php众筹网站的程序源码和方维众筹的安装和环境问题。 ... [详细]
  • 如何在php中将mysql查询结果赋值给变量
    本文介绍了在php中将mysql查询结果赋值给变量的方法,包括从mysql表中查询count(学号)并赋值给一个变量,以及如何将sql中查询单条结果赋值给php页面的一个变量。同时还讨论了php调用mysql查询结果到变量的方法,并提供了示例代码。 ... [详细]
author-avatar
Quiet静以修身
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有