RHEL5+postfix+mysql+extmai(源代码)
一、(1)配置rhel5的yum服务以方便安装常用软件
#service iptables stop
#chkconfig iptables off
#mkdir /media/cdrom
#mount /dev/cdrom /media/cdrom
#vim /etc/yum.repos.d/rhel-debuginfo.repo
修改为以下内容:
[rhel-debuginfo]
name=Red Hat Enterprise Linux $releasever - $basearch - Debug
baseurl=file:///media/cdrom/Server
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
(2)安装开发工具
#yum install gcc*
二、 安装配置dns(bind)服务器
#yum install bind caching-nameserver bind-chroot
#cp -a /etc/named.caching-nameserver.conf /etc/named.conf
# vim /etc/named.conf
直接分别执行下面两个末行模式命令:
:%s/127.0.0.1/any/g
:%s/localhost/any/g
保存退出
# vim /etc/named.rfc1912.zones
文件末尾加入以下内容:
zone "test.com" IN {
type master;
file "test.com.zone";
};
zone "16.172.in-addr.arpa" IN {
type master;
file "16.172";
};
保存退出
# cp -a /var/named/chroot/var/named/localhost.zone /var/named/chroot/var/named/test.com.zone
#vim /var/named/chroot/var/named/test.com.zone
删除最下面两行写入下面两行:
@ IN MX 5 mail.test.com.
mail IN A 172.16.17.86
保存退出
#cp -a /var/named/chroot/var/named/named.local /var/named/chroot/var/named/16.172
#vim /var/named/chroot/var/named/16.172
删除最下面一行,写入下面内容:
保存退出
#service named restart
#chkconfig named on
#echo 'nameserver 172.16.17.86' > /etc/resolv.conf
验证解析
# nslookup
> 172.16.17.86
Server: 172.16.17.86
Address: 172.16.17.86#53
86.17.16.172.in-addr.arpa name = mail.test.com.
> mail.test.com
Server: 172.16.17.86
Address: 172.16.17.86#53
Name: mail.test.com
Address: 172.16.17.86
> set type=mx
> test.com
Server: 172.16.17.86
Address: 172.16.17.86#53
test.com mail exchanger = 5 mail.test.com.
>exit
三、
四、安装mysql服务器(用数据库存储用户信息)
#groupadd mysql
#useradd –g mysql –s /bin/false –M mysql
#tar -zxvf mysql-
#cd /usr/local/src/mysql-
#yum install ncurses-devel
#./configure --prefix=/usr/local/mysql --enable-thread-safe-client --enable-local-infile --with-charset=gbk --with-extra-charset=all --with-low-memory
#make
#make install
#cp /usr/local/src/mysql-
#cd /usr/local/mysql
#chown -R mysql:mysql .
#bin/mysql_install_db --user=mysql
#chown -R root .
#chown -R mysql var
#bin/mysqld_safe --user=mysql &
#cd /usr/local/src/mysql-
#cp support-files/mysql.server /etc/rc.d/init.d/mysqld
#chmod 700 /etc/rc.d/init.d/mysqld
#chkconfig --add mysqld
#chkconfig mysqld on
#/usr/local/mysql/bin/mysqladmin ping
mysqld is alive
# /usr/local/mysql/bin/mysqladmin version
/usr/local/mysql/bin/mysqladmin Ver 8.41 Distrib
Copyright (C) 2000 MySQL AB & MySQL
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL license
Server version
Protocol version 10
Connection Localhost via UNIX socket
UNIX socket /tmp/mysql.sock
Uptime: 4 min 7 sec
Threads: 1 Questions: 2 Slow queries: 0 Opens: 0 Flush tables: 1 Open tables: 6 Queries per second avg: 0.008
#/usr/local/mysql/bin/mysql –u root -p[f1]
mysql> grant all privileges on *.* to root@"%" identified by 'password[f2] ' with grant option;[f3]
mysql>quit
配置库文件搜索路径
# echo "/usr/local/mysql/lib/mysql" >> /etc/ld.so.conf
# ldconfig -v
添加/usr/local/mysql/bin到环境变量PATH中
#export PATH=$PATH:/usr/local/mysql/bin
#ln -sv /usr/local/mysql/bin/* /usr/bin/
#service mysqld restart
[f1]使用root用户连接mysql数据库默认密码为空
[f2]本地root密码
[f3]让root用户通过3066端口连到数据库让root用户通过3066端口连到数据库
五、安装openssl(基于密码学的安全开发包)
#tar -zxvf openssl-
#cd /usr/local/src/openssl-
#yum install zlib-devel
#./config shared zlib
#make
#make test
#make install
#mv /usr/bin/openssl /usr/bin/openssl.OFF
# ln -sv /usr/local/ssl/bin/openssl /usr/bin/openssl
# ln -sv /usr/local/ssl/include/openssl /usr/include/openssl
# ln -sv /usr/local/ssl/lib/libssl.so.
# echo "/usr/local/ssl/lib" >> /etc/ld.so.conf
# ldconfig
# ldconfig -v
检测安装结果
# openssl version
openSSL
六、安装ssl(安全套接层协议)
http://www.oracle.com/database/berkeley-db.html
#tar -zxvf cyrus-sasl-
#cd /usr/local/src/cyrus-sasl-
#./configure --prefix=/usr/local/sasl2 --disable-gssapi --disable-anon --disable-sample --disable-digest --enable-plain --enable-login --enable-sql --with-mysql=/usr/local/mysql --with-mysql-includes=/usr/local/mysql/include/mysql --with-mysql-libs=/usr/local/mysql/lib/mysql --with-authdaemond=/usr/local/courier-authlib/var/spool/authdaemon/socket
#cp /usr/local/src/cyrus-sasl-
#make
#make install
# mv /usr/lib/libsasl2.so.
# mv /usr/lib/sasl2 /usr/lib/sasl2.OFF
#rm –rf /usr/lib/libsasl2.so.2
#rm -rf /usr/sbin/pluginviewer
# rm -rf /usr/sbin/saslauthd
# rm -rf /usr/sbin/sasldblistusers2
# rm -rf /usr/sbin/saslpasswd2
# rm -rf /usr/sbin/testsaslauthd
# ln -sv /usr/local/sasl2/lib/* /usr/lib
# ln -sv /usr/local/sasl2/lib/* /usr/local/lib
# ln -sv /usr/local/sasl2/include/sasl/* /usr/local/include
# ln -sv /usr/local/sasl2/sbin/* /usr/sbin
# ln -sv /usr/local/sasl2/sbin/* /usr/local/sbin/
# mkdir -pv /var/state/saslauthd
启动测试
# /usr/local/sbin/saslauthd -a shadow pam
# /usr/local/sbin/testsaslauthd -u root -p password[f1]
0: OK "Success."
配置库文件搜索路径
# echo "/usr/local/sasl2/lib" >> /etc/ld.so.conf
# echo "/usr/local/sasl2/lib/sasl2" >> /etc/ld.so.conf
# ldconfig
# ldconfig -v
配置开机启动
#echo "/usr/local/sbin/saslauthd -a shadow pam">>/etc/rc.local
[f1]本地root密码
七、安装db库(嵌入式数据库系统)
http://www.oracle.com/technology/products/berkeley-db/db/index.html
#tar -zxvf db-
#cd /usr/local/src/db-
#../dist/configure --prefix=/usr/local/BerkeleyDB
#make
#make install
修改相应文件指向
# ln -sv /usr/local/BerkeleyDB/include /usr/include/db4
# ln -sv /usr/local/BerkeleyDB/include/db.h /usr/include/db.h
# ln -sv /usr/local/BerkeleyDB/include/db_cxx.h /usr/include/db_cxx.h
配置库文件搜索路径
# echo "/usr/local/BerkeleyDB/lib" >> /etc/ld.so.conf
# ldconfig
# ldconfig -v
八、安装httpd(Web方式管理邮件)
http://archive.apache.org/dist/httpd/binaries
#tar jxvf httpd-
#cd /usr/local/src/httpd-
#./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-cgi --enable-so --enable-ssl --with-ssl=/usr/local/ssl --enable-track-vars --enable-rewrite --with-zlib --enable-mods-shared=most --enable-suexec --with-suexec-caller=daemon --with-suexec-docroot=/var/www/extsuite/
#make
#make install
#echo "/usr/local/apache/bin/apachectl start" >> /etc/rc.local
九、安装php(Php 解释器,与apache一起使用)
#tar jxvf php-
# mkdir -p /usr/local/php
# cd /usr/local/src/php-
#./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-zlib
#make
#make install
#cp php.ini-dist /usr/local/php/lib/php.ini
#vim /etc/httpd/httpd.conf
修改以下内容(大约351行,添加后面两行,针对php支持)
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php .php
AddType application/x-httpd-source .phps
(209行,将index.html改为index.php)
<IfModule dir_module>
DirectoryIndex index.php
</IfModule>
(147行,修改默认网站目录)
DocumentRoot "/var/www"
(174行,修改默认目录)
<Directory "/var/www">
#mkdir –p /var/www
#echo "<? phpinfo(); ?>" > /var/www/index.php
# /usr/local/apache/bin/apachectl restart
httpd: Syntax error on line 99 of /etc/httpd/httpd.conf: Cannot load /usr/local/apache/modules/libphp5.so into server: /usr/local/apache/modules/libphp5.so: cannot restore segment prot after reloc: Permission denied[f1]
#chcon -t texrel_shlib_t /usr/local/apache/modules/libphp5.so
客户端直接使用浏览器输入地址浏览即可(http://172.16.17.86)
本文转自legendfu51CTO博客,原文链接:http://blog.51cto.com/legendfu/1073368 ,如需转载请自行联系原作者