LAMP平台下构建Postfix邮件服务器
前言:
? 本人之前已經做過這個實驗,只是版本不同,今天本來想用全新版本的源碼包做實驗,但是以httpd-2.4.2.tar.gz的源碼包在配置虛擬主機這一塊我不知道如何配置,按照以前的配置總是報錯:AH00548: NameVirtualHost has no effect and will be removed in the next release /usr/local/apache2/conf/httpd.conf:491,在此糾結了很久,最終未果,就換了httpd-2.2.9的源碼包做的實驗,一路下來偶爾出點小插曲,但差不多都解決了,但是在登錄webmail界面的時候我的圖片不能正常顯示,檢查了配置文件,仍然沒有解決,請大家多多指教一下,下面是我在虛擬機上的配置過程:
先把我實驗的包大概說一下:
?
?
下面是實驗過程
[root@mail ~]# uname -a????????? ?//檢查系統環境
Linux mail 2.6.18-238.el5 #1 SMP Sun Dec 19 14:24:47 EST 2010 i686 i686 i386 GNU/Linux
[root@mail ~]#
[root@mail ~]# cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1?????????????? localhost localhost.localdomain
192.168.10.170????????? mail.chenkui.com????? //添加主機解析記錄
::1???????????? localhost6.localdomain6 localhost6
[root@mail ~]#
[root@mail ~]# cat /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=yes
HOSTNAME=mail?? 修改主機名
GATEWAY=192.168.10.1
[root@mail ~]#? init 6 //在此修改主機名要重啟才能生效
構建本地DVD yum源
安裝createrepo軟件包//在系統光盤中自帶有此軟件包
手動掛載光驅:mount /dev/cdrom /mnt Or /dev/dhc /mnt? 這個時候,進入/mnt就可以看到光盤上的文件了
[root@mail ~]# rpm -ivh /mnt/Server/createrepo-0.4.11-3.el5.noarch.rpm
warning: /mnt/Server/createrepo-0.4.11-3.el5.noarch.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing...??????????????? ########################################### [100%]
?? 1:createrepo???????????? ########################################### [100%]
[root@mail ~]#
然后修改/etc/yum.repos.d/rhel-debuginfo.repo,把里面的內容修改成如下:
[root@mail mnt]# vi /etc/yum.repos.d/rhel-debuginfo.repo
[Cluster]
enabled = 1???? //1表示repo中定義的源是啟用的,0為禁用
name = Cluster? //目錄名稱可自定義,在此我就把它定義為光盤中軟件的目錄名稱
baseurl = file:///mnt/Cluster? //把光盤掛載在哪個目錄下面,此處就定義哪個目錄
gpgcheck = 0?? //表示這個repo中下載的rpm將進行gpg的校驗,已確定rpm包的來源是有效和安全的,一般在此不啟用
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-beta,file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release//定義用于校驗的gpg密鑰,當不啟用的時候可以不定義該
url
[Server]
enabled = 1
name = Server
baseurl = file:///mnt/Server
gpgcheck = 1
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-beta,file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
[ClusterStorage]
enabled = 1
name = ClusterStorage
baseurl = file:///mnt/ClusterStorage
gpgcheck = 1
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-beta,file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
[VT]
enabled = 1
name = VT
baseurl = file:///mnt/VT
gpgcheck = 1
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-beta,file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
保存退出
?
?
構建DNS域名服務
有了以上的yum本地源,可以直接使用yum安裝相關包
[root@mail ~] yum install bind-* -y //-y表示默認確定安裝,不加-y后面會有交互式的提示
安裝緩存包,用于創建 named.conf 主配置文件
[root@mail ~] cd /var/named/chroot/etc/
[root@mail etc]# rpm -ivh /mnt/Server/caching-nameserver-9.3.6-16.P1.el5.i386.rpm
Preparing...??????????????? ########################################### [100%]
?? 1:caching-nameserver???? ########################################### [100%]
[root@mail etc]# ll
總計 16
-rw-r--r-- 1 root root?? 405 05-10 21:03 localtime
-rw-r----- 1 root named 1230 2010-12-03 named.caching-nameserver.conf
-rw-r----- 1 root named? 955 2010-12-03 named.rfc1912.zones
-rw-r----- 1 root named? 113 05-15 15:50 rndc.key
[root@mail etc]# cp -p named.caching-nameserver.conf named.conf? //-p表示復制文件的屬性
[root@mail etc]# vi named.conf
?
options {
??????? directory?????? "/var/named";
};
zone "chenkui.com" IN {
??????? type master;
??????? file "chenkui.zone";
};?
zone "10.168.192.in-addr.arpa" in {
??????? type master;
??????? file "chenkui.zero";
};
[root@mail etc]# named-checkconf named.conf?? //檢查配置文件有沒有語法錯誤,如果沒有任何輸出結果表示沒有錯誤
[root@mail etc]#????????????????????????????? //在此沒有輸出結果
[root@mail etc]# cd ../var/named/
[root@mail named]# ll
總計 36
drwxrwx--- 2 named named 4096 2004-08-26 data
-rw-r----- 1 root? named? 198 2010-12-03 localdomain.zone
-rw-r----- 1 root? named? 195 2010-12-03 localhost.zone
-rw-r----- 1 root? named? 427 2010-12-03 named.broadcast
-rw-r----- 1 root? named 1892 2010-12-03 named.ca
-rw-r----- 1 root? named? 424 2010-12-03 named.ip6.local
-rw-r----- 1 root? named? 426 2010-12-03 named.local
-rw-r----- 1 root? named? 427 2010-12-03 named.zero
drwxrwx--- 2 named named 4096 2004-07-27 slaves
[root@mail named]# cp -p localhost.zone chenkui.zone //創建區域數據庫文件
[root@mail named]# vi chenkui.zone
$TTL??? 86400
@?????????????? IN SOA? chenkui.com.?????? root.chenkui.com. (
??????????????????????????????????????? 42????????????? ; serial (d. adams)
??????????????????????????????????????? 3H????????????? ; refresh
??????????????????????????????????????? 15M???????????? ; retry
??????????????????????????????????????? 1W????????????? ; expiry
??????????????????????????????????????? 1D )??????????? ; minimum
@?????????????? IN NS?????????? www.chenkui.com.
www???????????? IN A??????????? 192.168.10.170
mail??????????? IN A??????????? 192.168.10.170
??????????????? IN MX 10??????? mail.chenkui.com.
*?????????????? IN A??????????? 192.168.10.170
pop3??????????? IN CNAME??????? mail
smtp??????????? IN CNAME??????? mail
:wq? //保存退出
[root@mail named]# cp -p chenkui.zone chenkui.zero //創建反向解析文件
[root@mail named]# vi chenkui.zero
$TTL??? 86400
@?????????????? IN SOA? chenkui.com.?????? root.chenkui.com. (
??????????????????????????????????????? 42????????????? ; serial (d. adams)
??????????????????????????????????????? 3H????????????? ; refresh
??????????????????????????????????????? 15M???????????? ; retry
??????????????????????????????????????? 1W????????????? ; expiry
??????????????????????????????????????? 1D )??????????? ; minimum
??????????????? IN NS?????????? www.chenkui.com.
170???????????? IN PTR????????? www.chenkui.com.
170???????????? IN PTR????????? mail.chenkui.com.
:wq? //保存退出
[root@mail ~]# cd /var/named/chroot/var/named/
[root@mail ~]# named-checkzone chenkui.com chenkui.zone
zone chenkui.com/IN: loaded serial 42
OK
[root@mail named]#?????????? //? named-checkzone通過檢查句法的正確性來檢查區帶(zone)文件的正確性。named-checkzone如果沒有檢查到錯誤,會返回一個簡單的“OK”字
符。???
[root@mail ~]# vi /etc/resolv.conf
nameserver?192.168.10.170? //修改DNS指向自己
[root@mail etc]# nslookup 192.168.10.170?? //驗證反向解析
Server:???????? 192.168.10.170
Address:??????? 192.168.10.170#53
170.10.168.192.in-addr.arpa???? name = www.chenkui.com.
170.10.168.192.in-addr.arpa???? name = mail.chenkui.com.
[root@mail etc]# nslookup mail.chenkui.com??
Server:???????? 192.168.10.170
Address:??????? 192.168.10.170#53
Name:?? mail.chenkui.com
Address: 192.168.10.170
[root@mail etc]#
[root@mail etc]# chkconfig named on???? //添加為隨系統啟動
[root@mail etc]# chkconfig --add named? //添加到系統服務列表
[root@mail etc]# rndc reload
server reload successful
?
?
?
?
?
構建LAMP平臺
在此我使用的是httpd-2.2.9的源碼包,安裝之前需要安裝apr-1.4.6.tar.gz、apr-util-1.4.1.tar.gz、pcre-8.30.zip等軟件包支持http
[root@mail etc]# mount /dev/cdrom /mnt
mount: block device /dev/cdrom is write-protected, mounting read-only
[root@mail etc]# cd /mnt
[root@mail mnt]# ll
總計 64272
-r-xr-xr-x 1 root root?? 982243 04-29 11:49 apr-1.4.6.tar.gz
-r-xr-xr-x 1 root root?? 774770 04-29 11:50 apr-util-1.4.1.tar.gz
-r-xr-xr-x 1 root root? 5583905 04-29 15:23 cmake-2.8.6.tar.gz
-r-xr-xr-x 1 root root? 5616185 04-29 11:02 httpd-2.4.2.tar.gz
-r-xr-xr-x 1 root root?? 875425 05-09 14:59 libmcrypt-2.5.8.tar.bz2
-r-xr-xr-x 1 root root?? 471915 05-09 15:10 mcrypt-2.6.8.tar.gz
-r-xr-xr-x 1 root root?? 655906 05-09 15:08 mhash-0.9.9.9.tar.bz2
-r-xr-xr-x 1 root root 24475686 05-25 11:43 mysql-5.5.22.tar.gz
-r-xr-xr-x 1 root root? 1285776 04-29 12:37 pcre-8.10.tar.gz
-r-xr-xr-x 1 root root? 1409751 04-29 12:34 pcre-8.10.zip
-r-xr-xr-x 1 root root 11707402 04-29 18:44 php-5.3.10.tar.bz2
-r-xr-xr-x 1 root root 11439508 05-09 14:30 php-5.4.0.tar.bz2
-r-xr-xr-x 1 root root?? 531360 05-22 21:00 squirrelmail-webmail-1.4.22.tar.bz2
[root@mail mnt]# tar zxvf apr-1.4.6.tar.gz -C /usr/src/
[root@mail mnt]# cd /usr/src/apr-1.4.6/
[root@mail apr-1.4.6]# ./configure --prefix=/usr/local/apr
[root@mail apr-1.4.6]# make && make install
2、
[root@mail mnt]# tar -zxvf apr-util-1.4.1.tar.gz -C /usr/src/
[root@mail mnt]# cd /usr/src/apr-util-1.4.1/
[root@mail apr-util-1.4.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config
[root@mail apr-util-1.4.1]# make && make install
3、
unzip pcre-8.30.zip -d /usr/src
cd /usr/src/pcre-8.30
./configure --prefix=/usr/local/pcre
?make && make install
uzip解壓參數
-x 文件列表 解壓縮文件,但不包括指定的file文件。
-v 查看壓縮文件目錄,但不解壓。
-t 測試文件有無損壞,但不解壓。
-d 目錄 把壓縮文件解到指定目錄下。
-z 只顯示壓縮文件的注解。
-n 不覆蓋已經存在的文件。
-o 覆蓋已存在的文件且不要求用戶確認。
-j 不重建文檔的目錄結構,把所有文件解壓到同一目錄下。
4、
[root@mail mnt]# tar -zxvf httpd-2.2.9.tar.gz -C /usr/src/
[root@mail mnt]# cd /usr/src/httpd-2.2.9
[root@mail httpd-2.2.9]# ./configure --prefix=/usr/local/apache2 --enable-so --enable-rewrite
[root@mail httpd-2.2.9]# make && make install
[root@mail httpd-2.2.9]# vi /usr/local/apache2/conf/httpd.conf
ServerName mail.chenkui.com
[root@mail httpd-2.2.9]# vi /etc/profile
56 PATH=$PATH:/usr/local/apache2/bin/
[root@mail httpd-2.2.9]# . /etc/profile //重新載入環境變量
[root@mail apache2]# echo $PATH?? //此時已經有apache的變量路徑存在
/usr/lib/qt-3.3/bin:/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 apache2]# apachectl -t
Syntax OK
[root@mail apache2]# vi /etc/ld.so.conf/
/usr/local/apache2/lib/???????????????????? //添加apache的庫文件搜索路徑
[root@mail apache2]# ldconfig???????????? //重新加載庫文件搜索路徑
[root@mail apache2]# apachectl start
httpd (pid 21702) already running
[root@mail apache2]# netstat -nplt | grep httpd
tcp??????? 0????? 0 :::80?????????????????????? :::*??????????????????????? LISTEN????? 21702/httpd????????
[root@mail apache2]#
?
?
?
?
安裝Mysql5.5.22
現在的5.5版本以上的MySQL都使用Cmake進行編譯安裝,所以在安裝MySQL之前我們首先要把Cmake裝在我們的系統。
我們所需要的軟件源碼包有以下:
???cmake-2.8.6.tar.gz
???mysql-5.5.22.tar.gz
1、安裝Cmake
#安裝所需依賴關系
yum -y install ntp vim-enhanced gcc gcc-c++ flex bison autoconf automake bzip2-devel ncurses-devel zlib-devel libjpeg-devel libpng-devel libtiff-devel
freetype-devel libXpm-devel gettext-devel? pam-devel libtool libtool-ltdl openssl openssl-devel fontconfig-devel libxml2-devel curl-devel? libicu libicu-devel
libmcrypt libmcrypt-devel mcrypt libmhash libmhash-devel
[root@mail mnt]# tar -jxvf libmcrypt-2.5.8.tar.bz2 -C /usr/src/
[root@mail libmcrypt-2.5.8]# ./configure
[root@mail libmcrypt-2.5.8]# make && make install
[root@mail mnt]# tar -zxvf mhash-0.9.9.tar.gz -C /usr/src
[root@mail mnt]# cd /usr/src/
[root@mail mhash-0.9.9]# ./configure?
[root@mail mhash-0.9.9]# make && make install
[root@mail mnt]# tar -zxvf mcrypt-2.6.8.tar.gz -C /usr/src/
[root@mail mnt]# cd /usr/src/mcrypt-2.6.8/
[root@mail mcrypt-2.6.8]# ln -s /usr/local/libmcrypt/lib/libmcrypt.la /usr/lib/libmcrypt.la
[root@mail mcrypt-2.6.8]# ln -s /usr/local/libmcrypt/lib/libmcrypt.so /usr/lib/libmcrypt.so
libmcheck.a????????? libmcop_mt.la??????? libmcop_mt.so.1????? libmcop.so?????????? libmcop.so.1.0.0????
libmcop.la?????????? libmcop_mt.so??????? libmcop_mt.so.1.0.0? libmcop.so.1???????? libmcrypt.la????????
[root@mail mcrypt-2.6.8]# ln -s /usr/local/libmcrypt/lib/libmcrypt.so /usr/lib/libmcrypt.so
[root@mail mcrypt-2.6.8]# ln -s /usr/local/libmcrypt/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
[root@mail mcrypt-2.6.8]# ln -s /usr/local/libmcrypt/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8
[root@mail mcrypt-2.6.8]#
[root@mail mcrypt-2.6.8]# export LD_LIBRARY_PATH=/usr/local/lib: LD_LIBRARY_PATH
?
[root@mail mcrypt-2.6.8]# ./configure
[root@mail mcrypt-2.6.8]# make && make install
?
?
?
安裝cmake
[root@mail mnt]# tar zxvf cmake-2.8.6.tar.gz -C /usr/src
[root@mail mnt]# cd /usr/src/cmake-2.8.6/
[root@mail mnt]# ./configure && make && make install
2、編譯安裝配置MySQL
? 創建所需目錄mkdir -pv /usr/local/mysql/data???? //同時創建mysql和data兩個目錄并輸出創建信息
? 創建mysql組??? groupadd mysql
? 創建mysql用戶 useradd -M -g ysql -s /sbin/nologin mysql? //創建mysql用戶并加入mysql組,并不能登錄到系統
解壓源碼
[root@mail mnt]# tar -zxvf mysql-5.5.22.tar.gz -C /usr/src/??????? /本人一般解壓在此目錄下面
[root@mail mnt]# cd /usr/src/mysql-5.5.22
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8-
DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_EMBEDDED_SERVER=1 -DENABLED_LOCAL_INFILE=1 -
DDEFAULT_COLLATION=utf8_general_ci -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_DEBUG=0
參數說明:
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql //安裝目錄
-DMYSQL_DATADIR=/usr/local/mysql/data //數據庫存放目錄
-DWITH_MYISAM_STORAGE_ENGINE=1 //安裝myisam存儲引擎
-DWITH_INNOBASE_STORAGE_ENGINE=1 //安裝innodb存儲引擎
-DWITH_ARCHIVE_STORAGE_ENGINE=1 //安裝archive存儲引擎
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 //安裝blackhole存儲引擎
-DENABLED_LOCAL_INFILE=1 //允許從本地導入數據
-DDEFAULT_CHARSET=utf8 //使用utf8字符
-DDEFAULT_COLLATION=utf8_general_ci //校驗字符
-DEXTRA_CHARSETS=all //安裝所有擴展字符集
-DMYSQL_TCP_PORT=3306 //MySQL監聽端口
-DMYSQL_USER=mysql //MySQL用戶名
其他參數:
-DWITH-EMBEDDED_SERVER=1 //編譯成embedded MySQL library (libmysqld.a)
-DSYSCONFDIR=/etc //MySQL配輯文件
-DMYSQL_UNIX_ADDR=/tmp/mysqld.sock //Unix socket 文件路徑
-DWITH_READLINE=1 //快捷鍵功能
-DWITH_SSL=yes //SSL
-DWITH_MEMORY_STORAGE_ENGINE=1 //安裝memory存儲引擎
-DWITH_FEDERATED_STORAGE_ENGINE=1 //安裝frderated存儲引擎
-DWITH_PARTITION_STORAGE_ENGINE=1 //安裝數據庫分區
-DINSTALL_PLUGINDIR=/usr/local/mysql/plugin //插件文件及配置路徑
[root@mail mysql-5.5.22]# make && make install
#復制配置文件
[root@mail mysql-5.5.22]# cp support-files/my-medium.cnf /etc/my.cnf
#設置權限
[root@mail mysql-5.5.22]# chmod +x /usr/local/mysql/
[root@mail mysql-5.5.22]# chown -R mysql.mysql /usr/local/mysql/
[root@mail mysql-5.5.22]# chown -R mysql.mysql /usr/local/mysql/data/
[root@mail mysql-5.5.22]#
#配置開機自動啟動
[root@mail mysql-5.5.22]# cp support-files/mysql.server /etc/init.d/mysqld
[root@mail mysql-5.5.22]# chmod +x /etc/rc.d/init.d/mysqld
[root@mail mysql-5.5.22]# chkconfig mysqld on
[root@mail mysql-5.5.22]# chkconfig --add mysqld
[root@mail mysql-5.5.22]#
#修改配置文件
vim /etc/my.cnf
#在[mysqld]中添加:
datadir = /usr/local/mysql/data
log-error = /usr/local/mysql/data/error.log
pid-file = /usr/local/mysql/data/mail.pid???? //(此處的pid文件名稱要與主機名稱一致)
user = mysql
tmpdir = /tmp
#保存退出
初始化數據庫
/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
手動啟動MySQL
service mysqld start?? //第一次我在這里啟動失敗,查看日志,提示字符集無效,修改my.cnf配置文件,添加下面設置,后來就沒的錯誤了
[client]
default-character-set=utf8
[mysqld]
character-set-server=utf8
? 保存退出后重新初始化數據庫
/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
測試MySQL是否啟動
[root@mail mysql-5.5.22]# service mysqld restart
MySQL server PID file could not be found!????????????????? [失敗]
Starting MySQL.....??????????????????????????????????????? [確定]
[root@mail mysql-5.5.22]# netstat -nuptl | grep 3306
tcp??????? 0????? 0 :::3306???????????????????? :::*??????????????????????? LISTEN????? 3430/mysqld????????
[root@mail mysql-5.5.22]# export PATH=$PATH:/usr/local/mysql/bin
[root@mail mysql-5.5.22]# echo "PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile
[root@mail mysql-5.5.22]# echo "/usr/local/mysql/lib/mysql" >> /etc/ld.so.conf
[root@mail mysql-5.5.22]# mysqladmin version??
mysqladmin? Ver 8.42 Distrib 5.5.22, for Linux on i686
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Server version????????? 5.5.22-log
Protocol version??????? 10
Connection????????????? Localhost via UNIX socket
UNIX socket???????????? /var/lib/mysql/mysql.sock
Uptime:???????????????? 2 min 11 sec
Threads: 1? Questions: 1? Slow queries: 0? Opens: 33? Flush tables: 1? Open tables: 26? Queries per second avg: 0.007
[root@mail mysql-5.5.22]#
到此MySQL編譯安裝完成
第一次登錄默認為空密碼?
mysql -u root? //以管理員身份登錄mysql數據庫
修改root登錄數據庫的密碼
mysqladmin -u root password "自定義的密碼"
?
?
?
安裝PHP
?
[root@mail php-5.3.10]# tar -jxvf php-5.3.10.tar.bz2 -C /usr/src
[root@mail php-5.3.10]# cd /usr/src/php-5.3.10
[root@mail php-5.3.10]# ./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-openssl --with-mysqli=/usr/local/mysql/bin/mysql_config --
enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml? --with-apxs2=/usr/local/apache2/bin/apxs
--with-mcrypt
[root@mail php-5.3.10]# make && make install
為php提供配置文件:
[root@mail php-5.3.10]# cp php.ini-production /usr/local/php/lib/php.ini
編輯apache配置文件httpd.conf,以apache支持php
?
[root@mail php-5.3.10]# vim /usr/local/apache2/htdocs/conf/httpd.conf
LoadModule php5_module??????? modules/libphp5.so
#確認的存php5_module存在,如果沒有就重新編譯php
?1、添加如下二行
?? AddType application/x-httpd-php? .php
?? AddType application/x-httpd-php-source? .phps
?2、定位至DirectoryIndex index.html
?? 修改為:
??? DirectoryIndex? index.php? index.html?
至此LAMP搭建成功:
可在APACHE文檔目錄下面添加下面測試頁
vim /index.php
<?php
phpinfo();
?>
在瀏覽器中輸入網站網址,如果出現php的版本信息頁面說明php與apahce整合成功
?
?
安裝Postfix? // 這里我交所有軟件打包成一個postfix.iso的文件,放入光驅中
確定系統里沒有安裝Sendmail,安裝了卸載。
[root@mail ~]# rpm -qa sendmail
sendmail-8.13.8-8.el5
[root@mail ~]# rpm -e --nodeps sendmail
[root@mail ~]# rpm -qa sendmail???????
[root@mail ~]#
[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 ~]# yum -y install mysql-devel-*? //掛載系統光盤安裝安裝mysql-devel-*,否則在后面會提示找不到mysql.h
[root@mail ~]# mount /dev/cdrom /mnt
mount: block device /dev/cdrom is write-protected, mounting read-only
[root@mail ~]# cd /mnt
[root@mail mnt]# ll
[root@mail mnt]# tar -zxvf postfix-2.8.2.tar.gz -C /usr/src/
[root@mail mnt]# cd /usr/src/postfix-2.8.2/
[root@mail postfix-2.8.2]# cp /usr/local/mysql/lib/* /usr/lib/???? //復制Mysql的庫文件,否則后面安裝Postfix提示庫文件找不到
[root@mail postfix-2.8.2]# make -f Makefile.init makefiles 'CCARGS=-DHAS_MYSQL -I/usr/local/mysql/include -DUSE_SASL_AUTH -I/usr/local/include/sasl'
'AUXLIBS=-L/usr/local/mysql/lib -lmysqlclient -lz -lm -L/usr/lib/sasl2 -lsasl2'
[root@mail postfix-2.8.2]#
[root@mail postfix-2.8.2]# make
[root@mail postfix-2.8.2]# make install
[root@mail postfix-2.8.2]# newaliases?? // 生成別名二進制文件,這個步驟如果忽略,會造成postfix效率極低
[root@mail postfix-2.8.2]# postconf -a?? //有Dovecot說明支持Dovecot驗證
dovecot
[root@mail postfix-2.8.2]# postconf -m?
btree
cidr
environ
hash
internal
mysql??????????????????????????? //有Mysql說明支持Mysql驗證
nis
pcre
proxy
regexp
static
tcp
texthash
unix
[root@mail postfix-2.8.2]#
[root@mail postfix-2.8.2]#
[root@mail postfix-2.8.2]# cp /etc/postfix/main.cf /etc/postfix/main.cf.bak? //將配置文件做一個備份
[root@mail postfix-2.8.2]# vim /etc/postfix/main.cf
76 myhostname = mail.chenkui.com
83 mydomain = chenkui.com
99 myorigin = $mydomain
113 inet_interfaces = all
162 mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain, mail.$mydomain, www.$mydomain, ftp.$mydomain
259 mynetworks = 192.168.10.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: 未被識別的服務,那么下面我們來制作postfix的啟動文件
[root@mail postfix-2.8.2]# mkdir /tmp/postfix
[root@mail postfix-2.8.2]# cd /tmp/postfix/
[root@mail postfix]# umount /mnt
[root@mail postfix]# mount /dev/cdrom /mnt
mount: block device /dev/cdrom is write-protected, mounting read-only
[root@mail postfix]# cp /mnt/Server/postfix-2.3.3-2.1.el5_2.i386.rpm ./
[root@mail postfix]#
[root@mail postfix]# ll
總計 3652
-r--r--r-- 1 root root 3734257 05-27 20:46 postfix-2.3.3-2.1.el5_2.i386.rpm
[root@mail postfix]#
[root@mail postfix]# rpm2cpio postfix-2.3.3-2.1.el5_2.i386.rpm |cpio -id
16333 blocks
[root@mail postfix]# ll
總計 3664
drwxr-xr-x 5 root root??? 4096 05-27 20:47 etc
-r--r--r-- 1 root root 3734257 05-27 20:46 postfix-2.3.3-2.1.el5_2.i386.rpm
drwxr-xr-x 7 root root??? 4096 05-27 20:47 usr
drwxr-xr-x 3 root root??? 4096 05-27 20:47 var
[root@mail postfix]# ll etc/rc.d/init.d/
總計 4
-rwxr-xr-x 1 root root 2404 05-27 20:47 postfix
[root@mail postfix]# cp etc/rc.d/init.d/postfix /etc/rc.d/init.d/
[root@mail postfix]# service postfix restart
關閉 postfix:???????????????????????????????????????????? [確定]
啟動 postfix:???????????????????????????????????????????? [確定]
[root@mail postfix]#
[root@mail postfix]# chkconfig --add postfix
[root@mail postfix]# chkconfig postfix on
[root@mail postfix]# chkconfig --list postfix
postfix???????? 0:關閉? 1:關閉? 2:啟用? 3:啟用? 4:啟用? 5:啟用? 6:關閉
[root@mail postfix]#
[root@mail postfix]# useradd user1? //增加兩個用戶用于后面測試
[root@mail postfix]# useradd user2
[root@mail postfix]# echo "123456" |passwd --stdin user1? //給user1賦值初始密碼
Changing password for user user1.
passwd: all authentication tokens updated successfully.
[root@mail postfix]# echo "123456" |passwd --stdin user2
Changing password for user user2.
passwd: all authentication tokens updated successfully.
[root@mail postfix]#
[root@mail postfix]# service mysqld restart
Shutting down MySQL.?????????????????????????????????????? [確定]
Starting MySQL..?????????????????????????????????????????? [確定]
[root@mail postfix]# service named restart
停止 named:?????????????????????????????????????????????? [確定]
啟動 named:?????????????????????????????????????????????? [確定]
[root@mail postfix]# //下面來進行telnet smtp的25號端口進行測試能否進行發送郵件
[root@mail postfix]# telnet mail.chenkui.com 25
Trying 192.168.10.170...
Connected to mail.chenkui.com (192.168.10.170).
Escape character is '^]'.
220 mail.chenkui.com ESMTP Postfix
ehlo mail.chenkui.com
250-mail.chenkui.com
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
mail from:user1@chenkui.com? //從user1發往到user2,這個過程測試成功說明可以正常發送郵件。
250 2.1.0 Ok
rcpt to:user2@chenkui.com
250 2.1.5 Ok
data
354 End data with <CR><LF>.<CR><LF>
this is a test E-mail,user1 to user2
.
250 2.0.0 Ok: queued as 80546275AA5
quit
221 2.0.0 Bye
Connection closed by foreign host.
[root@mail postfix]#
[root@mail postfix]#/檢查user2是否收到
[root@mail postfix]# su - user2
[user2@mail ~]$ mail
Mail version 8.1 6/6/93.? Type ? for help.
"/var/spool/mail/user2": 1 message 1 new
>N? 1 user1@chenkui.com???? Sun May 27 20:59? 13/500? //這里user2收到一封來自user1的郵件,序號為1
& 1
Message 1:
From user1@chenkui.com? Sun May 27 20:59:38 2012
X-Original-To: user2@chenkui.com
Delivered-To: user2@chenkui.com
Date: Sun, 27 May 2012 20:58:04 +0800 (CST)
From: user1@chenkui.com
this is a test E-mail,user1 to user2?? //剛才測試的內容
& quit
Saved 1 message in mbox
[user2@mail ~]$
[user2@mail ~]$ su - root? /切換回root用戶,在此處一定要加上 - 否則root的shell環境不一樣。
口令:
[root@mail ~]#
?
?
上面我們只是安裝了smtp發送服務器,下面我們來安裝接收服務器,并使用dovecot軟件。
[root@mail ~]# mount /dev/cdrom /mnt
mount: block device /dev/cdrom is write-protected, mounting read-only
[root@mail ~]# cd /mnt
[root@mail mnt]# groupadd dovecot //建立dovecot組
[root@mail mnt]# useradd -M -g dovecot -s /sbin/nologin dovecot //建立dovecot用戶并加入dovecot組,并不允許登錄到系統
[root@mail mnt]# ll
總計 42163
-r-xr-xr-x 1 root root? 2175238 03-21 21:36 courier-authlib-0.62.4.tar.bz2
-r-xr-xr-x 1 root root?? 137736 03-21 21:37 DBD-mysql-4.020.tar.gz
-r-xr-xr-x 1 root root?? 576803 03-21 21:37 DBI-1.616.tar.gz
-r-xr-xr-x 1 root root? 2314155 03-21 21:38 dovecot-1.1.4.tar.gz
-r-xr-xr-x 1 root root?? 541279 12-21 19:34 extmail-1.2.tar.gz
-r-xr-xr-x 1 root root?? 586234 12-21 19:35 extman-1.1.tar.gz
-r-xr-xr-x 1 root root??? 22800 03-21 21:37 File-Tail-0.99.3.tar.gz
-r-xr-xr-x 1 root root 14420771 03-21 21:42 fp-Linux-i686-ws.tar.gz
-r-xr-xr-x 1 root root?? 260989 03-21 21:37 GD-2.46.tar.gz
-r-xr-xr-x 1 root root? 5864320 03-21 21:45 MailScanner-4.84.3-1.rpm.tar.gz
-r-xr-xr-x 1 root root 11439508 03-02 04:34 php-5.4.0.tar.bz2
-r-xr-xr-x 1 root root? 3644570 2011-03-24 postfix-2.8.2.tar.gz
-r-xr-xr-x 1 root root?? 474709 03-21 21:37 rrdtool-1.2.23-3.el5.i386.rpm
-r-xr-xr-x 1 root root??? 34075 03-21 21:37 rrdtool-perl-1.2.23-3.el5.i386.rpm
-r-xr-xr-x 1 root root?? 664076 04-10 17:53 squirrelmail-webmail-1.4.22.tar.gz
-r-xr-xr-x 1 root root??? 13738 03-21 21:37 Unix-Syslog-1.1.tar.gz
[root@mail mnt]# tar -zxvf dovecot-1.1.4.tar.gz -C /usr/src/
[root@mail mnt]# cd /usr/src/dovecot-1.1.4/
[root@mail dovecot-1.1.4]# ./configure --sysconfdir=/etc --with-mysql
[root@mail dovecot-1.1.4]# make && make install
[root@mail dovecot-1.1.4]# cp /etc/dovecot-example.conf /etc/dovecot.conf? //建立主配置文件
[root@mail dovecot-1.1.4]# vi /etc/dovecot.conf
23 protocols = pop3 imap
47 disable_plaintext_auth = no
87 ssl_disable = yes
208 mail_location = maildir:~/Maildir
[root@www dovecot-1.1.4]# vim /etc/postfix/main.cf
414 home_mailbox = Maildir/
建立認證文件
vim /etc/pam.d/dovecot?
auth? required? pam_nologin.so
auth? include? system-auth
account? include? system-auth
session? include? system-auth
將此腳本加入到開機時自動啟動
[root@mail dovecot-1.1.4]# /usr/local/sbin/dovecot -c /etc/dovecot.conf
測試dovecot
[root@mail dovecot-1.1.4]#
[root@mail dovecot-1.1.4]# telnet mail.chenkui.com 110
Trying 192.168.10.170...
Connected to mail.chenkui.com (192.168.10.170).
Escape character is '^]'.
+OK Dovecot ready.
user user2
+OK
pass 123456
+OK Logged in.
list
+OK 0 messages:
.
quit
+OK Logging out.
Connection closed by foreign host.
[root@mail dovecot-1.1.4]#
?
?
安裝squirrelmail-webmail
[root@mail mnt]# tar -zxvf squirrelmail-webmail-1.4.22.tar.gz -C /usr/local/apache2/htdocs/
[root@mail mnt]# cd /usr/local/apache2/htdocs/
[root@mail htdocs]# ll
總計 12
-rw-r--r--? 1 root root?? 45 2007-06-12 index.html
-rw-r--r--? 1 root root?? 20 05-26 21:58 index.php
drwxr-xr-x 16 root root 4096 2011-07-13 squirrelmail-webmail-1.4.22
[root@mail htdocs]# mv squirrelmail-webmail-1.4.22/ webmail
[root@mail htdocs]#
[root@mail htdocs]# cd webmail/
[root@mail webmail]# mkdir -pv data/ attach/
mkdir: 已創建目錄 “attach”
[root@mail webmail]# ll
總計 72
drwxr-xr-x? 2 root root 4096 05-27 21:36 attach
drwxr-xr-x? 5 root root 4096 2011-07-13 class
drwxrwxr-x? 2 root root 4096 2011-07-13 config
-rwxr-xr-x? 1 root root? 102 2005-08-03 configure
drwxr-xr-x? 3 root root 4096 2011-07-13 contrib
drwxrwxr-x? 2 root root 4096 2011-07-13 data
drwxr-xr-x? 3 root root 4096 2011-07-13 doc
drwxr-xr-x? 4 root root 4096 2011-07-13 functions
drwxr-xr-x? 3 root root 4096 2011-07-13 help
drwxr-xr-x? 2 root root 4096 2011-07-13 p_w_picpaths
drwxr-xr-x? 3 root root 4096 2011-07-13 include
-rw-r--r--? 1 root root? 671 2011-01-06 index.php
drwxr-xr-x? 2 root root 4096 2011-07-13 locale
drwxr-xr-x 19 root root 4096 2011-07-13 plugins
drwxr-xr-x? 2 root root 4096 2011-07-13 po
-rw-r--r--? 1 root root?? 56 2009-03-27 README
drwxr-xr-x? 2 root root 4096 2011-07-13 src
drwxr-xr-x? 3 root root 4096 2011-07-13 themes
[root@mail webmail]#
[root@mail webmail]# chown -R daemon.daemon attach/ data/
[root@mail webmail]#
[root@mail webmail]# chmod 730 attach/
[root@mail webmail]# cp config/config_default.php config/config.php
[root@mail webmail]# vi config/config.php
118 $domain = 'chenkui.com';
146 $smtpServerAddress = 'localhost';
151 $smtpPort = 25;
210 $imapPort = 143;
231 $imap_server_type = 'dovecot';
499 $data_dir = '/usr/local/apache2/htdocs/webmail/data/';
517 $p_w_upload_dir = '/usr/local/apache2/htdocs/webmail/attach/';
[root@mail webmail]# /usr/local/apache2/bin/apachectl restart? //重啟apache服務
打開瀏覽器輸入:http://mail.chenkui.com/webmail/src/login.php此時可以打開squirrelMail的首頁
?
?
?
?
?
?
?
安裝Extman
[root@mail mnt]# tar -zxvf extman-1.1.tar.gz -C /usr/src/
[root@mail mnt]# cd /usr/src/extman-1.1/docs/
[root@mail docs]# ll
總計 76
-rw-r--r-- 1 test test? 1250 2006-04-23 backport
-rw-r--r-- 1 test test 11180 2007-02-28 extmail.schema
-rw-r--r-- 1 test test? 5141 2008-03-30 extmail.sql
-rw-r--r-- 1 test test? 2671 2008-03-19 init.ldif
-rw-r--r-- 1 test test? 1478 2008-04-04 init.sql
-rw-r--r-- 1 test test?? 201 2006-04-24 ldap_virtual_alias_maps.cf
-rw-r--r-- 1 test test?? 210 2005-12-15 ldap_virtual_domains_maps.cf
-rw-r--r-- 1 test test?? 195 2005-12-15 ldap_virtual_limit_maps.cf
-rw-r--r-- 1 test test?? 202 2005-11-04 ldap_virtual_mailbox_maps.cf
-rw-r--r-- 1 test test?? 190 2007-03-07 ldap_virtual_sender_maps.cf
-rw-r--r-- 1 test test?? 166 2005-12-15 mysql_virtual_alias_maps.cf
-rw-r--r-- 1 test test?? 168 2007-02-25 mysql_virtual_domains_maps.cf
-rw-r--r-- 1 test test?? 170 2005-12-15 mysql_virtual_limit_maps.cf
-rw-r--r-- 1 test test?? 172 2005-12-15 mysql_virtual_mailbox_maps.cf
-rw-r--r-- 1 test test?? 173 2007-03-07 mysql_virtual_sender_maps.cf
-rw-r--r-- 1 test test? 1337 2005-12-16 README.postfix
[root@mail docs]# vi extmail.sql
查找/替換,將數據庫文件內的所有TYPE=MyISAM修改為ENGINE=MyISAM,保存退出;//:%s/TYPE/ENGINE 使用此替換
[root@mail docs]# mysql -u root -p < extmail.sql
Enter password:???????????????????????????????????? //默認密碼是空的,如果修改過使用修改的密碼
[root@mail docs]# mysql -u root -p < init.sql
Enter password:
[root@mail docs]#
配置Postfix
[root@mail ~]# vi /etc/postfix/main.cf? //并添加651-656這幾行
??? 162 #mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain, mail.$mydomain, www.$mydomain, ftp.$mydomain? //注釋掉該行
??? 651 virtual_mailbox_base = /mailbox
??? 652 virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf
??? 653 virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
??? 654 virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf
??? 655 virtual_uid_maps = static:1000
??? 656 virtual_gid_maps = static:1000
[root@mail ~]# cd /usr/src/extman-1.1/docs/
[root@mail docs]# cp mysql_virtual_* /etc/postfix/
[root@mail docs]#
虛擬用戶設置SMTP發信認證
[root@mail mnt]# tar -jxvf courier-authlib-0.62.4.tar.bz2 -C /usr/src/
[root@mail mnt]# cd /usr/src/courier-authlib-0.62.4
[root@mail courier-authlib-0.62.4]# vi /etc/ld.so.conf
ldconfig: /usr/lnflibmysqlclient.so.18 is not a symbolic link
[root@mail courier-authlib-0.62.4]# ln -sf /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib/libmysqlclient.so.18
[root@mail courier-authlib-0.62.4]# ./configure --prefix=/usr/local/courier-authlib --without-stdheaderdir --with-authmysql --with-redhat --with-mysql-
libs=/usr/local/mysql/lib/ --with-mysql-includes=/usr/local/mysql/include/mysql??? // 在此也要注意mysql的鏈接庫路徑
[root@mail courier-authlib-0.62.4]# make && make install && make install-configure//最后一個參數是表示生成默認配置文件authmysqlrc 和 authdaemonrc
[root@mail courier-authlib-0.62.4]# vi /etc/ld.so.conf
/usr/local/courier-authlib/lib/courier-authlib???????????? //添加庫文件搜索路徑
[root@mail courier-authlib-0.62.4]# ldconfig??????????????? //重新加載庫文件
[root@mail courier-authlib-0.62.4]# cd /usr/local/courier-authlib/etc/authlib/
[root@mail authlib]# ll
總計 56
-rw-rw---- 1 daemon daemon 3704 05-27 22:38 authdaemonrc
-rw-rw---- 1 daemon daemon 3704 05-27 22:38 authdaemonrc.dist
-rw-rw---- 1 daemon daemon 8229 05-27 22:38 authldaprc
-rw-rw---- 1 daemon daemon 8229 05-27 22:38 authldaprc.dist
-rw-rw---- 1 daemon daemon 8812 05-27 22:38 authmysqlrc
-rw-rw---- 1 daemon daemon 8812 05-27 22:38 authmysqlrc.dist
[root@mail authlib]#
[root@mail authlib]# cp authdaemonrc authdaemonrc.bak?? //做一個備份
[root@mail authlib]# cp authmysqlrc authmysqlrc.bak
[root@mail authlib]#
[root@mail authlib]# vi authdaemonrc
修改
?27 authmodulelist="authmysql"
?34 authmodulelistorig="authmysql"
?75 DEBUG_LOGIN=2 //設置登錄記錄調試,輸出錯誤日志記錄
:wq
[root@mail authlib]# chmod -R 755 /usr/local/courier-authlib/var/spool/authdaemon/
[root@mail authlib]# vi authmysqlrc
???? 26 MYSQL_SERVER??????????? localhost
???? 27 MYSQL_USERNAME????????? extmail
???? 28 MYSQL_PASSWORD????????? extmail
???? 49 MYSQL_SOCKET??????????? /var/lib/mysql/mysql.sock???????????
???? 56 MYSQL_PORT????????????? 3306
???? 68 MYSQL_DATABASE????????? extmail
???? 83 MYSQL_USER_TABLE??????? mailbox
???? 92 MYSQL_CRYPT_PWFIELD???? password
???? 113 MYSQL_UID_FIELD???????? uidnumber
???? 119 MYSQL_GID_FIELD???????? gidnumbe
???? 128 MYSQL_LOGIN_FIELD?????? username
???? 133 MYSQL_HOME_FIELD??????? concat('/mailbox',homedir)
???? 139 MYSQL_NAME_FIELD??????? name
???? 150 MYSQL_MAILDIR_FIELD???? concat('/mailbox',maildir)
?
[root@mail authlib]# cd /usr/src/courier-authlib-0.62.4/
[root@mail courier-authlib-0.62.4]# cp courier-authlib.sysvinit /etc/init.d/courier-authlib//復制為系統啟動文件
[root@mail courier-authlib-0.62.4]# chmod 755 /etc/init.d/courier-authlib
[root@mail courier-authlib-0.62.4]# chkconfig --add courier-authlib
[root@mail courier-authlib-0.62.4]# chkconfig --level 2345 courier-authlib on
[root@mail courier-authlib-0.62.4]# chkconfig --list courier-authlib
courier-authlib 0:關閉? 1:關閉? 2:啟用? 3:啟用? 4:啟用? 5:啟用? 6:關閉
[root@mail ~]# service courier-authlib start?
Starting Courier authentication services: authdaemond
[root@mail ~]# cd /usr/src/courier-authlib-0.62.4
[root@mail courier-authlib-0.62.4]# cp /tmp/postfix/usr/lib/sasl2/smtpd.conf /usr/lib/sasl2/
[root@mail courier-authlib-0.62.4]# vi /usr/lib/sasl2/smtpd.conf????? //在這里沒有這個文件,我查找后在/tmp/postfix/usr/lib/sasl2/smtpd.conf復制過來的
pwcheck_method: authdaemond
mech_list:PLAIN LOGIN
authdaemond_path:/usr/local/courier-authlib/var/spool/authdaemon/socket
:wq
?
[root@mail courier-authlib-0.62.4]# vim /etc/dovecot.conf
208??? mail_location = maildir:/mailbox/%d/%n/Maildir
795?? mechanisms = plain
828?? #passdb pam {?????????
857?? #}
899?? passdb sql {
900???? # Path for SQL configuration file, see doc/dovecot-sql-example.conf
901???? args = /etc/dovecot-mysql.conf
902?? }???????
962?? userdb sql {
963???? # Path for SQL configuration file, see doc/dovecot-sql-example.conf
964???? args = /etc/dovecot-mysql.conf
965?? }??????????????????????????????????????????????????
:wq
[root@mail courier-authlib-0.62.4]# vim /etc/postfix/main.cf
414 home_mailbox = Maildir/? //此處之前已經修改
建立數據查詢配置文件,手動產生/etc/dovecot-mysql.conf文件
[root@mail courier-authlib-0.62.4]# vi /etc/dovecot-mysql.conf
driver = mysql
connect? =? host=localhost? dbname=extmail? user=extmail? password=extmail
default_pass_scheme? =? CRYPT
password_query? =? SELECT? username? AS? user,password? AS? password? FROM? mailbox? WHERE? username = '%u'
user_query? =? SELECT? maildir,? uidnumber? AS? uid,? gidnumber? AS? gid? FROM mailbox? WHERE? username? = '%u'
[root@mail ~]# mkdir -p /mailbox/extmail.org/postmaster/Maildir/
[root@mail ~]# cd /mailbox/extmail.org/postmaster/Maildir/
[root@mail Maildir]# chown -R postfix:postfix /mailbox/
[root@mail Maildir]#dovecot
[root@mail Maildir]# /usr/local/courier-authlib/sbin/authtest -s login postmaster@extmail.org extmail?? //測試虛擬用戶認證,下面已經看到認證成功
Authentication succeeded.
???? Authenticated: postmaster@extmail.org? (uid 1000, gid 1000)
??? Home Directory: /mailboxextmail.org/postmaster
?????????? Maildir: /mailboxextmail.org/postmaster/Maildir/
???????????? Quota: 104857600S
Encrypted Password: $1$phz1mRrj$3ok6BjeaoJYWDBsEPZb5C0
Cleartext Password: extmail
?????????? Options: (none)
[root@mail ~]#
搭建 Extmail平臺
基于Perl 語言開發的中文Webmail管理平臺
套件:ExtMail --Web 界面的郵件操作
????? Extman –Web 界面的郵件系統管理
?
[root@mail mnt]# tar -zxvf Unix-Syslog-1.1.tar.gz -C /usr/src/
Unix-Syslog-1.1/
Unix-Syslog-1.1/README
Unix-Syslog-1.1/Changes
Unix-Syslog-1.1/test.pl
Unix-Syslog-1.1/Artistic
Unix-Syslog-1.1/Makefile.PL
Unix-Syslog-1.1/META.yml
Unix-Syslog-1.1/Syslog.pm
Unix-Syslog-1.1/Syslog.xs
Unix-Syslog-1.1/MANIFEST
[root@mail mnt]#
[root@mail mnt]# cd /usr/src/Unix-Syslog-1.1/
[root@mail Unix-Syslog-1.1]# ll
總計 60
-rw-r--r-- 1 user1 bin 8902 2007-10-03 Artistic
-rw-r--r-- 1 user1 bin 3659 2008-05-19 Changes
-rw-r--r-- 1 user1 bin? 463 2008-05-19 Makefile.PL
-rw-r--r-- 1 user1 bin? 152 2008-05-19 MANIFEST
-rw-r--r-- 1 user1 bin? 296 2008-05-19 META.yml
-rw-r--r-- 1 user1 bin 5642 2007-10-03 README
-rw-r--r-- 1 user1 bin 9287 2008-05-19 Syslog.pm
-rw-r--r-- 1 user1 bin 3928 2008-05-18 Syslog.xs
-rw-r--r-- 1 user1 bin 7108 2008-02-28 test.pl
[root@mail Unix-Syslog-1.1]#
[root@mail Unix-Syslog-1.1]# perl Makefile.PL
Checking if your kit is complete...
Looks good
Writing Makefile for Unix::Syslog
[root@mail Unix-Syslog-1.1]# make && make install
[root@mail Unix-Syslog-1.1]# cd -
/mnt
[root@mail mnt]# ll
總計 42163
-r-xr-xr-x 1 root root? 2175238 03-21 21:36 courier-authlib-0.62.4.tar.bz2
-r-xr-xr-x 1 root root?? 137736 03-21 21:37 DBD-mysql-4.020.tar.gz
-r-xr-xr-x 1 root root?? 576803 03-21 21:37 DBI-1.616.tar.gz
-r-xr-xr-x 1 root root? 2314155 03-21 21:38 dovecot-1.1.4.tar.gz
-r-xr-xr-x 1 root root?? 541279 12-21 19:34 extmail-1.2.tar.gz
-r-xr-xr-x 1 root root?? 586234 12-21 19:35 extman-1.1.tar.gz
-r-xr-xr-x 1 root root??? 22800 03-21 21:37 File-Tail-0.99.3.tar.gz
-r-xr-xr-x 1 root root 14420771 03-21 21:42 fp-Linux-i686-ws.tar.gz
-r-xr-xr-x 1 root root?? 260989 03-21 21:37 GD-2.46.tar.gz
-r-xr-xr-x 1 root root? 5864320 03-21 21:45 MailScanner-4.84.3-1.rpm.tar.gz
-r-xr-xr-x 1 root root 11439508 03-02 04:34 php-5.4.0.tar.bz2
-r-xr-xr-x 1 root root? 3644570 2011-03-24 postfix-2.8.2.tar.gz
-r-xr-xr-x 1 root root?? 474709 03-21 21:37 rrdtool-1.2.23-3.el5.i386.rpm
-r-xr-xr-x 1 root root??? 34075 03-21 21:37 rrdtool-perl-1.2.23-3.el5.i386.rpm
-r-xr-xr-x 1 root root?? 664076 04-10 17:53 squirrelmail-webmail-1.4.22.tar.gz
-r-xr-xr-x 1 root root??? 13738 03-21 21:37 Unix-Syslog-1.1.tar.gz
[root@mail mnt]# tar -zxvf DB
DBD-mysql-4.020.tar.gz? DBI-1.616.tar.gz???????
[root@mail mnt]# tar -zxvf DBI-1.616.tar.gz -C /usr/src/
[root@mail mnt]# cd /usr/src/DBI-1.616/
[root@mail DBI-1.616]# ll
總計 976
-rw-r--r-- 1 mysql mysql 106959 2010-12-30 Changes
-rw-r--r-- 1 mysql mysql?? 3139 2009-02-25 dbd_xsh.h
-rw-r--r-- 1 mysql mysql?? 1937 2009-09-02 dbilogstrip.PL
-rw-r--r-- 1 mysql mysql 308284 2010-12-22 DBI.pm
-rw-r--r-- 1 mysql mysql 174680 2010-07-30 dbipport.h
-rw-r--r-- 1 mysql mysql?? 6784 2009-09-14 dbiprof.PL
-rw-r--r-- 1 mysql mysql?? 5967 2009-09-14 dbiproxy.PL
-rw-r--r-- 1 mysql mysql?? 3747 2006-02-08 dbi_sql.h
-rw-r--r-- 1 mysql mysql?? 2016 2005-03-26 dbivport.h
-rw-r--r-- 1 mysql mysql 193557 2010-12-22 DBI.xs
-rw-r--r-- 1 mysql mysql? 24174 2010-12-22 DBIXS.h
-rw-r--r-- 1 mysql mysql??? 148 2010-12-22 dbixs_rev.h
-rw-r--r-- 1 mysql mysql?? 1533 2007-07-16 dbixs_rev.pl
-rw-r--r-- 1 mysql mysql? 22333 2010-07-30 Driver.xst
-rw-r--r-- 1 mysql mysql?? 3716 2009-09-14 Driver_xst.h
drwxr-x--- 2 mysql mysql?? 4096 05-28 19:24 ex
drwxr-x--- 6 mysql mysql?? 4096 05-28 19:24 lib
-rw-r--r-- 1 mysql mysql? 13371 2010-09-03 Makefile.PL
-rw-r--r-- 1 mysql mysql?? 5456 2010-12-30 MANIFEST
-rw-r----- 1 mysql mysql?? 1078 2010-12-30 META.yml
-rw-r--r-- 1 mysql mysql?? 1677 2009-11-03 Perl.xs
-rw-r--r-- 1 mysql mysql?? 5594 2010-08-26 README
drwxr-x--- 2 mysql mysql?? 4096 05-28 19:24 t
-rwxr-xr-x 1 mysql mysql?? 5479 2009-02-25 test.pl
-rw-r--r-- 1 mysql mysql? 21306 2009-05-02 TODO_2005.txt
-rw-r--r-- 1 mysql mysql?? 2718 2009-06-08 TODO_gofer.txt
-rw-r--r-- 1 mysql mysql???? 64 2005-04-11 typemap
[root@mail DBI-1.616]# perl Makefile.PL
[root@mail DBI-1.616]# make && make install
[root@mail DBI-1.616]# cd -
/mnt
[root@mail mnt]# ll
總計 42163
-r-xr-xr-x 1 root root? 2175238 03-21 21:36 courier-authlib-0.62.4.tar.bz2
-r-xr-xr-x 1 root root?? 137736 03-21 21:37 DBD-mysql-4.020.tar.gz
-r-xr-xr-x 1 root root?? 576803 03-21 21:37 DBI-1.616.tar.gz
-r-xr-xr-x 1 root root? 2314155 03-21 21:38 dovecot-1.1.4.tar.gz
-r-xr-xr-x 1 root root?? 541279 12-21 19:34 extmail-1.2.tar.gz
-r-xr-xr-x 1 root root?? 586234 12-21 19:35 extman-1.1.tar.gz
-r-xr-xr-x 1 root root??? 22800 03-21 21:37 File-Tail-0.99.3.tar.gz
-r-xr-xr-x 1 root root 14420771 03-21 21:42 fp-Linux-i686-ws.tar.gz
-r-xr-xr-x 1 root root?? 260989 03-21 21:37 GD-2.46.tar.gz
-r-xr-xr-x 1 root root? 5864320 03-21 21:45 MailScanner-4.84.3-1.rpm.tar.gz
-r-xr-xr-x 1 root root 11439508 03-02 04:34 php-5.4.0.tar.bz2
-r-xr-xr-x 1 root root? 3644570 2011-03-24 postfix-2.8.2.tar.gz
-r-xr-xr-x 1 root root?? 474709 03-21 21:37 rrdtool-1.2.23-3.el5.i386.rpm
-r-xr-xr-x 1 root root??? 34075 03-21 21:37 rrdtool-perl-1.2.23-3.el5.i386.rpm
-r-xr-xr-x 1 root root?? 664076 04-10 17:53 squirrelmail-webmail-1.4.22.tar.gz
-r-xr-xr-x 1 root root??? 13738 03-21 21:37 Unix-Syslog-1.1.tar.gz
[root@mail mnt]# tar -zxvf DBD-mysql-4.020.tar.gz -C /usr/src/
[root@mail mnt]# cd /usr/src/DBD-mysql-4.020/
[root@mail DBD-mysql-4.020]# ll
總計 356
-rwxr-xr-x 1 mysql games? 61258 2011-08-21 ChangeLog
-rwxr-xr-x 1 mysql games?? 1948 2011-08-19 constants.h
-rwxr-xr-x 1 mysql games 146213 2011-08-21 dbdimp.c
-rwxr-xr-x 1 mysql games? 10623 2011-08-21 dbdimp.h
drwxr-xr-x 2 mysql games?? 4096 2011-08-21 eg
-rwxr-xr-x 1 mysql games? 29285 2011-08-21 INSTALL.html
drwxr-xr-x 4 mysql games?? 4096 2011-08-21 lib
-rwxr-xr-x 1 mysql games? 31297 2011-08-21 Makefile.PL
-rw-r--r-- 1 mysql games??? 713 2011-08-19 Makefile.PL.embedded
-rwxr-xr-x 1 mysql games?? 1240 2011-08-19 MANIFEST
-rwxr-xr-x 1 mysql games???? 41 2011-08-19 MANIFEST.SKIP
-rw-r--r-- 1 mysql games??? 697 2011-08-21 META.yml
-rwxr-xr-x 1 mysql games?? 1709 2011-08-19 myld
-rwxr-xr-x 1 mysql games? 22505 2011-08-21 mysql.xs
-rwxr-xr-x 1 mysql games?? 3387 2011-08-19 README
drwxr-xr-x 2 mysql games?? 4096 2011-08-21 t
-rw-r--r-- 1 mysql games??? 896 2011-08-19 TODO
[root@mail DBD-mysql-4.020]# perl Makefile.PL?
[root@mail DBD-mysql-4.020]# make && make install //三個包在編譯安裝過程提示的 警告信息 隱式函數 計算出的變量值未被使用等,只要沒有error信息就一切ok
[root@mail DBD-mysql-4.020]# cd -
/mnt
[root@mail mnt]# ll
總計 42163
-r-xr-xr-x 1 root root? 2175238 03-21 21:36 courier-authlib-0.62.4.tar.bz2
-r-xr-xr-x 1 root root?? 137736 03-21 21:37 DBD-mysql-4.020.tar.gz
-r-xr-xr-x 1 root root?? 576803 03-21 21:37 DBI-1.616.tar.gz
-r-xr-xr-x 1 root root? 2314155 03-21 21:38 dovecot-1.1.4.tar.gz
-r-xr-xr-x 1 root root?? 541279 12-21 19:34 extmail-1.2.tar.gz
-r-xr-xr-x 1 root root?? 586234 12-21 19:35 extman-1.1.tar.gz
-r-xr-xr-x 1 root root??? 22800 03-21 21:37 File-Tail-0.99.3.tar.gz
-r-xr-xr-x 1 root root 14420771 03-21 21:42 fp-Linux-i686-ws.tar.gz
-r-xr-xr-x 1 root root?? 260989 03-21 21:37 GD-2.46.tar.gz
-r-xr-xr-x 1 root root? 5864320 03-21 21:45 MailScanner-4.84.3-1.rpm.tar.gz
-r-xr-xr-x 1 root root 11439508 03-02 04:34 php-5.4.0.tar.bz2
-r-xr-xr-x 1 root root? 3644570 2011-03-24 postfix-2.8.2.tar.gz
-r-xr-xr-x 1 root root?? 474709 03-21 21:37 rrdtool-1.2.23-3.el5.i386.rpm
-r-xr-xr-x 1 root root??? 34075 03-21 21:37 rrdtool-perl-1.2.23-3.el5.i386.rpm
-r-xr-xr-x 1 root root?? 664076 04-10 17:53 squirrelmail-webmail-1.4.22.tar.gz
-r-xr-xr-x 1 root root??? 13738 03-21 21:37 Unix-Syslog-1.1.tar.gz
[root@mail mnt]# tar -zxvf extmail-1.2.tar.gz -C /usr/local/apache2/htdocs/
[root@mail mnt]# cd /usr/local/apache2/htdocs/
[root@mail htdocs]# ll
總計 16
drwxr-xr-x? 7 test test 4096 2009-12-25 extmail-1.2
-rw-r--r--? 1 root root?? 45 2007-06-12 index.html
-rw-r--r--? 1 root root?? 20 05-26 21:58 index.php
drwxr-xr-x 17 root root 4096 05-27 21:36 webmail
[root@mail htdocs]#
[root@mail htdocs]# mv extmail-1.2/ extmail
[root@mail htdocs]# cd extmail/
[root@mail extmail]# ll
總計 168
-rw-r--r-- 1 test test?? 410 2007-01-26 AUTHORS
drwxr-xr-x 2 test test? 4096 2009-11-07 cgi
-rw-r--r-- 1 test test 61170 2009-12-18 ChangeLog
-rw-r--r-- 1 test test?? 900 2006-02-20 CREDITS
-rwxr-xr-x 1 test test 14477 2009-11-07 dispatch.fcgi
-rwxr-xr-x 1 test test? 1743 2009-11-07 dispatch-init
-rwxr-xr-x 1 test test?? 234 2007-10-09 dispatch_lig.sh
-rw-r--r-- 1 test test? 1305 2007-10-09 FAQ
-rw-r--r-- 1 test test??? 90 2008-06-09 globabook.cf
drwxr-xr-x 5 test test? 4096 2007-10-09 html
-rw-r--r-- 1 test test? 3728 2008-02-24 INSTALL
drwxr-xr-x 2 test test? 4096 2009-12-18 lang
drwxr-xr-x 7 test test? 4096 2009-11-10 libs
-rw-r--r-- 1 test test? 2771 2009-11-07 README
-rw-r--r-- 1 test test 12677 2008-10-13 README.fcgi
-rw-r--r-- 1 test test? 1263 2009-11-07 README.filter
-rw-r--r-- 1 test test? 2281 2007-02-15 README.vpopmail
drwxr-xr-x 2 test test? 4096 2009-11-07 tools
-rw-r--r-- 1 test test???? 4 2009-12-25 Version
-rw-r--r-- 1 test test? 6808 2009-12-18 webmail.cf.default
[root@mail extmail]#
[root@mail extmail]# chown -R postfix.postfix cgi/
[root@mail extmail]# cp webmail.cf.default webmail.cf
[root@mail extmail]# vi webmail.cf
? 2 SYS_CONFIG = /usr/local/apache2/htdocs/extmail/
? 5 SYS_LANGDIR = /usr/local/apache2/htdocs/extmail/lang
? 8 SYS_TEMPLDIR = /usr/local/apache2/htdocs/extmail/html/
? 127 SYS_MAILDIR_BASE = /mailbox
?
? 139 SYS_MYSQL_USER = extmail
? 140 SYS_MYSQL_PASS = extmail
? 141 SYS_MYSQL_DB = extmail
? 142 SYS_MYSQL_HOST = localhost
? 143 SYS_MYSQL_SOCKET = /var/lib/mysql/mysql.sock
配置虛擬主機
[root@mail extmail]# vi /usr/local/apache2/conf/httpd.conf
??? 157 User postfix
??? 158 Group postfix
//下面的內容是在最后添加進去的
??? 491 NameVirtualHost *:80
??? 492 <VirtualHost *:80>
??? 493 ServerName mail.chenkui.com
??? 494 DocumentRoot /usr/local/apache2/htdocs/extmail/html/
??? 495 ScriptAlias /extmail/cgi/ "/usr/local/apache2/htdocs/extmail/cgi/"
??? 496 Alias /extmail/ /usr/local/apache2/htdocs/extmail/html/
??? 497 </VirtualHost>
[root@mail extmail]# /usr/local/apache2/bin/apachectl restart
打開瀏覽器輸入:http://mail.chenkui.com,此時可以看到extmail的界面了!!!!!
?//美中不足的是我這里web界面圖片無法顯示,查看了圖片路徑指向的是正常的,但不知為何,希望大家幫忙看看,如有錯誤請指出,謝謝!
安裝Extman
[root@mail htdocs]# cd /mnt
[root@mail mnt]# ll
[root@mail mnt]# tar -zxvf GD-2.46.tar.gz -C /usr/src/
[root@mail mnt]# cd /usr/src/GD-2.46/
[root@mail GD-2.46]# ll
總計 224
drwxr-xr-x 2 postfix postfix? 4096 2011-05-02 bdf_scripts
-rw-r--r-- 1 postfix postfix? 7122 2011-05-02 ChangeLog
drwxr-xr-x 2 postfix postfix? 4096 2011-05-02 demos
drwxr-xr-x 2 postfix postfix? 4096 2011-05-02 GD
-rw-r--r-- 1 postfix postfix 60602 2011-05-02 GD.pm
-rw-r--r-- 1 postfix postfix 48735 2009-01-12 GD.xs
-rw-r--r-- 1 postfix postfix 11758 2011-02-06 Makefile.PL
-rw-r--r-- 1 postfix postfix? 1438 2011-05-02 MANIFEST
-rw-r--r-- 1 postfix postfix?? 543 2011-05-02 META.yml
-rw-r--r-- 1 postfix postfix 32810 2001-12-07 qd.pl
-rw-r--r-- 1 postfix postfix 17139 2011-02-06 README
-rw-r--r-- 1 postfix postfix?? 467 2001-12-07 README.QUICKDRAW
-rw-r--r-- 1 postfix postfix? 2221 2001-12-07 README.unix
drwxr-xr-x 2 postfix postfix? 4096 2011-05-02 t
-rw-r--r-- 1 postfix postfix??? 66 2001-12-07 typemap
[root@mail GD-2.46]# perl Makefile.PL
[root@mail GD-2.46]# make && make install
[root@mail GD-2.46]# cd -
/mnt
[root@mail mnt]# ll
總計 42163
-r-xr-xr-x 1 root root? 2175238 03-21 21:36 courier-authlib-0.62.4.tar.bz2
-r-xr-xr-x 1 root root?? 137736 03-21 21:37 DBD-mysql-4.020.tar.gz
-r-xr-xr-x 1 root root?? 576803 03-21 21:37 DBI-1.616.tar.gz
-r-xr-xr-x 1 root root? 2314155 03-21 21:38 dovecot-1.1.4.tar.gz
-r-xr-xr-x 1 root root?? 541279 12-21 19:34 extmail-1.2.tar.gz
-r-xr-xr-x 1 root root?? 586234 12-21 19:35 extman-1.1.tar.gz
-r-xr-xr-x 1 root root??? 22800 03-21 21:37 File-Tail-0.99.3.tar.gz
-r-xr-xr-x 1 root root 14420771 03-21 21:42 fp-Linux-i686-ws.tar.gz
-r-xr-xr-x 1 root root?? 260989 03-21 21:37 GD-2.46.tar.gz
-r-xr-xr-x 1 root root? 5864320 03-21 21:45 MailScanner-4.84.3-1.rpm.tar.gz
-r-xr-xr-x 1 root root 11439508 03-02 04:34 php-5.4.0.tar.bz2
-r-xr-xr-x 1 root root? 3644570 2011-03-24 postfix-2.8.2.tar.gz
-r-xr-xr-x 1 root root?? 474709 03-21 21:37 rrdtool-1.2.23-3.el5.i386.rpm
-r-xr-xr-x 1 root root??? 34075 03-21 21:37 rrdtool-perl-1.2.23-3.el5.i386.rpm
-r-xr-xr-x 1 root root?? 664076 04-10 17:53 squirrelmail-webmail-1.4.22.tar.gz
-r-xr-xr-x 1 root root??? 13738 03-21 21:37 Unix-Syslog-1.1.tar.gz
[root@mail mnt]# tar -zxvf File-Tail-0.99.3.tar.gz -C /usr/src/
[root@mail mnt]# cd /usr/src/File-Tail-0.99.3/
[root@mail File-Tail-0.99.3]# ll
總計 92
-rw-r--r-- 1 10008 dip? 4812 2005-09-14 Changes
-rwxr-xr-x 1 10008 dip? 1381 1999-11-03 logwatch
-rw-r--r-- 1 10008 dip? 2471 2000-10-17 Makefile.PL
-rw-r--r-- 1 10008 dip?? 198 2005-09-14 MANIFEST
-rw-r--r-- 1 10008 dip?? 452 2005-09-14 META.yml
-rw-r--r-- 1 10008 dip? 2143 1999-02-03 README
-rwxr-xr-x 1 10008 dip? 1101 1999-02-03 select_demo
drwxr-xr-x 2 10008 dip? 4096 2005-09-14 t
-rw-r--r-- 1 10008 dip 25308 2005-09-14 Tail.pm
-rw-r--r-- 1 10008 dip 27991 2005-09-14 Tail.pm.debug
[root@mail File-Tail-0.99.3]#
[root@mail File-Tail-0.99.3]# perl Makefile.PL
File::Tail will be installed without debugging information.
This information isn't usefull unless you intend to tinker
with the code. To install with debugging enabled, use:
perl Makefile.PL LOGIT
Checking if your kit is complete...
Looks good
Writing Makefile for File::Tail
[root@mail File-Tail-0.99.3]# make && make install
[root@mail File-Tail-0.99.3]# cd -
/mnt
[root@mail mnt]# ll
總計 42163
-r-xr-xr-x 1 root root? 2175238 03-21 21:36 courier-authlib-0.62.4.tar.bz2
-r-xr-xr-x 1 root root?? 137736 03-21 21:37 DBD-mysql-4.020.tar.gz
-r-xr-xr-x 1 root root?? 576803 03-21 21:37 DBI-1.616.tar.gz
-r-xr-xr-x 1 root root? 2314155 03-21 21:38 dovecot-1.1.4.tar.gz
-r-xr-xr-x 1 root root?? 541279 12-21 19:34 extmail-1.2.tar.gz
-r-xr-xr-x 1 root root?? 586234 12-21 19:35 extman-1.1.tar.gz
-r-xr-xr-x 1 root root??? 22800 03-21 21:37 File-Tail-0.99.3.tar.gz
-r-xr-xr-x 1 root root 14420771 03-21 21:42 fp-Linux-i686-ws.tar.gz
-r-xr-xr-x 1 root root?? 260989 03-21 21:37 GD-2.46.tar.gz
-r-xr-xr-x 1 root root? 5864320 03-21 21:45 MailScanner-4.84.3-1.rpm.tar.gz
-r-xr-xr-x 1 root root 11439508 03-02 04:34 php-5.4.0.tar.bz2
-r-xr-xr-x 1 root root? 3644570 2011-03-24 postfix-2.8.2.tar.gz
-r-xr-xr-x 1 root root?? 474709 03-21 21:37 rrdtool-1.2.23-3.el5.i386.rpm
-r-xr-xr-x 1 root root??? 34075 03-21 21:37 rrdtool-perl-1.2.23-3.el5.i386.rpm
-r-xr-xr-x 1 root root?? 664076 04-10 17:53 squirrelmail-webmail-1.4.22.tar.gz
-r-xr-xr-x 1 root root??? 13738 03-21 21:37 Unix-Syslog-1.1.tar.gz
[root@mail mnt]# rpm -ivh rrdtool-1.2.23-3.el5.i386.rpm
warning: rrdtool-1.2.23-3.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 217521f6
Preparing...??????????????? ########################################### [100%]
?? 1:rrdtool??????????????? ########################################### [100%]
[root@mail mnt]# rpm -ivh rrdtool-perl-1.2.23-3.el5.i386.rpm
warning: rrdtool-perl-1.2.23-3.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 217521f6
Preparing...??????????????? ########################################### [100%]
?? 1:rrdtool-perl?????????? ########################################### [100%]
[root@mail mnt]#
[root@mail mnt]# tar -zxvf extman-1.1.tar.gz -C /usr/local/apache2/htdocs/
[root@mail mnt]# cd /usr/local/apache2/htdocs/
[root@mail htdocs]# ll
總計 20
drwxr-xr-x? 7 test test 4096 05-28 19:39 extmail
drwxr-xr-x 11 test test 4096 2009-12-24 extman-1.1
-rw-r--r--? 1 root root?? 45 2007-06-12 index.html
-rw-r--r--? 1 root root?? 20 05-26 21:58 index.php
drwxr-xr-x 17 root root 4096 05-27 21:36 webmail
[root@mail htdocs]#
[root@mail htdocs]# mv extman-1.1/ extman/
[root@mail htdocs]# cd extman/
[root@mail extman]# ll
總計 100
drwxr-xr-x 3 test test? 4096 2009-05-03 addon
-rw-r--r-- 1 test test?? 140 2005-10-22 AUTHORS
drwxr-xr-x 2 test test? 4096 2009-05-09 cgi
-rw-r--r-- 1 test test 20812 2009-12-24 ChangeLog
drwxr-xr-x 2 test test? 4096 2009-12-24 contrib
drwxr-xr-x 3 test test? 4096 2009-12-24 daemon
drwxr-xr-x 2 test test? 4096 2009-11-07 docs
drwxr-xr-x 5 test test? 4096 2009-12-24 html
-rw-r--r-- 1 test test? 3860 2007-02-13 INSTALL
drwxr-xr-x 2 test test? 4096 2009-11-08 lang
drwxr-xr-x 6 test test? 4096 2009-07-20 libs
-rw-r--r-- 1 test test? 2112 2007-03-06 README
-rw-r--r-- 1 test test 13723 2008-09-25 README.fcgi
drwxr-xr-x 2 test test? 4096 2009-12-24 tools
-rw-r--r-- 1 test test???? 4 2009-12-24 Version
-rw-r--r-- 1 test test? 5046 2009-11-08 webman.cf.default
[root@mail extman]#
[root@mail extman]# chown -R postfix.postfix cgi/
[root@mail extman]# mkdir /tmp/extman
[root@mail extman]# chown -R postfix.postfix /tmp/extman/
[root@mail extman]# cp webman.cf.default webman.cf
[root@mail extman]# vi webman.cf
??? 2 SYS_CONFIG = /usr/local/apache2/htdocs/extman/
??? 5 SYS_LANGDIR = /usr/local/apache2/htdocs/extman/lang
??? 8 SYS_TEMPLDIR = /usr/local/apache2/htdocs/extman/html
??? 12 SYS_MAILDIR_BASE = /mailbox
??? 127 SYS_MYSQL_USER = webman
??? 128 SYS_MYSQL_PASS = webman
??? 129 SYS_MYSQL_DB = extmail
??? 130 SYS_MYSQL_HOST = localhost
??? 131 SYS_MYSQL_SOCKET = /var/lib/mysql/mysql.sock
:wq
[root@mail extman]# vi /usr/local/apache2/conf/httpd.conf
??? 491 NameVirtualHost *:80
??? 492 <VirtualHost *:80>
??? 493 ServerName mail.chenkui.com
??? 494 DocumentRoot /usr/local/apache2/htdocs/extmail/html/
??? 495 ScriptAlias /extmail/cgi/ "/usr/local/apache2/htdocs/extmail/cgi/"
??? 496 Alias /extmail/ "/usr/local/apache2/htdocs/extmail/html/"
??? 497 ScriptAlias /extman/cgi/ "/usr/local/apache2/htdocs/extman/cgi/"??? // 在之前的基礎上添加的
??? 498 Alias /extman "/usr/local/apache2/htdocs/extman/html/"?????????????? //在之前的基礎上添加的
??? 499 </VirtualHost>
?
此時可以打開后臺管理界面了 http://mail.chenkui.com/extman? //注意客戶機要與服務器時間一致,否則會登錄不上
默認帳戶:root@extmail.org
默認密碼:extmail*123*
?
?
設置郵件系統的圖形化日志信息
[root@mail ~]# ln -sf /usr/local/apache2/htdocs/extman/addon/mailgraph_ext/mailgraph-init /usr/sbin/
[root@mail ~]# ln -sf /usr/local/apache2/htdocs/extman/addon/mailgraph_ext/qmonitor.pl /usr/sbin/
[root@mail ~]# cp -a /usr/local/apache2/htdocs/extman/addon/mailgraph_ext/ /usr/local/???? -a? //相當于 -pdr 的意思;-d :若來源文件為連結文件的屬性(link
file),則復制連結文件屬性而非檔案本身;-f :為強制 (force) 的意思,若有重復或其它疑問時,不會詢問使用者,而強制復制;-p :連同檔案的屬性一起復制過去,而非使用
預設屬性;
[root@mail ~]# mailgraph-init start
Starting mail statistics grapher: mailgraph_ext
Starting queue statistics grapher: qmonitor
[root@mail ~]# qmonitor.pl start &??? //&表示在后臺運行
[1] 4355
[root@mail ~]#
[root@mail ~]# echo "/usr/sbin/qmonitor.pl start" >> /etc/rc.d/rc.local??? //開機自啟動
[root@mail ~]# echo "/usr/sbin/mailgraph-init start" >> /etc/rc.d/rc.local
[root@mail ~]#
登錄Extman后臺,打開 系統——圖形日志,可以看到郵件投遞分析圖表
//在extman后臺,我沒有截圖,都是中文界面,相信大家都知道怎么操作,如何添加新域,添加管理員、用戶、配置模板等等。
?
?
配置垃圾郵件過濾
[root@mail ~]# vi /etc/postfix/main.cf
657 smtpd_client_restrictions = check_client_access hash:/etc/postfix/access??? //添加此行
[root@mail GD-2.46]# vi /etc/postfix/access
?445 192.168.1??? REJECT? //拒絕來自192.168.1.0網段的郵件
?446 192.168.10.100 OK??? //接收來自192.168.10.1的郵件
?447 qq.com????? REJECT?? //拒絕來自QQ的郵件
[root@mail ~]# postmap /etc/postfix/access //轉換為hash數據庫文件access.db
根據客戶機helo信息中的主機名地址過濾郵件。
[root@mail ~]# vi /etc/postfix/main.cf? //在最后添加下面兩行
??? 658 smtpd_helo_required = yes
??? 659 smtpd_helo_restrictions = reject_invaild_hostname
根據發件人的地址過濾郵件
[root@mail ~]# vi /etc/postfix/main.cf
smtpd_sender_login_maps = mysql:/etc/postfix/mysql_virtu l_sender_maps.cf,mysql:/etc/postfix/mysql_virtual_alias_maps.cf
smtpd_sender_restrictions = permit_mynetworks,reject_sender_login_mismatch,reject_non_fqdn_sender,reject_unknown_sender_domain,check_sender_access hash:/etc/postfix/sen
der_access
?
設置發件人地址訪問控制策略,拒絕由user1@sina.cn,任何域的admin用戶及來處mail.qq.com的用戶發送的郵件。
[root@mail ~]# vi /etc/postfix/sender_access
user1@sina.cn?? REJECT
admin@????????? REJECT
mail.qq.com???? REJECT
[root@mail ~]# postmap /etc/postfix/sender_access
[root@mail ~]# service postfix restart
設置收件人地址訪問控制策略
smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination,reject_non_fqdn_recipient,reject_unknown_recipient_domain
?
基于郵件內容過濾
[root@mail mnt]# tar -zxvf MailScanner-4.84.3-1.rpm.tar.gz -C /usr/local/src/?
[root@mail mnt]# cd /usr/local/src/MailScanner-4.84.3-1/
[root@mail mnt]#? ./install.sh
[root@mail MailScanner-4.84.3-1]# vi /etc/MailScanner/MailScanner.conf
131 Run As User = postfix??? //將運行程序的用戶設置為Postfix
136 Run As Group = postfix? //將運行程序的用戶組設置為Postfix
165 Incoming Queue Dir = /var/spool/postfix/hold????? //設置待過濾處理郵件隊列目錄
169 Outgoing Queue Dir = /var/spool/postfix/incoming?? // 設置過濾處理后的郵件隊列目錄
196 MTA = postfix?? //設置MTA服務器名稱
2231 Required SpamAssassin Score = 7?? //高于7的視為垃圾郵件?? ——垃圾郵件有個評分標準,對于國內的一般設置為7或者以上
2237 High SpamAssassin Score = 10???? //高于10的視為高分垃圾郵件
2437 Spam Actions = deliver header "X-Spam-Status: Yes"???????? //對非高分垃圾郵件采取的動作
2499 High Scoring Spam Actions = delete forward spam@extmail.org //對高分垃圾郵件采取的動作
[root@mail MailScanner-4.84.3-1]# vi /etc/postfix/main.cf? //在main.cf中啟用header_checks配置參數,設置Postfix對郵件標頭進行模式匹配檢查,并在模式查詢表文件“/etc/postfix/header_checks”中設置/^Received:/HOLD 匹配模式,從而將接收的所有郵件都放入到hold隊列中,交由MailScanner掃描調度工具處理
519 header_checks = regexp:/etc/postfix/header_checks
[root@mail MailScanner-4.84.3-1]# vi /etc/postfix/header_checks?? //設置使用模式查詢表
497 /^Received:/HOLD????
?
[root@mail MailScanner-4.84.3-1]# chown -R postfix:postfix /var/spool/MailScanner/incoming/
[root@mail MailScanner-4.84.3-1]# chown -R postfix:postfix /var/spool/MailScanner/quarantine/
[root@mail MailScanner-4.84.3-1]# service MailScanner start
Starting MailScanner daemons:
???????? incoming postfix:???????????????????????????????? [確定]
???????? outgoing postfix:???????????????????????????????? [確定]
???????? MailScanner:????????????????????????????????????? [確定]
[root@mail MailScanner-4.84.3-1]#
[root@mail MailScanner-4.84.3-1]# chkconfig --add MailScanner
[root@mail MailScanner-4.84.3-1]# chkconfig MailScanner on
[root@mail MailScanner-4.84.3-1]# chkconfig --list MailScanner
MailScanner???? 0:關閉? 1:關閉? 2:啟用? 3:啟用? 4:啟用? 5:啟用? 6:關閉
[root@mail MailScanner-4.84.3-1]# service postfix restart
?
[root@mail ~]# yum -y install spamassassin?? //掛載系統光盤包安裝
[root@mail ~]# spamassassin //其配置文件位于/etc/mail//spamassassin/local.cf 中,但是保持默認即可
[root@mail ~]#
[root@mail ~]# service spamassassin start
啟動 spamd:?????????????????????????????????????????????? [確定]
[root@mail ~]#??
在配置F-Port病毒查殺軟件時要接入Internet,下面我的虛擬機已經可以上網了
[root@mail mnt]# ping baidu.com
PING baidu.com (220.181.111.85) 56(84) bytes of data.
64 bytes from baidu.com (220.181.111.85): icmp_seq=1 ttl=53 time=71.6 ms
64 bytes from baidu.com (220.181.111.85): icmp_seq=2 ttl=53 time=74.4 ms
64 bytes from baidu.com (220.181.111.85): icmp_seq=3 ttl=53 time=106 ms
--- baidu.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2000ms
rtt min/avg/max/mdev = 71.647/84.198/106.523/15.828 ms
[root@mail mnt]# cat /etc/resolv.conf
nameserver 192.168.10.1
[root@mail mnt]#
[root@mail mnt]# tar -zxvf fp-Linux-i686-ws.tar.gz -C //配置F-Port 病毒查殺軟件
[root@mail mnt]# cd /opt/f-prot/
[root@mail f-prot]# ll
總計 28856
-rw-r--r-- 1 user1 users 27622812 2008-04-29 antivir.def
drwxr-xr-x 4 user1 users???? 4096 2008-04-29 doc
-rw-r--r-- 1 user1 users???? 9383 2008-04-29 f-prot.conf.default
-rwxr-xr-x 1 user1 users? 1519972 2008-04-29 fpscan
-rwxr-xr-x 1 user1 users?? 285032 2008-04-29 fpupdate
-rwxr-xr-x 1 user1 users??? 40063 2008-04-29 install-f-prot.pl
-rw-r--r-- 1 user1 users?????? 55 2008-04-29 license.key
lrwxrwxrwx 1 user1 users?????? 20 05-31 07:15 product.data -> product.data.default
-rw-r--r-- 1 user1 users?????? 13 2008-04-29 product.data.default
-rw-r--r-- 1 user1 users???? 6192 2008-04-29 README
[root@mail f-prot]#
[root@mail f-prot]# ./install-f-prot.pl
??????? (c) FRISK Software International
??????? http://www.f-prot.com/
??????? You are about to install F-Prot Antivirus for Linux Workstations
??????? on a RedHat Linux 2.6.18 running on i686 into the '/opt/f-prot'
??????? directory
Where do you want a symbolic link to 'F-Prot Antivirus command line scanner (fpscan)' to be created?
(Just press Enter to accept the default) [/usr/local/bin]:
Where do you want a symbolic link to 'section 8 manuals' to be created?
(Just press Enter to accept the default) [/usr/local/man/man8]:
Where do you want a symbolic link to 'section 1 manuals' to be created?
(Just press Enter to accept the default) [/usr/local/man/man1]:
Where do you want a symbolic link to 'section 5 manuals' to be created?
(Just press Enter to accept the default) [/usr/local/man/man5]:
Changing file access permissions on the installed files and directories ...ok
Checking if you have an existing license key...yes
Found an existing license key in /opt/f-prot/license.key, updating antivir.def ...
Downloading update (%100)? //已經自動從網上下載更新
We've generated the following crontab entries to update the
antivir.def file via fpupdate. Updates will be run hourly at a
randomly picked minute to distribute load, and thus make your updates
faster than if they were run during obvious high load times, e.g. on
the hour.
The global crontab entry we made to add to /etc/crontab is the following:
??????? 31 * * * * root /opt/f-prot/fpupdate > /dev/null
Would you like to have this crontab appended to /etc/crontab?
(Just press Enter to accept the default) [Y/n]: Y?
??????? All done!
?
If you reconfigured your MTA you should restart it now to activate the changes.
??????? Have a nice day
Frisk software (www.f-prot.com)
[root@mail f-prot]# ll
總計 60000
-rw-r--r-- 1 user1 users 59467267 05-31 07:31 antivir.def
drwxr-xr-x 4 user1 users???? 4096 2008-04-29 doc
-rw-r--r-- 1 root? root????? 9383 05-31 07:20 f-prot.conf
-rw-r--r-- 1 user1 users???? 9383 2008-04-29 f-prot.conf.default
-rwxr-xr-x 1 user1 users? 1519972 2008-04-29 fpscan
-rwx------ 1 user1 users?? 285032 2008-04-29 fpupdate
-rwxr-xr-x 1 user1 users??? 40063 2008-04-29 install-f-prot.pl
-rw-r--r-- 1 user1 users?????? 55 2008-04-29 license.key
lrwxrwxrwx 1 user1 users?????? 20 05-31 07:15 product.data -> product.data.default
-rw-r--r-- 1 user1 users?????? 13 2008-04-29 product.data.default
-rw-r--r-- 1 user1 users???? 6192 2008-04-29 README
[root@mail f-prot]# /opt/f-prot/fpupdate
[root@mail f-prot]#???????????????????????????????????????????? [確定]
[root@mail ~]# crontab -e??????????
00 23 * * * /opt/f-port/fpupdate????? //設置每天晚上11點自動更新病毒庫
[root@mail ~]# service crond restart
停止 crond:?????????????????????????????????????????????? [確定]
啟動 crond:?????????????????????????????????????????????? [確定]
[root@mail ~]# chkconfig --level 35 crond on
?
測試郵件內容過濾及病毒測試
登錄postmaster@extmail.org,給自己發一封測試郵件,內容分別包含下面字符串,在日志中查看效果
測試郵件內容過濾,下面是一段字符串:
XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X
測試郵件防病毒機制
X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*
?
?
本實驗很多參考了北大青鳥benet 3.0課程教材,之前做這個實驗,用的版本有所不同,但是沒出現什么問題,就是在最后病毒測試一項,沒有見到效果,這個大家可以換其他的殺毒軟件試試,以上如有錯誤請指出,本人會及時更正,謝謝!
?
轉載于:https://blog.51cto.com/loveroot/882443
總結
以上是生活随笔為你收集整理的LAMP平台下构建Postfix邮件服务器的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 梦到女人下面是什么意思
- 下一篇: 好久不更新这个博客了。