一:安装配置dns服务器
[root@zzu ~]# yum install -y bind bind-chroot caching-nameserver[root@zzu ~]# cd /var/named/chroot/etc/
[root@zzu etc]# cp -p named.caching-nameserver.conf named.conf[root@zzu etc]# vim named.conf
15 listen-on port 53 { any; };
27 allow-query { any; };
28 allow-query-cache { any; };
37 match-clients { any; };
38 match-destinations { any; };
[root@zzu etc]# vim named.rfc1912.zones
21 zone "zzu.com" IN {
22 type master;
23 file "zzu.com.db";
24 allow-update { none; };
25 };
32 zone "1.168.192.in-addr.arpa" IN {
33 type master;
34 file "1.168.192.db";
35 allow-update { none; };
36 };
[root@zzu named]# cp -p named.local 1.168.192.db
[root@zzu named]# vim 1.168.192.db
1 IN PTR 192.168.1.100
[root@zzu named]# chkconfig named on
[root@zzu named]# service named start
Starting named: [ OK ]
[root@zzu named]# rndc reload
server reload successful
[root@zzu named]# dig -t mx zzu.com
; <<>> DiG 9.3.6-P1-RedHat-9.3.6-4.P1.el5 <<>> -t mx zzu.com
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 17274
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 2
;; QUESTION SECTION:
;zzu.com. IN MX
;; ANSWER SECTION:
zzu.com. 86400 IN MX 10 mail.zzu.com.
;; AUTHORITY SECTION:
zzu.com. 86400 IN NS ns.zzu.com.
;; ADDITIONAL SECTION:
mail.zzu.com. 86400 IN A 192.168.1.100
ns.zzu.com. 86400 IN A 192.168.1.100
;; Query time: 2 msec
;; SERVER: 192.168.1.100#53(192.168.1.100)
;; WHEN: Sat Apr 14 20:17:01 2012
;; MSG SIZE rcvd: 95
#修改主机的名字
[root@zzu named]# vim /etc/sysconfig/network
HOSTNAME=mail.zzu.com
[root@zzu named]# vim /etc/hosts
127.0.0.1 mail.zzu.com
重启机器
[root@zzu named]# init 6
[root@mail ~]# mount /dev/cdrom /mnt/cdrom/
二:lamp环境的搭建
[root@mail ~]# ll
total 83096
-rw-r--r-- 1 root root 5322082 Apr 14 20:35 httpd-2.2.19.tar.bz2
-rw-r--r-- 1 root root 68452352 Apr 14 20:35 mysql-5.5.15-linux2.6-i686.tar.gz
-rw-r--r-- 1 root root 11144328 Apr 14 20:35 php-5.3.7.tar.bz2
2.1#安装apache软件:
[root@mail ~]# tar -jxvf httpd-2.2.19.tar.bz2 -C /usr/local/src/
[root@mail ~]# cd /usr/local/src/httpd-2.2.19/
[root@mail ~]# cd /usr/local/src/httpd-2.2.19/
[root@mail httpd-2.2.19]#./configure --prefix=/usr/local/apache2 --enable-so --enable-rewrite
[root@mail httpd-2.2.19]#make
[root@mail httpd-2.2.19]#make install
修改系统变量
[root@mail apache2]# vim /etc/profile
44 PATH=$PATH:/usr/local/apache2/bin/
[root@mail ~]# source /etc/profile
[root@mail ~]# echo $PATH
/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/apache2/bin/
[root@mail ~]# apachectl start
[root@mail ~]# netstat -tupln|grep http
tcp 0 0 :::80 :::* LISTEN 4726/httpd
连接库文件
[root@mail ~]# vim /etc/ld.so.conf.d/http.conf
/usr/local/apache2/lib
[root@mail ~]# ldconfig -v|grep apache
/usr/local/apache2/lib:
2.2安装mysql软件:
[root@mail ~]# service sendmail stop
Shutting down sm-client: [ OK ]
Shutting down sendmail: [ OK ]
[root@mail ~]# tar -zxvf mysql-5.0.81.tar.gz -C /usr/local/src/
[root@mail ~]# cd /usr/local/src/mysql-5.0.81/
[root@mail mysql-5.0.81]# ./configure --prefix=/usr/local/mysql
[root@mail mysql-5.0.81]#make
[root@mail mysql-5.0.81]#make install
[root@mail mysql-5.0.81]# cp support-files/my-medium.cnf /etc/my.cnf
[root@mail mysql-5.0.81]# /usr/local/mysql/bin/mysql_install_db --user=mysql
[root@mail mysql-5.0.81]# chown -R root:mysql /usr/local/mysql
[root@mail mysql-5.0.81]# chown -R mysql /usr/local/mysql/var
[root@mail mysql-5.0.81]# vim /etc/ld.so.conf.d/mysql.conf
/usr/local/mysql/lib/mysql/
[root@mail mysql-5.0.81]# ldconfig -v|grep mysql
/usr/local/mysql/lib/mysql:
libmysqlclient.so.15 -> libmysqlclient.so.15.0.0
[root@mail mysql-5.0.81]# /usr/local/mysql/bin/mysqld_safe --user=mysql & (卡主不动的话,请按enter)
[root@mail mysql-5.0.81]# cp support-files/mysql.server /etc/init.d/mysqld
[root@mail mysql-5.0.81]# chmod +x /etc/init.d/mysqld
[root@mail mysql-5.0.81]# chkconfig --add mysqld
[root@mail mysql-5.0.81]# chkconfig mysqld on
[root@mail mysql-5.0.81]# service mysqld start
Starting MySQL [ OK ]
2.3安装php软件
[root@mail ~]# tar -ixvf php-5.3.7.tar.bz2 -C /usr/local/src/
[root@mail ~]# cd /usr/local/src/php-5.3.7/
[root@mail php-5.3.7]#
./configure --prefix=/usr/local/php5
--enable-mbstring --with-apxs2=/usr/local/apache2/bin/apxs
--with-mysql=/usr/local/mysql --with-config-file-path=/usr/local/php5
[root@mail php-5.3.7]# make
[root@mail php-5.3.7]# make install
[root@mail php-5.3.7]# cp php.ini-production /usr/local/php5/php.ini
修改主配置文件
[root@mail php-5.3.7]# vim /usr/local/apache2/conf/httpd.conf
DirectoryIndex index.php index.html
AddType application/x-httpd-php .php
2.4测试php与apache和mysql的连接情况
[root@mail ~]# cd /usr/local/apache2/htdocs/
[root@mail htdocs]# ls
index.html
[root@mail htdocs]# mv index.html index.php
三:安装postfix源码
[root@mail htdocs]# rpm -e sendmail --nodeps
[root@mail ~]# groupadd -g 1200 postdrop
[root@mail ~]# groupadd -g 1000 postfix
[root@mail ~]# useradd -M -u 1000 -g postfix -G postdrop -s /sbin/nologin postfix
[root@mail ~]# tar -zxvf postfix-2.8.2.tar.gz -C /usr/local/src/
[root@mail ~]# cd /usr/local/src/postfix-2.8.2/
[root@mail postfix-2.8.2]# make -f Makefile.init makefiles
'CCARGS=-DHAS_MYSQL
-I/usr/local/mysql/include/mysql
-DUSE_SASL_AUTH -I/usr/local/include/sasl'
'AUXLIBS=-L/usr/local/mysql/lib/mysql -lmysqlclient
-lz -lm -L/usr/local/lib -lsasl2'
此处在执行的过程中一定注意mysql的库文件和头文件的路径是否正确,若不正确的话只需要进行相应的连接即可(ln -ns)
[root@mail postfix-2.8.2]# make
[root@mail postfix-2.8.2]# make install
/etc/postfix/main.cf
/etc/aliases
/usr/bin/newaliases
配置postfix
[root@mail postfix-2.8.2]# vim /etc/postfix/main.cf
76 myhostname = mail.zzu.com
83 mydomain = zzu.com
99 myorigin = $mydomain
113 inet_interfaces = all
162 mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
260 mynetworks = 192.168.1.0/24, 127.0.0.0/8
[root@mail postfix-2.8.2]# postfix start
postfix/postfix-script: starting the Postfix mail system
[root@mail postfix-2.8.2]# postfix check
[root@mail postfix-2.8.2]# service postfix restart
postfix: unrecognized service
[root@mail postfix-2.8.2]# mkdir /abc
[root@mail postfix-2.8.2]# cd /abc/
[root@mail abc]# cp /mnt/cdrom/Server/postfix-2.3.3-2.1.el5_2.i386.rpm ./
[root@mail abc]# rpm2cpio postfix-2.3.3-2.1.el5_2.i386.rpm |cpio -id
16333 blocks
[root@mail abc]# cp etc/rc.d/init.d/postfix /etc/rc.d/init.d/
[root@mail abc]# service postfix restart
Shutting down postfix: [ OK ]
Starting postfix: [ OK ]
[root@mail abc]# chkconfig postfix on
[root@mail abc]# chkconfig --add postfix
[root@mail abc]# chkconfig --list postfix
postfix 0:off 1:off 2:on 3:on 4:on 5:on 6:off
验证postfix
[root@mail abc]# useradd user1
[root@mail abc]# useradd user2
[root@mail abc]# echo "123"|passwd --stdin user1
Changing password for user user1.
passwd: all authentication tokens updated successfully.
[root@mail abc]# echo "123"|passwd --stdin user2
Changing password for user user2.
passwd: all authentication tokens updated successfully.
[root@mail ~]# telnet mail.zzu.com 25
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
220 mail.zzu.com ESMTP Postfix
mail from:[email protected]
250 2.1.0 Ok
rcpt to:[email protected]
250 2.1.5 Ok
data
354 End data with <CR><LF>.<CR><LF>
user1--------root
.
250 2.0.0 Ok: queued as 6C8E236BB9F
quit
221 2.0.0 Bye
Connection closed by foreign host.
You have new mail in /var/spool/mail/root
使用管理员进行查看
[root@mail ~]# mail
N 2 [email protected] Sun Apr 15 00:08 13/433
& list 2
Message 2:
From [email protected] Sun Apr 15 00:08:13 2012
X-Original-To: [email protected]
Delivered-To: [email protected]
Date: Sun, 15 Apr 2012 00:07:27 +0800 (CST)
From: [email protected]
user1--------root 内容
五:安装dovecot
[root@mail ~]#useradd -M -s /sbin/nologin dovecot
[root@mail ~]# tar -zxvf dovecot-1.1.4.tar.gz -C /usr/local/src/
[root@mail ~]# cd /usr/local/src/dovecot-1.1.4/
[root@mail dovecot-1.1.4]#./configure --sysconfdir=/etc --with-mysql
[root@mail dovecot-1.1.4]##make
[root@mail dovecot-1.1.4]##make install
配置
[root@mail dovecot-1.1.4]# cp /etc/dovecot-example.conf /etc/dovecot.conf
[root@mail dovecot-1.1.4]# vim /etc/dovecot.conf
23 protocols = imap pop3
87 ssl_disable = yes
208 mail_location = maildir:~/Maildir
[root@mail dovecot-1.1.4]# vim /etc/postfix/main.cf
home_mailbox = Maildir/
[root@mail pam.d]# vim /etc/pam.d/dovecot 增加对dovecot的pam的相关认证
auth required pam_nologin.so
auth include system-auth
account include system-auth
session include system-auth
[root@mail pam.d]# /usr/local/sbin/dovecot -c /etc/dovecot.conf
测试接收服务器
[root@mail ~]# telnet mail.zzu.com 110
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
+OK Dovecot ready.
user user2
+OK
pass 123
+OK Logged in.
list
+OK 1 messages:
1 390
.
retr 1
+OK 390 octets
Return-Path: <[email protected]>
X-Original-To: [email protected]
Delivered-To: [email protected]
Received: from mail.zzu.com (mail.zzu.com [127.0.0.1])
by mail.zzu.com (Postfix) with SMTP id 98E5236BB9F
for <[email protected]>; Sun, 15 Apr 2012 00:36:11 +0800 (CST)
Message-Id: <[email protected]>
Date: Sun, 15 Apr 2012 00:36:11 +0800 (CST)
From: [email protected]
111111
.
六:安装webmail方便进行管理
[root@mail ~]# tar -zxvf squirrelmail-webmail-1.4.22.tar.gz -C /usr/local/apache2/htdocs/
[root@mail ~]# cd /usr/local/apache2/htdocs/
[root@mail htdocs]# mv squirrelmail-webmail-1.4.22/ webmail
[root@mail htdocs]# cd /usr/local/apache2/htdocs/webmail/
[root@mail webmail]# mkdir -p attach data
[root@mail webmail]# chown -R daemon:daemon attach/ data/
[root@mail webmail]# chmod 730 attach/
[root@mail webmail]# cp config/config_default.php config/config.php
[root@mail webmail]# vim config/config.php
118 $domain = 'zzu.com';
499 $data_dir = '/var/local/apache2/htdocs/webmail/data/';
517 $attachment_dir = '/var/local/apache2/htdocs/webmail/attach/';
[root@mail webmail]# /usr/local/apache2/bin/apachectl start
测试webmail
七:安装extman
未完待续!
欢迎加入郑州阳仔的网络工程师自由交流群--132444800(请注明自己的身份,就说是51cto的博友)