配置IP地址
[iyunv@localhost ~]# vi /etc/rc.d/rc.local
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.
touch /var/lock/subsys/local
/usr/local/apache/bin/apachectl -k start
ifconfig eth0 192.168.5.49 netmask 255.255.255.0
route add default gw 192.168.5.11
sshd
Last login: Thu May 24 12:47:38 2012
[iyunv@localhost ~]# vi /etc/ssh/sshd_config
Port 22
ListenAddress 0.0.0.0
PermitRootLogin yes
[iyunv@localhost ~]# service sshd restart
Stopping sshd: [ OK ]
Starting sshd: [ OK ]
[iyunv@localhost ~]#
使用ssh软件连接上linux服务器
安装过了mysql不过老长时间没用,忘了密码了,老规矩!改!硬改!
mysqld_safe --skip-grant-tables &
shell>mysqladmin -u root flush-privileges password "newpassword"
mysql>update user set password=password('新密码') WHERE User='root';
mysql>flush privileges;
挂载光盘到目录,安装sendmail和dovecot服务
建立文件目录结构
[iyunv@localhost /]# mkdir /a/{1,2,3,4,5,a,b,c,d,e} -p
挂载光盘文件到 /a/a
[iyunv@localhost /]# mount /dev/cdrom /a/a
mount: block device /dev/cdrom is write-protected, mounting read-only
[iyunv@localhost /]#
进入包目录
[iyunv@localhost /]# cd /a/a/Server/
[iyunv@localhost Server]# rpm -ivh sendmail-
然后按tab键盘两下不全命令
sendmail-8.13.8-8.el5.i386.rpm sendmail-devel-8.13.8-8.el5.i386.rpm
sendmail-cf-8.13.8-8.el5.i386.rpm sendmail-doc-8.13.8-8.el5.i386.rpm
[iyunv@localhost Server]# rpm -ivh sendmail-
[iyunv@localhost Server]# rpm -ivh sendmail-devel-8.13.8-8.el5.i386.rpm
warning: sendmail-devel-8.13.8-8.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:sendmail-devel ########################################### [100%]
[iyunv@localhost Server]#
[iyunv@localhost Server]# rpm -ivh sendmail-doc-8.13.8-8.el5.i386.rpm
warning: sendmail-doc-8.13.8-8.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:sendmail-doc ########################################### [100%]
[iyunv@localhost Server]#
[iyunv@localhost Server]# rpm -ivh sendmail-cf-8.13.8-8.el5.i386.rpm
warning: sendmail-cf-8.13.8-8.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:sendmail-cf ########################################### [100%]
[iyunv@localhost Server]#
[iyunv@localhost Server]# rpm -ivh sendmail-8.13.8-8.el5.i386.rpm
warning: sendmail-8.13.8-8.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
package sendmail-8.13.8-8.el5.i386 is already installed
[iyunv@localhost Server]#
这样就完成了sendmail的安装
我们继续安装pop3,imap协议
[iyunv@localhost Server]# rpm -ivh dovecot-1.0.7-7.el5.i386.rpm
warning: dovecot-1.0.7-7.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
error: Failed dependencies:
libmysqlclient.so.15 is needed by dovecot-1.0.7-7.el5.i386
libmysqlclient.so.15(libmysqlclient_15) is needed by dovecot-1.0.7-7.el5.i386
[iyunv@localhost Server]#
[iyunv@localhost Server]# rpm -ivh perl-DBI-1.52-2.el5.i386.rpm
warning: perl-DBI-1.52-2.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:perl-DBI ########################################### [100%]
[iyunv@localhost Server]#
[iyunv@localhost Server]# rpm -ivh mysql-5.0.77-4.el5_4.2.i386.rpm
warning: mysql-5.0.77-4.el5_4.2.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:mysql warning: /etc/my.cnf created as /etc/my.cnf.rpmnew
########################################### [100%]
[iyunv@localhost Server]#
[iyunv@localhost Server]# rpm -ivh dovecot-1.0.7-7.el5.i386.rpm
warning: dovecot-1.0.7-7.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:dovecot ########################################### [100%]
[iyunv@localhost Server]#
这样我们就安装好了pop3服务
我们设置,sendmail,支持对外即可!
[iyunv@localhost Server]# cd /etc/mail
备份源文件,然后再修改!切记!
[iyunv@localhost mail]# cat sendmail.mc > sendmail.mc.bak
[iyunv@localhost mail]# vi sendmail.mc
define(`UUCP_MAILER_MAX', `2000000')dnl 这个是邮箱的大小
sendmail单独设置每个账户的邮箱大小用quota
sendmail.cf中设置邮件发送的大小!
MaxMessageSize = 1048576
设置监听所有地址的数据
DAEMON_OPTIONS(`Port=smtp,Addr=0.0.0.0, Name=MTA')dnl
设置子进程验证smtp
DAEMON_OPTIONS(`Port=submission, Name=MSA, M=Ea')dnl
保存退出
生成cf的配置文件
[iyunv@localhost mail]# m4 sendmail.mc > sendmail.cf
[iyunv@localhost mail]# service sendmail restart
Shutting down sm-client: [ OK ]
Shutting down sendmail: [ OK ]
Starting sendmail: [ OK ]
Starting sm-client: [ OK ]
[iyunv@localhost mail]#
编辑dovecot文件支持pop3和imap服务
[iyunv@localhost etc]# vi /etc/dovecot.conf
protocols = imap imaps pop3 pop3s
[iyunv@localhost etc]# service dovecot restart
Stopping Dovecot Imap: [FAILED]
Starting Dovecot Imap: [ OK ]
[iyunv@localhost etc]#
查看端口是否开启!
[iyunv@localhost etc]# netstat -ant
tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTE
tcp 0 0 :::110 :::* LISTEN
tcp 0 0 :::143 :::* LISTE
25端口是发送
110,143分别是 pop3,imap协议接收
[iyunv@localhost etc]# useradd b
[iyunv@localhost etc]# passwd b
Changing password for user b.
New UNIX password:
BAD PASSWORD: it is WAY too short
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
使用foxmail测试成功
再使用foxmail测试imap的时候失败主要的原因是验证失败,使用windows自带的outlook可以测试成功!
这样的邮件系统不安全,因为任何人都可以通过这个服务器不需要验证发送邮件
我们加入一个安全验证到sendmail里面,
安装
修改认证方式
vi /usr/lib/sasl2/Sendmail.conf 里面指明了:pwcheck_method=saslauthd,不做修改
vi /etc/sysconfig/saslauthd 找到第7行的:MECH= 改成:MECH=shadow
保存
如下示列:
[iyunv@mail]# cat /usr/lib/sasl2/Sendmail.conf
pwcheck_method:saslauthd
[iyunv@mail]# cat /usr/lib/sasl2/smtpd.conf.rpmsave
log_level: 3
pwcheck_method: saslauthd
mech_list: PLAIN LOGIN
[iyunv@mail]# cat /etc/sysconfig/saslauthd
# Directory in which to place saslauthd's listening socket, pid file, and so
# on. This directory must already exist.
SOCKETDIR=/var/run/saslauthd
# Mechanism to use when checking passwords. Run "saslauthd -v" to get a list
# of which mechanism your installation was compiled with the ablity to use.
MECH=shadow
# Additional flags to pass to saslauthd on the command line. See saslauthd(8)
# for the list of accepted flags.
FLAGS=
[iyunv@mail]#testsaslauthd -u test -p 123456 (验证smtp)
0: OK "Success."