一、(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
删除最下面一行,写入下面内容:
86.17 IN PTR mail.test.com.
保存退出
#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服务器(用数据库存储用户信息)
http://downloads.mysql.com
#groupadd mysql
#useradd –g mysql –s /bin/false –M mysql
#tar -zxvf mysql- 5.0.22 .tar.gz -C /usr/local/src/
#cd /usr/local/src/mysql- 5.0.22 /
#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- 5.0.22 /support-files/my-medium.cnf /etc/my.cnf
#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- 5.0.22 /
#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 5.0.22 , for pc-linux-gnu on i686
Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
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 5.0.22 -log
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(基于密码学的安全开发包)
www.openssl.org
#tar -zxvf openssl- 0.9.8 h.tar.tar -C /usr/local/src/
#cd /usr/local/src/openssl- 0.9.8 h/
#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. 0.9.8 /usr/lib/libssl.so
# echo "/usr/local/ssl/lib" >> /etc/ld.so.conf
# ldconfig
# ldconfig -v
检测安装结果
# openssl version
openSSL 0.9.8 h 28 May 2008
六、安装ssl(安全套接层协议)
http://www.oracle.com/database/berkeley-db.html
#tar -zxvf cyrus-sasl- 2.1.22 .tar.tar -C /usr/local/src/
#cd /usr/local/src/cyrus-sasl- 2.1.22 /
#./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- 2.1.22 /mac/libdes/public/des.h ./
#make
#make install
# mv /usr/lib/libsasl2.so. 2.0.22 /usr/lib/libsasl2.so.2.0.22.OFF
# 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- 4.7.25 .tar.gz -C /usr/local/src/
#cd /usr/local/src/db- 4.7.25 /build_unix/
#../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- 2.2.4 .tar.bz2 -C /usr/local/src/
#cd /usr/local/src/httpd- 2.2.4 /
#./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一起使用)
http://www.php.net
#tar jxvf php- 5.2.5 .tar.bz2 –C /usr/local/src
# mkdir -p /usr/local/php
# cd /usr/local/src/php- 5.2.5
#./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)
[f1]和selinux有关,需要下面命令修改库文件类型