centos5.2下安装配置postfix

本文涉及的产品
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS MySQL,集群版 2核4GB 100GB
推荐场景:
搭建个人博客
云数据库 RDS MySQL,高可用版 2核4GB 50GB
简介:
#=====================关闭SELinux========================================================
setenforce 0
cp /opt/config/selinux-config /etc/selinux/config
#=====================删除sendmail=======================================================
rpm -e --nodeps sendmail
#====================安装bzip============================================================
rpm -ivh bzip2-1.0.3-3.i386.rpm
rpm -ivh bzip2-libs-1.0.3-3.i386.rpm
rpm -ivh ftp-0.17-33.fc6.i386.rpm
rpm -ivh unzip-5.52-2.2.1.i386.rpm
rpm -ivh wget-1.10.2-7.el5.i386.rpm
#====================(1)安装ncurses-5.6================================================
cd /opt
tar zxvf ncurses-5.6.tar.gz
cd ncurses-5.6
./configure --prefix=/usr --with-shared --without-debug 
make
make install
#====================(2)安装mysql======================================================
cd /opt
groupadd mysql
useradd mysql -g mysql -s /sbin/nologin
tar -zxvf mysql-5.0.51a.tar.gz
cd mysql-5.0.51a
./configure --with-mysqld-user=mysql --prefix=/usr/local/mysql5 --with-charset=gbk --with-extra-charset=all --without-isam --exec-prefix=/usr/local/mysql5 
make;make install
/usr/local/mysql5/bin/mysql_install_db
cp /usr/local/mysql5/share/mysql/my-medium.cnf /usr/local/mysql5/var/my.cnf 
cp /usr/local/mysql5/share/mysql/mysql.server /etc/init.d/mysqld
chmod 700 /etc/rc.d/init.d/mysqld  
chkconfig --add mysqld 
chkconfig --level 2345 mysqld on
chown mysql:mysql -R /usr/local/mysql5/
service mysqld start
ln -s /usr/local/mysql5/bin/mysql /sbin/mysql 
ln -s /usr/local/mysql5/bin/mysqladmin /sbin/mysqladmin
#配置库文件搜索路径
echo "/usr/local/mysql5/lib/mysql" >> /etc/ld.so.conf
ldconfig -v
#添加/usr/local/mysql/bin到环境变量PATH中
export PATH=$PATH:/usr/local/mysql5/bin
#测试 
#netstat -nplt | grep mysql
#ps aux|grep mysql
mysqladmin -u root password et-postfix
#====================(3)安装ZLIB2======================================================
cd /opt
tar zxvf zlib-1.2.3.tar.gz
cd zlib-1.2.3
./configure
make
make install
#=====================(4)安装openssl===================================================
cd /opt
tar zxvf openssl-0.9.8g.tar.gz
cd openssl-0.9.8g
./config shared zlib
make
make test
make install
mv /usr/bin/openssl /usr/bin/openssl.OFF
mv /usr/include/openssl /usr/include/openssl.OFF
rm /usr/lib/libssl.so
ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl
ln -s /usr/local/ssl/include/openssl /usr/include/openssl
ln -sv /usr/local/ssl/lib/libssl.so.0.9.8 /usr/lib/libssl.so
#配置库文件搜索路径
echo "/usr/local/ssl/lib" >> /etc/ld.so.conf
ldconfig -v
#检测安装结果
#openssl version
#======================(5)安装安装sasl-2.1.22==========================================
cd /opt
tar zxvf cyrus-sasl-2.1.22.tar.gz
cd cyrus-sasl-2.1.22
./configure --prefix=/usr/local/sasl2 --disable-gssapi --disable-anon --disable-sample --disable-digest --enable-plain --enable-login --enable-sql --with-mysql=/usr/local/mysql5 -with-mysql-includes=/usr/local/mysql5/include/mysql --with-mysql-libs=/usr/local/mysql5/lib/mysql   --with-authdaemond=/usr/local/courier-authlib/var/spool/authdaemon/socket
cp mac/libdes/public/des.h ./ 
make
make install
#关闭原有的sasl,并创建链接(这个地方我和原文有不同)postfix 2.3以后的版本会分别在/usr/local/lib和/usr/local/include中搜索sasl库文件及头文件,故还须将其链接至此目录中:
mv /usr/lib/sasl2 /usr/lib/sasl2.save
mv /usr/lib/libsasl2.so.2 /usr/lib/libsasl2.so.2.save
mv /usr/lib/libsasl2.so.2.0.22 /usr/lib/libsasl2.so.2.0.22.save
ln -sv /usr/local/sasl2/lib/* /usr/lib
ln -sv /usr/local/sasl2/lib/* /usr/local/lib
ln -sv /usr/local/sasl2/include/sasl/* /usr/local/include

#创建运行时需要的目录并调试启动
mkdir -pv /var/state/saslauthd      
#/usr/local/sasl2/sbin/saslauthd -a shadow pam -d
#启动并测试
/usr/local/sasl2/sbin/saslauthd -a shadow pam
#配置库文件搜索路径
echo "/usr/local/sasl2/lib" >> /etc/ld.so.conf
echo "/usr/local/sasl2/lib/sasl2" >> /etc/ld.so.conf
ldconfig -v
#开机自动启动
echo "/usr/local/sasl2/sbin/saslauthd -a shadow pam">>/etc/rc.local
#=======================(6)安装BerkeleyDB==============================================
cd /opt
tar zxvf db-4.5.20.tar.gz
cd db-4.5.20/build_unix
../dist/configure --prefix=/usr/local/BerkeleyDB
make;make install
ln -sv /usr/local/BerkeleyDB/include /usr/include/db4
ln -sv /usr/local/BerkeleyDB/include/db.h /usr/include/db.h
ln -sv /usr/local/BerkeleyDB/include/db_cxx.h /usr/include/db_cxx.h
echo "/usr/local/BerkeleyDB/lib" >> /etc/ld.so.conf
ldconfig
#=========================(7)安装httpd-2.2.8===========================================
cd /opt
tar jxvf httpd-2.2.8.tar.bz2
cd httpd-2.2.8
./configure --prefix=/usr/local/apache2 --enable-so --enable-ssl --with-ssl=/usr/local/ssl --enable-track-vars --enable-rewrite --with-zlib --enable-mods-shared=most --enable-suexec --with-suexec-caller=daemon
make;make install
#apache 开机启动
/usr/local/apache2/bin/apachectl start
echo "/usr/local/apache2/bin/apachectl start" >> /etc/rc.local
#===========================(8)安装libPNG==============================================
cd /opt
tar zxvf  libpng-1.2.26.tar.gz
cd libpng-1.2.26
cp scripts/makefile.linux ./makefile
./configure --prefix=/usr/local/libpng
make;make install
#=============================(9)安装freetype==========================================
cd /opt
tar zxvf freetype-2.3.5.tar.gz
cd freetype-2.3.5
./configure
 make;make install
#=============================(10)安装JPEG6============================================
cd /opt
tar zxvf jpegsrc.v6b.tar.gz
cd jpeg-6b
mkdir -pv /usr/local/jpeg/{,bin,lib,include,man/man1,man1} 
./configure --prefix=/usr/local/jpeg --enable-shared --enable- static
make;make install
#==============================(11)安装GD==============================================
cd /opt
tar zxvf gd-2.0.35.tar.gz
cd gd-2.0.35
./configure --with-png --with-freetype --with-jpeg=/usr/local/jpeg/ 
make;make install
#===============================(12)安装LIBXML2========================================
cd /opt
tar zxvf libxml2-2.6.31.tar.gz
cd libxml2-2.6.31
./configure --prefix=/usr/local/libxml2
make;make install
cp xml2-config /usr/bin
#================================(13)安装libmcrypt=====================================
cd /opt
tar zxvf libmcrypt-2.5.7.tar.gz
cd libmcrypt-2.5.7
./configure
 make;make install
#=================================(14)安装PHP5.2.5=====================================
cd /opt
tar zxvf php-5.2.5.tar.gz
cd php-5.2.5
./configure --prefix=/usr/local/php5 --with-mysql=/usr/local/mysql5 --with-apxs2=/usr/local/apache2/bin/apxs --with-jpeg-dir=/usr/local/jpeg --with-freetype-dir=/usr/local/include/freetype2 --with-zlib --with-png-dir=usr/local/libpng12 --with-libxml-dir=/usr/local/libxml2 --with-gd --enable-ftp --enable-sockets -enable-mbstring=all- --with-mcrypt --with-mysqli=/usr/local/mysql5/bin/mysql_config
make;make install
cp php.ini-dist /usr/local/php5/lib/php.ini
mv /usr/local/apache2/conf/httpd.conf /usr/local/apache2/conf/httpd.conf-1
cp /opt/config/httpd.conf /usr/local/apache2/conf/httpd.conf
cp /opt/config/index.php /usr/local/apache2/htdocs/index.php
killall httpd
/usr/local/apache2/bin/apachectl start
#=================================(15)安装Postfix-2.4.5================================
cd /opt
groupadd -g 2525 postfix
useradd -g postfix -u 2525 -s /sbin/nologin -M postfix
groupadd -g 2526 postdrop
useradd -g postdrop -u 2526 -s /bin/false -M postdrop
tar zxvf postfix-2.4.5.tar.gz
cd postfix-2.4.5
make makefiles 'CCARGS=-DHAS_MYSQL -I/usr/local/mysql5/include/mysql -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/local/sasl2/include/sasl -I/usr/local/BerkeleyDB/include -DUSE_TLS -I/usr/local/ssl/include/openssl ' 'AUXLIBS=-L/usr/local/mysql5/lib/mysql -lmysqlclient -lz -lm -L/usr/local/sasl2/lib -lsasl2 -L/usr/local/BerkeleyDB/lib -L/usr/local/ssl/lib -lssl -lcrypto'
make;make install
#生成别名二进制文件,这个步骤如果忽略,会造成postfix效率极低:
newaliases
#生成的aliases.db默认是在/etc/目录下,须做软连接,后面的lias_maps配置会用到
ln -s /etc/aliases.db /etc/postfix/aliases.db
#编辑配置文件
mv /etc/postfix/main.cf /etc/postfix/main.cf-1
cp /opt/config/main.cf /etc/postfix/main.cf
cp /opt/config/mysql_virtual_alias_maps.cf /etc/postfix/mysql_virtual_alias_maps.cf 
cp /opt/config/mysql_virtual_domains_maps.cf /etc/postfix/mysql_virtual_domains_maps.cf 
cp /opt/config/mysql_virtual_mailbox_limit_maps.cf /etc/postfix/mysql_virtual_mailbox_limit_maps.cf
cp /opt/config/mysql_virtual_mailbox_maps.cf /etc/postfix/mysql_virtual_mailbox_maps.cf 
#启动postfix
/usr/local/postfix/sbin/postfix start
echo "/usr/local/postfix/sbin/postfix start" >> /etc/rc.local
#================================(16)安装Courier authentication library================
cd /opt
rpm -ivh gdbm-devel-1.8.0-26.2.1.i386.rpm
ln -s /usr/local/mysql5/bin/mysql_config /usr/bin/mysql_config
tar -jxvf courier-authlib-0.59.3.tar.bz2
cd courier-authlib-0.59.3
./configure \
--prefix=/usr/local/courier-authlib \
--sysconfdir=/etc \
--with-mailuser=postfix \
--with-mailgroup=postfix \
--without-authpam \
--without-authldap \
--without-authpwd \
--without-authshadow \
--without-authvchkpw \
--without-authpgsql \
--with-authmysql \
--with-mysql-libs=/usr/local/mysql5/lib \
--with-mysql-includes=/usr/local/mysql5/include \
--with-redhat \
--with-authmysqlrc=/etc/authmysqlrc \
--with-authdaemonrc=/etc/authdaemonrc \
CFLAGS="-march=i686 -O2 -fexpensive-optimizations" \
CXXFLAGS="-march=i686 -O2 -fexpensive-optimizations"
make;make install
chmod 755 /usr/local/courier-authlib/var/spool/authdaemon
#编辑配置文件
cp /opt/config/authdaemonrc /etc/authdaemonrc
cp /opt/config/authmysqlrc /etc/authmysqlrc
ln -s /usr/local/courier-authlib/bin/courierauthconfig /usr/bin/courierauthconfig
ln -sv /usr/local/courier-authlib/include/* /usr/include/
cp /opt/courier-authlib-0.59.3/courier-authlib.sysvinit /etc/init.d/courier-authlib
chmod 755 /etc/init.d/courier-authlib
chkconfig --add courier-authlib
chkconfig --level 2345 courier-authlib on
echo "/usr/local/courier-authlib/lib/courier-authlib" >> /etc/ld.so.conf
ldconfig -v
#启动服务
service courier-authlib start
#==============================(17)安装Courier-IMAP====================================
cd /opt
tar jxvf courier-imap-4.1.3.tar.bz2
cd courier-imap-4.1.3
./configure --prefix=/usr/local/courier-imap --with-redhat --enable-unicode --disable-root-check --with-trashquota --without-ipv6 CPPFLAGS='-I/usr/local/ssl/include/openssl -I/usr/local/courier-authlib/include' LDFLAGS='-L/usr/local/courier-authlib/lib/courier-authlib' COURIERAUTHCONFIG='/usr/local/courier-authlib/bin/courierauthconfig' 
make
make install
#编辑配置文件
cp /opt/config/imapd /usr/local/courier-imap/etc/imapd
cp /usr/local/courier-imap/etc/imapd-ssl.dist /usr/local/courier-imap/etc/imapd-ssl
cp /opt/config/pop3d /usr/local/courier-imap/etc/pop3d 
cp /usr/local/courier-imap/etc/pop3d-ssl.dist /usr/local/courier-imap/etc/pop3d-ssl
mkdir –pv /var/mailbox
chown -R postfix /var/mailbox
cp /opt/courier-imap-4.1.3/courier-imap.sysvinit /etc/rc.d/init.d/courier-imapd
chmod 755 /etc/rc.d/init.d/courier-imapd
chkconfig --add courier-imapd
chkconfig --level 2345 courier-imapd on
#修改/usr/local/lib/sasl2/smtpd.conf文件,配置SMTP 认证
cp /opt/config/smtpd.conf /usr/local/lib/sasl2/smtpd.conf
#启动courier-imapd
service courier-imapd start
#==============================(18)安装pcre==============================================
cd /opt
tar zxvf pcre-7.2.tar.gz
cd pcre-7.2
./configure
make
make install
#==============================(19)安装courier-maildrop================================
cd /opt
groupadd -g 1001 vmail
useradd -g vmail -u 1001 -M -s /sbin/nologin vmail
tar jxvf maildrop-2.0.4.tar.bz2
cd maildrop-2.0.4
./configure  --enable-sendmail=/usr/sbin/sendmail  --enable-trusted-users='root vmail'  --enable-syslog=1 --enable-maildirquota  --enable-maildrop-uid=1001  --enable-maildrop-gid=1001  --with-trashquota  --with-dirsync
make
make install
#编辑配置文件
cp /opt/config/maildroprc /etc/maildroprc
touch /var/log/maildrop.log
chown vmail.vmail /var/log/maildrop.log
#编辑main.cf  master.cf
mv /etc/postfix/main.cf /etc/postfix/main.cf-2
mv /etc/postfix/master.cf /etc/postfix/master.cf-1
mv /etc/authmysqlrc /etc/authmysqlrc-1
cp /opt/config/main.cf-1 /etc/postfix/main.cf
cp /opt/config/master.cf /etc/postfix/master.cf
cp /opt/config/authmysqlrc-1 /etc/authmysqlrc
#=============================(20)Webmail安装配置========================================
cd /opt
tar -zxvf extmail-1.0.4.tar.gz
mkdir -pv /var/www/extsuite
mv extmail-1.0.4 /var/www/extsuite/extmail
#=============================(21)安装Extman=============================================
cd /opt
tar -zxvf extman-0.2.3.tar.gz
mv extman-0.2.3 /var/www/extsuite/extman
/usr/local/mysql5/bin/mysql -u root -pet-postfix < /var/www/extsuite/extman/docs/extmail.sql
/usr/local/mysql5/bin/mysql -u root -pet-postfix < /var/www/extsuite/extman/docs/init.sql
#关闭验证码
#vi /var/www/extsuite/extman/webman.cf
#SYS_CAPTCHA_ON = 0
#安装perl组件
perl -MCPAN -e shell 
install Bundle::CPAN
install HTML::KTemplate
install DBI       
install Unix::Syslog
install FCGI
install DBD::mysql
install Time::HiRes 
install File::Tail  
exit
cd /opt
rpm -ivh libart_lgpl-devel-2.3.17-4.i386.rpm
tar zxvf cgilib-0.5.tar.gz
cd cgilib-0.5
make
cp libcgi.a /usr/local/lib
cp cgi.h /usr/include
ln -s /usr/local/include/freetype2/ /usr/include/freetype2
#安装rrdtool-1.2.23
cd /opt
tar zxvf rrdtool-1.2.23.tar.tar 
cd rrdtool-1.2.23
./configure --prefix=/usr/local/rrdtool
make
make install
#创建必要的符号链接(Extman会到这些路径下找相关的库文件)
ln -sv /usr/local/rrdtool/lib/perl/5.8.5/i386-linux-thread-multi/auto/RRDs/RRDs.so   /usr/lib/perl5/5.8.5/i386-linux-thread-multi/
ln -sv /usr/local/rrdtool/lib/perl/5.8.5/RRDp.pm   /usr/lib/perl5/5.8.5
ln -sv /usr/local/rrdtool/lib/perl/5.8.5/i386-linux-thread-multi/RRDs.pm   /usr/lib/perl5/5.8.5
cp -r /usr/local/rrdtool/lib/perl/5.8.8/i386-linux-thread-multi/* /usr/lib/perl5/5.8.8/i386-linux-thread-multi/
#复制mailgraph_ext到/usr/local,并启动之
cp -r /var/www/extsuite/extman/addon/mailgraph_ext  /usr/local  
/usr/local/mailgraph_ext/mailgraph-init  start
/usr/local/mailgraph_ext/qmonitor-init  start
#添加到自动启动队列
echo "/usr/local/mailgraph_ext/mailgraph-init start" >> /etc/rc.local
echo "/usr/local/mailgraph_ext/qmonitor-init start" >> /etc/rc.local
mv  /var/www/extsuite/extman/webman.cf /var/www/extsuite/extman/webman.cf.bak
cp /opt/config/webman.cf /var/www/extsuite/extman/webman.cf
cp /opt/config/webmail.cf /var/www/extsuite/extmail/webmail.cf
mkdir /tmp/extman
chown -R vmail.vmail /var/mailbox
chown -R vmail.vmail /tmp/extman
chown -R vmail.vmail /var/www/extsuite
/usr/local/mysql5/bin/mysql -u root -pet-postfix
use mysql;
SET PASSWORD FOR  'extmail'@'localhost' = PASSWORD('et-extmail'); 
grant all privileges on *.* to  'extmail'@'localhost' identified by 'extmail' with grant option;
exit;
mv /usr/local/apache2/conf/httpd.conf /usr/local/apache2/conf/httpd.conf-2
cp /opt/config/httpd.conf-1 /usr/local/apache2/conf/httpd.conf
mv /usr/local/apache2/conf/extra/httpd-vhosts.conf /usr/local/apache2/conf/extra/httpd-vhosts.conf.bak
cp /opt/config/httpd-vhosts.conf /usr/local/apache2/conf/extra/httpd-vhosts.conf
killall httpd
/usr/local/apache2/bin/apachectl start
#设置http访问控制、认证、授权文件
#/usr/local/apache2/bin/htpasswd -c /usr/local/apache2/conf/htpasswd kerry
#chown vmail.vmail /usr/local/apache2/conf/htpasswd
#[url]http://192.168.8.151/extman     [/url] user:root@extmail.org   pwd:extmail*123*


本文转自king_819 51CTO博客,原文链接:http://blog.51cto.com/kerry/102811,如需转载请自行联系原作者
 
相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助 &nbsp; &nbsp; 相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
9天前
|
网络协议 Linux Python
Python脚本配置Centos静态ip地址
这是一个Python脚本,用于自动化配置CentOS系统的静态IP地址。脚本创建或修改文件,填写接口名(如ens33)、IP地址、子网掩码、网关和DNS。运行时需替换变量值并使用`sudo`以管理员权限执行。完成配置后,它会重启网络服务。注意,用户应根据实际网络环境调整参数。
Python脚本配置Centos静态ip地址
|
9天前
|
网络协议 Shell Linux
Shell脚本配置Centos静态ip地址
这是一个用于在CentOS上设置静态IP的Shell脚本摘要: - 脚本交互式获取用户输入的IP地址、子网掩码、网关和DNS。 - 使用`sed`命令动态更新`/etc/sysconfig/network-scripts/ifcfg-ENS33`配置文件。 - 修改`BOOTPROTO`为`static`,并设置IP、NETMASK、GATEWAY和DNS1字段。 - 用`systemctl restart network`重启网络服务。 - 提示用户新配置的静态IP信息。
|
14天前
|
应用服务中间件 Linux nginx
CentOS 7 上配置 Nginx 作为反向代理
在CentOS 7上设置Nginx反向代理的步骤:安装Nginx;启动Nginx服务编辑`/etc/nginx/nginx.conf`;添加`proxy_pass http://app_server_address;将请求转发至应用服务器;重启Nginx`sudo systemctl restart nginx`;验证配置是否成功
|
22天前
|
安全 关系型数据库 MySQL
CentOS 8 中安装与配置 MySQL
CentOS 8 中安装与配置 MySQL
93 3
|
23天前
|
缓存 Linux Docker
CentOS 7 下安装 Docker 及配置阿里云加速服务
CentOS 7 下安装 Docker 及配置阿里云加速服务
348 1
|
1月前
|
NoSQL 关系型数据库 应用服务中间件
jdk1.8、mysql、redis、nginx centos云服务器安装配置
jdk1.8、mysql、redis、nginx centos云服务器安装配置
|
22天前
|
网络协议 Linux Shell
如何在 CentOS 中配置 SSH 服务的 TCP 端口转发
如何在 CentOS 中配置 SSH 服务的 TCP 端口转发
37 0
|
1月前
|
Linux
centos bond多网关配置 bond多网关路由
centos bond多网关配置 bond多网关路由
29 2
|
24天前
|
Java Linux
Centos安装openjdk11并配置JAVA_HOME
Centos安装openjdk11并配置JAVA_HOME
81 0
|
26天前
|
消息中间件 RocketMQ
Centos7.6安装RocketMQ4.9.2并配置开机自启
Centos7.6安装RocketMQ4.9.2并配置开机自启
31 0