postfix安装记录一LAMP环境

参考了网上的一些资料搭建了自己的postfix邮件服务器,从开始到结束,还蛮复杂的,对于没有接触过postfix的人来说,有点难度,我结合了网上的资料搭建了postfix+courier-imap+maildrop+cyrus-sasl+ extman+ SpamAssassin+ clamav+ amavisd-new,主要是参考了 http://blog.csdn.net/liuyunfengheda/article/details/5805043 的博客; 自己在实践过程中把记录写下来,共同交流


一、LAMP环境搭建

二、postfix、邮件相关的认证及extman套件安装

三、图形化日志安装

四、postfix防病毒和垃圾邮件过滤,垃圾邮件的过滤实在是不好把握;有这方面经验的网友可以教教我,谢谢!


过程如下:


一、所需安装源码包列表


LAMP环境
postfix相关
防病毒、过滤垃圾邮件及相关模块
php-5.2.13.tar.gz postfix-2.8.15.tar.gz amavisd-new-2.6.2.tar.gz
httpd-2.2.15.tar.gz cyrus-sasl-2.1.22.tar.gz clamav-0.98.tar.gz
mysql-5.1.47.tar.gz maildrop-2.5.4.tar.bz2 Mail-SpamAssassin-3.3.1.tar.bz2
日志相关的软件 courier-authlib-0.63.0.tar.bz2 DBD-mysql-3.0008.tar.gz
gd-2.0.35.tar.gz courier-imap-4.9.3.tar.bz2 Mail-DKIM-0.40.tar.gz
Time-HiRes-1.9719.tar.gz Encode-IMAPUTF7-1.05.tar.gz Razor2-Client-Agent-2.84.tar.gz
File-Tail-0.99.3.tar.gz extman-1.1.tar.gz
Convert-BinHex-1.119.tar.gz
rrdtool-1.4.3.tar.gz extmail-1.2.tar.gz razor-agents-2.84.tar.bz2


Net-Server-2.007.tar.gz


IO-Socket-INET6-2.71.tar.gz





二、系统准备工作


1、系统相关的准备工作


采用centos 5.8 32位系统;内存为4G ;采用主机名为mail.test.com


# ifconfig eth0//确认IP地址

eth0inet addr:192.168.x.x Bcast:192.168.x.255Mask:255.255.255.0


[root@mail src]# hostname //确认主机名

mail.test.com


# vim /etc/sysconfig/i18n//更改系统字符集

LANG="en_US"

#LANG="en_US.UTF-8"

SUPPORTED="zh_CN.UTF-8:zh_CN:zh:zh_TW.UTF-8:zh_TW:zh:en_US.UTF-8:en_US:en"

SYSFONT="latarcyrheb-sun16"


# vim /etc/hosts//修改Hosts文件,修改前先备份一下;

27.0.0.1 localhost.localdomain localhost

::1 localhost6.localdomain6 localhost6

192.168.x.x mail.test.com mail




2、卸载系统原有组件


#rpm -qa|egrep '(httpd|mysql|php|sendmail)'//删除系统中的LAMP组件和sendmail

httpd-2.2.3-63.el5.centos

sendmail-8.13.8-8.1.el5_7 ~


# rpm -e --nodeps sendmail-8.13.8-8.1.el5_7

# rpm -e --nodeps httpd-2.2.3-63.el5.centos


[root@mail etc]# rpm -qa |grep sasl//删除系统自带的认证安全层cyrus-sasl

cyrus-sasl-2.1.22-5.el5_4.3

cyrus-sasl-plain-2.1.22-5.el5_4.3

cyrus-sasl-lib-2.1.22-5.el5_4.3

cyrus-sasl-devel-2.1.22-5.el5_4.3

cyrus-sasl-md5-2.1.22-5.el5_4.3



[root@mail etc]# rpm -e $(rpm -qa |grepcyrus-sasl) --nodeps

[root@mail etc]# rpm -qa |grep sasl |wc -l

0


3[root@mail etc]# cd/usr/local/src/


[root@mail src]# ls

installpack sourcepack //源码文件都放在sourcepack下面,要安装的文件放在installpack下面



三、安装MYSQLApachePhp


1、安装并配置mysql


(1)、创建mysql用户和组


root@mail sourcepack]# cd sourcepack/

root@mail sourcepack]# chmod 777 *

[root@mail sourcepack]# tar zxvfmysql-5.1.47.tar.gz -C ../installpack/

[root@mail installpack]# ls

mysql-5.1.47

[root@mail installpack]# cd mysql-5.1.47/

[root@mail mysql-5.1.47]#


[root@mail mysql-5.1.47]# groupadd mysql

[root@mail mysql-5.1.47]# useradd -g mysql-s /sbin/nologin mysql


(2)、安装mysql


[root@mail mysql-5.1.47]#./configure--prefix=/usr/local/mysql --with-charset=utf8

--with-extra-charsets=complex --enable-thread-safe-client--with-big-tables --with-ssl

--with-embedded-server--enable-local-infile --enable-assembler --with-plugins=innobase

--with-plugins=partition --with-low-memory --with-mysqld-ldflags=-all-static

--with-client-ldflags=-all-static



[root@mail mysql-5.1.47]# make

[root@mail mysql-5.1.47]# make install

[root@mail mysql-5.1.47]# cpsupport-files/my-huge.cnf /etc/my.cnf


[root@mail mysql-5.1.47]# cd/usr/local/mysql/

[root@mail mysql]# bin/mysql_install_db--user=mysql


[root@mail mysql]# chown -R root .//修改目录权限

[root@mail mysql]# chown -R mysql var

[root@mail mysql]# chgrp -R mysql .


[root@mail mysql]# bin/mysqld_safe--user=mysql &//后台启动mysql

[1] 9006

[root@mail mysql]# 130930 08:56:12mysqld_safe Logging to '/usr/local/mysql/var/mail.beijihu.com.err'.

130930 08:56:12 mysqld_safe Starting mysqlddaemon with databases from /usr/local/mysql/var


[root@mail sourcepack]# netstat -anlt |grep3306//Mysql 端口号查看


tcp00 0.0.0.0:33060.0.0.0:*LISTEN






(3)开机启动mysql


[root@mail mysql]# cpshare/mysql/mysql.server /etc/init.d/mysqld

[root@mail mysql]# chkconfig --add mysqld

[root@mail mysql]# cd /etc/init.d/

[root@mail init.d]# chmod +x mysqld

[root@mail init.d]# chkconfig --list mysqld

mysqld0:off1:off2:on3:on4:on5:on6:off

[root@mail init.d]# service mysqld start

Starting MySQL[OK]




(4)创建本地登录和远程登录帐号密码


[root@mail init.d]# cp /usr/local/mysql/bin/*/sbin/


[root@mail init.d]# mysqladmin -u root -hlocalhost password 'aa123456'//本机登录


[root@mail init.d]# mysql -u root -p

Enter password:

Welcome to the MySQL monitor.Commands end with ; or \g.

Your MySQL connection id is 2

Server version: 5.1.47-log Sourcedistribution


Copyright (c) 2000, 2010, Oracle and/or itsaffiliates. All rights reserved.

This software comes with ABSOLUTELY NOWARRANTY. This is free software,

and you are welcome to modify andredistribute it under the GPL v2 license


Type 'help;' or '\h' for help. Type '\c' toclear the current input statement.


mysql> show databases;

+--------------------+

| Database|

+--------------------+

| information_schema |

| mysql|

| test|

+--------------------+

3 rows in set (0.00 sec)


mysql> grant all privileges on *.* toroot@'%' identified by 'aa123456' with grant option;//

程登登录

Query OK, 0 rows affected (0.00 sec)


(5) 、配置文件搜索路径

[root@mail installpack]# echo"/usr/local/mysql/lib/mysql" >> /etc/ld.so.conf

[root@mail installpack]# ldconfig


2、安装apache

(1)解压文件

[root@mail sourcepack]# tar zxvfhttpd-2.2.15.tar.gz -C ../installpack/


(2)、安装apache


[[email protected]]# ./configure --prefix=/usr/local/apache2 --with-mpm=worker--enable-so --enable-mods-shared=all --enable-moduls=most --enable-rewrite --enable-heades --disable-status --enable-dav --enable-dav-fs --enable-dav-lock--enable-deflate --enable-suexec --with-suexec-caller=daemon --with-suexec-docroot=/var/www


// 这个地方比较重要,我们启用了apache的 suexec功能,可以用/usr/local/apache2/bin/suexec -V 查看相关的路径, 后来才发现在postfix一些相关的配置文件中默认了/var/www/extsuite的路径;编译的时候加入--with-suexec-caller=daemon 默认是www,但一般apache的运行用户是nobody或者daemon,这里我们是httpd2.2以上版本,用户是daemon,所以指定这个参数,否则suexec不能被运行。不熟悉Apache可以参考这位网友写的http://blog.chinaunix.net/uid-8223172-id-2511665.html或文档http://man.chinaunix.net/newsoft/ApacheMenual_CN_2.2new/suexec.html


[[email protected]]#make

[[email protected]]#make install



(3)、修改配置文件

修改apache配置文件

#vi/usr/local/apache2/conf/httpd.conf
找到DocumentRoot “/usr/local/apache2/htdocs”
修改为:DocumentRoot “/var/www”(后文中我们还会注释掉此行,以启用虚拟主机)

找到<Directory “/usr/local/apache2/htdocs”>
修改为:<Directory “/var/www”>

找到
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny fromall //这句改为Allow from all
</Directory>


启动apache
#/usr/local/apache2/bin/apachectl start如果没有创建/var/www 文件夹在启动时会提示错误,在/var下创建www目录




(4)、开机自启动

[root@mail bin]# echo"/usr/local/apache2/bin/apachectl start">>/etc/rc.local


3、安装php


(1)、解压[root@mailsourcepack]# tar zxvf php-5.2.13.tar.gz -C ../installpack/



[[email protected]]#./configure --prefix=/usr/local/php5

--with-apxs2=/usr/local/apache2/bin/apxs--with-mysql=/usr/local/mysql/

--with-mysqli=/usr/local/mysql/bin/mysql_config--with-pdo-mysql=/usr/local/mysql/

--enable-soap--with-gd --enable-sockets --enable-mbstring --disable-ipv6 --enable-exif--with-zlib --with-curl -with-curlwrappers --enable-calendar --with-gettext--enable-gd-native-ttf

--enable-zend-multibyte--with-bz2 --with-jpeg-dir --with-png-dir --with-freetype-dir--with-iconv-dir --with-libxml-dir --enable-ftp --with-iconv-dir


[[email protected]]# make

[[email protected]]# make install


[[email protected]]# cp php.ini-dist /usr/local/php5/lib/php.ini


(2)、配置apache 配置文件加载PhP模块;


#vi /usr/local/apache2/conf/httpd.conf


注意一下 105


LoadModule php5_modulemodules/libphp5.so


360AddType application/x-gzip .gz .tgz后添加


AddType application/x-httpd-php .php .phtml

AddType application/x-httpd-php-source .phps

找到Directory index 后面添加 index.php





(3)、重启apache 测试php

[root@mail sourcepack]#/usr/local/apache2/bin/apachectl stop

[root@mail sourcepack]#/usr/local/apache2/bin/apachectl start

# cd /var/www/

[root@mail www]# vim index.php

<? phpinfo(); ?>


测试页正常


你可能感兴趣的:(postfix,amavisd,垃圾邮件过滤)