2014-07-13 20:14:24
来 源
中存储网
Postfix
安装系统环境(centos 6.2)首先安装 yum -y install gcc gcc-c++    gcc编译插件    yum -y install make        make 插件    yum -y install wget        w

安装系统环境(centos 6.2)

首先安装 yum -y  install gcc gcc-c++          gcc编译插件

         yum -y  install make                 make 插件

         yum -y  install wget                 wget 插件

apache 安装(httpd-2.4.2.tar.gz)<apache 的安装需要先安装3个插件,apr、apr-util、pcre>

1.首先安装apr-1.4.5.tar.gz 插件

   tar zxvf apr-1.4.5.tar.gz

   cd apr-1.4.5

   ./configure  --prefix=/usr/local/apr

   make && make install

2.安装apr-util.1.4.1.tar.gz 插件(如果安装1.3.x 版本以下的插件,在apache安装时还是会提示无法发现)

   tar zxvf apr-util.1.4.1.tar.gz

   cd apr-util.1.4.1

   ./configure --wiht-apr=/usr/local/apr

   make && make install

3.安装pcre-8.30.tar.gz

   tar zxvf pcre-8.30.tar.gz

   cd pcre-8.30

   ./configure --prefix=/usr/local/pcre

   make && make install

4.安装apache 

  tar zxvf httpd-2.4.2.tar.gz

  cd httpd-2.4.2

  ./configure --prefix=/usr/local/apache --enable-module=so --with-pcre=/usr/local/pcre

  make && make install

 apache测试

 关闭防火墙service iptables stop 

 修改selinux  进入config配置文件中selinux=disabled

 重启apache /usr/local/apache/bin/apachectl start

 然后在客户端访问,出现It works 表示安装成功   

**********************************************************************************************************

**********************************************************************************************************

mysql安装(mysql-5.5.9.tar.gz)

安装mysql之前需要先安装cmake

1.安装cmake-2.8.4.tar.gz

 tar zxvf cmake-2.8.4.tar.gz

 cd cmake-2.8.4

 ./configure 

 make && make install

2.安装ncurses-devel(如果不装该插件,在mysql编译时会提示Could NOT find Curses )

 yum install ncurses-devel

3.安装mysql

 tar zxvf mysql-5.5.9.tar.gz

 cd mysql-5.5.9

 groupadd mysql

 useradd -g mysql mysql

 mkdir /usr/local/mysql

 mkdir /usr/local/mysql/data 

 cmake .

 -DCMAKE_INSTALL_PREFIX=/usr/local/mysql/

 -DMYSQL_DATADIR=/usr/local/mysql/data

 -DWITH_INNOBASE_STORAGE_ENGINE=1

 -DMYSQL_TCP_PORT=3306

 -DMYSQL_UNIX_ADDR=/usr/local/mysql/data/mysql.sock

 -DMYSQL_USER=mysql

 -DWITH_DEBUG=0

 make && make install

 /usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data (初始化数据库

 cp mysql/support-files/my-large.cnf  /etc/my.cnf (mysql的配置文件)

 cp support-files/mysql.server /etc/init.d/mysqld  (mysql启动脚本)

 chmod 755 /etc/init.d/mysqld (修改权限)

 chown -R mysql:mysql /usr/local/mysql(修改权限)

 最后启动数据库 /etc/init.d/mysqld start

注:mysql 数据库安装时先配置,然后进行权限的分组,这样才不会出现问题

***********************************************************************************************************

***********************************************************************************************************

php安装(php-5.3.6.tar.bz2)

php安装时需要先安装几个组件(gettext、libpng、jpeg、freetype、libxml、zlib、curl)

1.安装jpegsrc.v8b.tar.gz

 mkdir /usr/local/jpeg

 mkdir -p /usr/local/jpeg/bin

 mkdir -p /usr/local/jpeg/lib

 mkdir -p /usr/local/jpeg/include

 mkdir -p /usr/local/jpeg/man

 mkdir -p /usr/local/jpeg/man1

 mkdir -p /usr/local/jpeg6man/man1

 tar zxvf jpegsrc.v8b.tar.gz

 cd jpeg.8b

 ./configure --prefix=/usr/local/jpeg --enable-shared --enable-static

 make && make install

2.安装zlib(这里选用系统自带的) 

 yum install zlib

 yum install zlib-devel

3.安装gettext-0.18.1.1.tar.gz

  tar zxvf gettext-0.18.1.1.tar.gz

  cd gettext-0.18.1.1

  ./configure --prefix=/usr/local/gettext

  make && make install

4.安装libpng-1.4.4.tar.gz

  tar zxvf libpng-1.4.4.tar.gz

  cd libpng-1.4.4

  ./configure --prefix=/usr/local/libpng

  make install 

5.安装freetype-2.4.3.tar.gz

  tar zxvf freetype-2.4.3.tar.gz

  cd freetype-2.4.3

  ./configure =/usr/local/freetype 

   make && make install

6.安装 gd-2.0.35.tar.gz 

  tar zxvf gd-2.0.35.tar.gz 

  cd gd-2.0.35

  ./configure --prefix=/usr/local/gd -with-jpeg=/usr/local/jpeg/ --with-png=/usr/local/libpng --with-zlib --with-freetype=/usr/local/freetype

  make && make install 

7.安装libxml

 yum install libxml2

 yum install libxml2-devel

8.安装php-5.3.6.tar.bz2

  tar jxvf php-5.3.6.tar.bz2

  cd php-5.3.6

  ./configure --prefix=/usr/local/usr/php --with-mysql=/usr/local/mysql --with-apxs2=/usr/local/apache/bin/apxs --with-freetype=/usr/local/freetype 

  --with-png=/usr/local/libpng --with-jpeg-dir=/usr/local/jpeg --with-gettext=/usr/local/gettext --with-gd=/usr/local/gd --with-curl --with-libxml2

  --enable-mbstring --enable-so

  make && make install

 为了支持能够访问php文件,需要在/usr/local/apache/htdocs/httpd.conf配置中添加

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

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

 重启一下apache,测试一下php是否安装成功

  /usr/local/apache/bin/apachectl stop 

  /usr/local/apache/bin/apachectl start

***********************************************************************************************************

***********************************************************************************************************

postfixadmin安装(postfixadmin-2.3.5.tar.gz)

1.首先为postfix在mysql数据库中添加一个用户

/usr/local/mysql/bin/mysql -u root -p

mysql>create database postfix;

mysql>grant all privileges on postfix.* to postfix@localhost identified by 'postfix';

mysql>flush privileges;

2.安装postfixadmin

 tar zxvf postfixadmin-2.3.5.tar.gz

 mv postfixadmin-2.3.5 /usr/local/apache/htdocs/postfixadmin   (我是将postfixadmin放在apache的htdocs目录下)

 cd /usr/local/apache/htdocs/postfixadmin

 cp config.inc.php config.inc.php.bak (先将config.inc.php备份一下)

 vi config.inc.php (修改配置文件)

$CONF['configured'] = true;

$CONF['default_language'] = 'cn'; ###让postfixadmin 支持中文

$CONF['database_type'] = 'mysql';

$CONF['database_host'] = 'localhost';

$CONF['database_user'] = 'postfix';

$CONF['database_password'] = 'postfix';

$CONF['database_name'] = 'postfix';

$CONF['domain_in_mailbox'] = 'yes';

$CONF['encrypt'] = 'md5';

访问postfixadmin  http://168.192.122.31/postfixadmin 检测相关创建是否加载成功

如果页面出现该提示信息,你需要安装一下imap插件

Warning: Depends on: IMAP functions - NOT FOUND

To install IMAP support, install php5-imap

Without IMAP support, you won't be able to create subfolders when creating mailboxes. 

安装imap插件(imap.tar.Z)

yum -y install openssl openssl-devel pam pam-devel(安装依赖包)

tar -zxvf imap.tar.Z

cd imap-2007f 

make lnp EXTRACFLAGS="-fPIC -I/usr/include/openssl" IP6=4 (服务器的系统是X86_64的,需要make这句话否则安装时会报错)

echo "set disable-plaintext nil" > /etc/c-client.cf

mkdir /usr/local/imap

mkdir /usr/local/imap/include

mkdir /usr/local/imap/lib

chmod -R 077 /usr/local/imap

cp imapd/imapd /usr/sbin

cp c-client/*.h /usr/local/imap/include/

cp c-client/*.c /usr/local/imap/lib/

cp c-client/c-client.a /usr/local/imap/lib/libc-client.a

cd /home/jdrc/php-5.3.6/ext/imap (进入php源文件中的ext目录下的imap目录)

/usr/local/php/bin/phpize (执行一下phpize) phpize文件在php安装目录下的bin文件中

./configure --with-php-config=/usr/local/php/bin/php-config --with-imap-ssl --with-imap=/usr/local/imap

make && make install

编辑php.ini

改magic_quotes_gpc=off

加入extension=“imap.so”

重启apache 

1.打开http://122.224.97.226/postfix/setup.php就可以开始postfixadmin的安装了,安装完后可以进行添加域和用户的操作

2.设置setup密码 (如装了php5-imap还是提示无imap,则直接改掉setup.php里的变为if ( $f_imap_open == 0) 跳过检查)

3.打开postfixadmin配置文件config.inc.php,找到$CONF['setup_password'] =‘changme’这一行,把值改为刚才setup生成的加密密码,如

“84ab1a59d0a50933fffb7cf2c3483ac9:65a5b14ab41e35c53c85f6806eb1182765ecf866”

4.输入管理员的邮箱 和密码点击 Add Admin 按扭

最后打开http://122.224.97.226/postfix/login.php即可登录进行相关邮件管理的操作

*********************************************************************************************************

*********************************************************************************************************

安装postfix(postfix-2.5.5.tar.gz) 

yum install db*-devel

groupadd -g 89 postfix

useradd -u 89 -g postfix -s /sbin/nologin -d /dev/null postfix

groupadd -g 90 postdrop

tar zxvf postfix-2.5.5.tar.gz

cd postfix-2.5.5

make -f Makefile.init makefiles 'CCARGS=-DHAS_MYSQL -I/usr/local/mysql/include/ -DUSE_SASL_AUTH -DDEF_SERVER_SASL_TYPE="dovecot"'

'AUXLIBS=-L/usr/local/mysql/lib -lmysqlclient -lz -lm'  (-I/usr/local/mysql/include/  -L/usr/local/mysql/lib 该路径一定不要写错了,否则安装时会报错 )

make && make install

cd /etc/postfix

mv main.cf main.cf.bak

touch main.cf

vi main.cf

command_directory = /usr/sbin

config_directory = /etc/postfix

daemon_directory = /usr/libexec/postfix

data_directory = /var/lib/postfix

debug_peer_level = 2

html_directory = no

mail_owner = postfix

mailbox_size_limit = 209715200

mailq_path = /usr/bin/mailq

manpage_directory = /usr/local/man

message_size_limit = 52428800

newaliases_path = /usr/bin/newaliases

queue_directory = /var/spool/postfix

readme_directory = no

sample_directory = /etc/postfix

sendmail_path = /usr/sbin/sendmail

setgid_group = postdrop

unknown_local_recipient_reject_code = 550

mydomain = lab

myhostname = localhost.lab

mynetworks = 0.0.0.0/0

myorigin = $mydomain

###########################################

virtual_alias_maps = mysql:/etc/postfix/mysql/mysql_virtual_alias_maps.cf

virtual_gid_maps = static:89  (用户组的id)

virtual_mailbox_base = /data/mailbox/

virtual_mailbox_domains = mysql:/etc/postfix/mysql/mysql_virtual_domains_maps.cf

virtual_mailbox_maps = mysql:/etc/postfix/mysql/mysql_virtual_mailbox_maps.cf

virtual_transport = virtual

virtual_uid_maps = static:89  (用户的id)

###########################################

message_size_limit = 52428800

mailbox_size_limit = 209715200

virtual_mailbox_limit = 209715200

virtual_create_maildirsize = yes

virtual_mailbox_extended = yes

virtual_mailbox_limit_maps = mysql:/etc/postfix/mysql/mysql_virtual_mailbox_limit_maps.cf

virtual_mailbox_limit_override = yes

virtual_overquota_bounce = yes

##########################################

smtpd_sasl_auth_enable = yes

smtpd_sasl_path = /var/run/dovecot/auth-client(该路径来源于dovecot文件中,后面dovecot会有相关提示)

broken_sasl_auth_clients = yes

smtpd_recipient_restrictions = permit_mynetworks,

                  permit_sasl_authenticated,

                  reject_invalid_hostname,

                  reject_non_fqdn_hostname,

                  reject_unknown_sender_domain,

                  reject_non_fqdn_sender,

                  reject_non_fqdn_recipient,

                  reject_unknown_recipient_domain,

                  reject_unauth_pipelining,

                  reject_unauth_destination

smtpd_sasl_security_options = noanonymous

smtpd_sasl_local_domain =

smtpd_banner = $myhostname

###########################################

mkdir /etc/postfix/mysql

cd /etc/postfix/mysql

touch mysql_virtual_alias_maps.cf mysql_virtual_domains_maps.cf mysql_virtual_mailbox_maps.cf mysql_virtual_mailbox_limit_maps.cf

vi mysql_virtual_alias_maps.cf

user = postfix

password = postfix

hosts = localhost

dbname = postfix

table = alias

select_field = goto

where_field = address

vi mysql_virtual_domains_maps.cf

user = postfix

password = postfix

hosts = localhost

dbname = postfix

table = domain

select_field = description

where_field = domain

vi mysql_virtual_mailbox_maps.cf

user = postfix

password = postfix

hosts = localhost

dbname = postfix

table = mailbox

select_field = maildir

where_field = username

vi mysql_virtual_mailbox_limit_maps.cf

user = postfix

password = postfix

hosts = localhost

dbname = postfix

table = mailbox

select_field = quota

where_field = username

重启postfix  /usr/sbin/postfix restart

************************************************************************************************

************************************************************************************************

dovecot 安装的dovecot-1.2.9.tar.gz

yum install pam*   

mkdir -p /data/mailbox

chown -R postfix.postfix /data/mailbox

useradd -d /dev/null -s /sbin/nologin dovecot

tar zxvf dovecot-1.2.9.tar.gz

cd dovecot-1.2.9

./configure --prefix=/usr/local/dovecot --sysconfdir=/etc/dovecot --with-sql --with-sql-drivers --with-pam --with-mysql 

CPPFLAGS=-I/usr/local/mysql/include/mysql LDFLAGS=-L/usr/local/mysql/lib/mysql

make && make install

cd /etc/dovecot  

cp dovecot-example.conf dovecot.conf

vi dovecot.conf 

protocols=imap imaps pop3 pop3s

listen=*

disable_plaintext_auth = no

ssl= no

auth_debug = yes

log_path = /var/log/pop3.log

mail_location =maildir:/data/mailbox/%u

#mail_location = mbox:~/mail:INBOX=/var/mail/%u

pop3_uidl_format=%08Xu%08Xv

mail_uid = 89

mail_gid = 89

first_valid_uid = 89

auth default {

mechanisms = PLAIN LOGIN

args = /etc/dovecot/dovecot-sql.conf

}

userdb sql {

args = /etc/dovecot/dovecot-sql.conf

}

socket listen {

client {

path = /var/run/dovecot/auth-client (1.该路径和postfix目录下的main.cf 文件中的smtpd_sasl_path保持一致2.在/var/run 目录下创建一个dovecot文件,否则在启动dovecot时会报错)

mode = 0660

user = postfix

group = postfix

}

}

}

cp dovecot-sql-example.conf dovecot-sql.conf

vi dovecot-sql.conf   /修改dovecot-sql文件     

driver = mysql

connect = host=localhost dbname=postfix user=postfix password=postfix

default_pass_scheme = MD5 

###这里修改为 MD5 是为了与 postfixadmin 想符合,不然验证不过去总提示密码错误!

password_query = SELECT password FROM mailbox WHERE username = '%u'

user_query = SELECT maildir, 89 as uid, 89 as gid FROM mailbox WHERE username = '%u'

/usr/local/dovecot/sbin/dovecot

声明: 此文观点不代表本站立场;转载须要保留原文链接;版权疑问请联系我们。