Basic knowledge:
compiling manually environment variables used in postfix, variable values contain space or shell special characters, and the entire variable value must be enclosed in double quotation marks.
Auxlibs
Point out a function library that is located outside the standard location, using this variable to mark the path of the function library;
Cc
Pointing out the specific compiler you need to use, Postfix uses the GCC compiler by default, and if you don't want to use it, you can use this variable to indicate the compiler path you want to use;
Ccargs
Provide additional options to the compiler, the compiler supports special options, or the required support files are not in the standard path, use this variable to indicate special options or paths.
-I option , which indicates the function library path, such as Ccargs '-i/usr/local/include/',
-the-l option indicates the name of the function library (not the file name of the library), such as/usr/lib/mysql/ The libmysqlclient.so in the directory is the file name of the Mysqlclient function library, the function name is mysqlclient, and the link is-lmysqlclient.
The Postfix package defines a series of macros that represent specific resources found on the system, as well as pre-set options, and compiler options provide
-D option for user-defined compiler macros, such as postfix with the ability to query MYSQL, then define HAS_MYSQL macros,ccargs= '-dhas_mysql ';
DEBUG
When constructing the postfix executable, the compiler uses a higher level of debugging, debugging tools to get more detailed debugging information, to build the actual system postfix, it is recommended to turn off debugging support.
Opt
The extent to which the compiler optimizes the postfix executable when it is constructed. The default optimization level selected by the secondary option prompt.
The system used for this configuration is the CentOS6.5 64-bit version.
First, pre-installation preparation work:
Pre-installation instructions: The Mail service relies on the DNS service, so make sure that your DNS service is configured for the mail application.
Configure MX parsing
1, install the required RPM package, which includes the following:
httpd, MySQL, Mysql-server, Mysql-devel, Openssl-devel, Dovecot, Perl-dbd-mysql, Tcl, Tcl-devel, LIBART_LGPL, Libart_ Lgpl-devel, Libtool-ltdl, Libtool-ltdl-devel, Expect,cyrus-sasl,cyrus-sasl-devel, Cyrsu-sasl-libs (back three software is important)
2. Delete the Postfix software, Postfix and Postdrop account from the system;
# rpm-e Postfix
# userdel-r Postfix
# Userdel-r Postdroop
Why delete the system's own account will be explained after. If you do not delete it, you will get an error when configuring Extmail later.
3, install the following development to use the RPM package group:
Development Libraries
Development Tools
Method:
# yum Groupinstall "Packge_group_name"
Second, start dependent services:
1. Start the MySQL database and set the password for the root user of MySQL:
# service Mysqld Start
# Chkconfig Mysqld on
# mysqladmin-uroot password ' your_password '
2. Start the SASLAUTHD service and add it to the auto-start queue:
# service SASLAUTHD Start
# Chkconfig SASLAUTHD on
Three, installation configuration postfix
# GROUPADD-G 504 Postfix
# useradd-g postfix-u 503-s/sbin/nologin-m postfix
# GROUPADD-G 505 Postdrop
# useradd-g postdrop-u 505-s/sbin/nologin-m postdrop
Note: The CentOS6.6 version comes with Postfix, but the version is low and needs to be uninstalled.
Download good postfix
# tar ZXVF postfix-2.11.7.tar.gz
# CD postfix-2.11.7
Note: The 64-bit version of the system library file is under the/usr/lib64 folder, so the/usr/lib in the compilation option is replaced with/usr/lib64. MySQL is not installed in the standard directory, to indicate the installation location (I here MySQL is the system comes with, do not need to modify), as shown below.
# Make makefiles ' Ccargs=-dhas_mysql-i/usr/include/mysql-duse_sasl_auth-duse_cyrus_sasl-i/usr/include/sasl-duse_ TLS ' Auxlibs=-l/usr/lib64/mysql-lmysqlclient-lz-lm-l/usr/lib64/sasl2-lsasl2-lssl-lcrypto '
Make
Make install
Follow the prompts below to enter the relevant path (the [] number is the default value, "]" after the input value, the omitted representation takes the default value)
Install_root: [/]/
TempDir: [/root/postfix-2.9.3]/tmp/postfix
Config_directory: [/etc/postfix]/etc/postfix
Daemon_directory: [/usr/libexec/postfix]
Command_directory: [/usr/sbin]
Queue_directory: [/var/spool/postfix]
Sendmail_path: [/usr/sbin/sendmail]
Newaliases_path: [/usr/bin/newaliases]
Mailq_path: [/USR/BIN/MAILQ]
Mail_owner: [Postfix]
Setgid_group: [Postdrop]
Html_directory: [No]/var/www/html/postfix
Manpages: [/usr/local/man]
Readme_directory: [No]
To this postfix compilation is complete.
To generate an alias binary file:
# newaliases
Check that the Cyrus module is supported after the compilation is complete.
Postconf-a
Observe if the Cyrus is displayed
650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650 "this.width=650;" src= "http ://s2.51cto.com/wyfs02/m01/78/8d/wkiom1z_s3vbvcu5aaagvmd9nvi625.png "title=" 2.png "alt=" wKiom1Z_ S3vbvcu5aaagvmd9nvi625.png "/>
2. Perform some basic configuration, test the boot postfix and send the letters
# VIM/ETC/POSTFIX/MAIN.CF
Modify the following items for the configuration you need
Myhostname = mail.fei.com
Myorigin = fei.com
MyDomain = fei.com
mydestination = $myhostname, localhost. $mydomain, localhost, $mydomain (messages destined for this domain are received or relayed)
Mynetworks = 192.168.10.0/24, 127.0.0.0/8 (IP in this segment is responsible for relaying, not in the trunk, 192.168.10.0/24 network segment is my virtual machine Test network segment)
Description
The Myorigin parameter is used to indicate the domain name where the sender is located, that is, to disguise the sender address;
The mydestination parameter specifies the domain name of the recipient postfix receiving the message, that is, the message to which domain name your postfix system will receive.
The Myhostname parameter specifies the host name of the host that is running the Postfix mail system, and by default its value is set to the local machine name;
The mydomain parameter specifies your domain name, by default, Postfix removes the first part of Myhostname as the value of mydomain;
The Mynetworks parameter specifies the network address of your network, and the postfix system distinguishes whether the user is remote or local based on its value, and if the local network user allows access;
The inet_interfaces parameter specifies the network interface that the postfix system listens to;
Attention:
1, in the Postfix configuration file, the parameter line and the comment line cannot be in the same line;
2, the value of any one parameter does not need to quote, otherwise, the quotation marks will be used as part of the parameter values;
3, each modified parameter and its value after the execution of postfix reload can make it effective, but if modified inet_interfaces, you need to restart postfix;
4, if the value of one parameter has more than one, you can put them in different rows, just need to place a space in front of each subsequent line; Postfix will treat the first character as a space or tab text line as the continuation of the previous line;
5. When there is no $mydomain in the value of the mydestination, the message is sent without knowing which domain to send, and the statu=bounced (mail for fei.com loops back to myself) error is displayed.
Iv. provide sysv service script for Postfix /etc/rc.d/init.d/postfix
The content is as follows (before #END):
#!/bin/bash
#
# postfix postfix Mail Transfer Agent
#
# chkconfig:2345 80 30
# Description:postfix is a Mail Transport Agent, which are the program \
# That's moves mail from the one machine to another.
# Processname:master
# Pidfile:/var/spool/postfix/pid/master.pid
# config:/etc/postfix/main.cf
# config:/etc/postfix/master.cf
# Source function library.
. /etc/rc.d/init.d/functions
# Source Networking configuration.
. /etc/sysconfig/network
# Check that networking are up.
[$NETWORKING = "No"] && exit 3
[-x/usr/sbin/postfix] | | Exit 4
[-d/etc/postfix] | | Exit 5
[-d/var/spool/postfix] | | Exit 6
Retval=0
Prog= "Postfix"
Start () {
# Start Daemons.
Echo-n $ "Starting postfix:"
/usr/bin/newaliases >/dev/null 2>&1
/usr/sbin/postfix start 2>/dev/null 1>&2 && Success | | Failure $ "$prog start"
Retval=$?
[$RETVAL-eq 0] && Touch/var/lock/subsys/postfix
Echo
Return $RETVAL
}
Stop () {
# Stop Daemons.
Echo-n $ "Shutting down Postfix:"
/usr/sbin/postfix Stop 2>/dev/null 1>&2 && Success | | Failure $ "$prog Stop"
Retval=$?
[$RETVAL-eq 0] && rm-f/var/lock/subsys/postfix
Echo
Return $RETVAL
}
Reload () {
Echo-n $ "Reloading postfix:"
/usr/sbin/postfix Reload 2>/dev/null 1>&2 && Success | | Failure $ "$prog Reload"
Retval=$?
Echo
Return $RETVAL
}
Abort () {
/usr/sbin/postfix Abort 2>/dev/null 1>&2 && Success | | Failure $ "$prog Abort"
Return $?
}
Flush () {
/usr/sbin/postfix Flush 2>/dev/null 1>&2 && Success | | Failure $ "$prog Flush"
Return $?
}
Check () {
/usr/sbin/postfix Check 2>/dev/null 1>&2 && Success | | Failure $ "$prog check"
Return $?
}
Restart () {
Stop
Start
}
# See how we were called.
Case "$" in
Start
Start
;;
Stop
Stop
;;
Restart
Stop
Start
;;
Reload
Reload
;;
Abort
Abort
;;
Flush
Flush
;;
Check
Check
;;
Status
Status Master
;;
Condrestart)
[-f/var/lock/subsys/postfix] && Restart | | :
;;
*)
echo $ "Usage: $ {Start|stop|restart|reload|abort|flush|check|status|condrestart}"
Exit 1
Esac
Exit $?
# END
Give execute permission to this script:
# chmod +x/etc/rc.d/init.d/postfix
Add the Postfix service to the list of services:
# chkconfig--add postfix
Set it to start automatically:
# chkconfig Postfix on
Use this script to restart the service to test whether it will perform correctly:
# service Postfix Restart
You can use local user test mail to send and receive.
At this point, only local IP addresses and local loopback addresses can send and receive messages based on mynetwork restrictions.
This article is from the "No Flying World" blog, please be sure to keep this source http://hf1208.blog.51cto.com/8957433/1728826
Linux (CentOS6.5) postfix Server compilation installation