Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3862060
  • 博文数量: 421
  • 博客积分: 685
  • 博客等级: 上将
  • 技术积分: 3670
  • 用 户 组: 普通用户
  • 注册时间: 2010-02-18 14:20
文章分类

全部博文(421)

文章存档

2012年(5)

2011年(52)

2010年(83)

2009年(67)

2008年(65)

2007年(149)

分类: LINUX

2009-05-14 16:03:58

邮件服务器系统的安装
本文约定:默认情况下,本文中的所有软件的压缩安装文件都放在 /root 目录下,除非特别说明的情况下。
友情提示:本文中用红色字体标的“注意”部分与文档后面的 FAQ 部分,仅作参考之用,如果你在安装的时候遇到类似问题,可以提供一个解决问题的思路之用。
禁用 selinux
[root @test root]# vi /etc/selinux/conifg
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#       enforcing - SELinux security policy is enforced.
#       permissive - SELinux prints warnings instead of enforcing.
#       disabled - SELinux is fully disabled.
将 SELINUX=enforcing
改成
SELINUX=disabled
# SELINUXTYPE= type of policy in use. Possible values are:
#       targeted - Only targeted network daemons are protected.
#       strict - Full SELinux protection.
SELINUXTYPE=targeted
Selinux 是 linux 系统中一个强制性的安全机制,但也带来了不少麻烦,为了避免不必要的麻烦,还是先关了吧。我之前在 Fedora cora 5 上安装邮件服务器时就因为没有关掉 selinux ,而苦恼了一段时间。
1、        安装 mysql
添加虚帐户mysql 并同时产生一个 mysql 组。注:如果系统中已有就不必添加了。
[root @test root]# groupadd  mysql
[root @test root]# useradd -g mysql mysql
解压缩mysql 安装文件
[root @test root]# cp mysql-5.0.45-linux-i686-glibc23.tar.gz /usr/local
[root @test root]# cd /usr/local
[root @test local]#tar xvzf mysql-5.0.45-linux-i686- glibc23.tar.gz
[root @test local]#ln -s mysql-5.0.45-linux-i686- glibc23 mysql
[root @test local] # mv /etc/my.cnf /etc/my.cnf.bak
[root @test local] # cp mysql/support-files/my-medium.cnf /etc/my.cnf
初始化 mysql 数据库
[root @test local]# cd mysql
[root @test mysql]#./script/mysql_install_db  —user=mysql &
修改目录所有权限为mysql 所有
[root @test mysql]#chown -R root .
[root @test mysql]#chown -R mysql:mysql data
[root @test mysql]#chgrp -R mysql .
启动测试mysql
[root @test local]#/usr/local/mysql/bin/safe_mysqld —user= mysql &
Starting mysqld daemon with databases from /usr/local/mysql/data
查看 mysql 是否已经正式启动       
[root @test local] # netstat –tlunp | grep mysql

/////****************************** 注 意 ***************************
这一步可以省略,可以先查看在 /tmp 目录下是否存在 mysql.sock 这个文件,如果没有的话,就需要链接,有的话,就不必啦。
[root @test local]#ln -s /var/lib/mysql/mysql.sock /tmp/
注:将/var/lib/mysql/mysql.sock 链接到 /tmp 目录下,并保持名称不变,如果不这样做的话,有时候可能mysql 启动时会报错,如 ERROR 200:Can’t connect to local MYSQL server throuht socket /tmp/mysql.sock.
******************************************************************\\\\\\\\\

复制一个编译目录的脚本,以使 mysql 每次启动时都能自动运行
[root @test mysql]#cp support-files/mysql.server /etc/rc.d/init.d/mysqld
[root @test mysql]#chmod 755 /etc/init.d/mysqld
[root @test mywql]#chkconfig —add mysqld
[root @test mysql]#chkconfig —level 35 mysqld on
[root @test local] # mkdir /usr/local/mysql/lib/mysql
[root @test local] # mkdir /usr/local/mysql/include/mysql
[root @test local] # chown root.mysql /usr/local/mysql/lib/mysql
[root @test local] # chwon root.mysql /usr/local/mysql/include/mysql
[root @test local] # ln –s /usr/local/mysql/lib/* /usr/local/mysql/lib/mysql
[root @test local] # ln –s /usr/local/mysql/include/* /usr/local/mysql/include/mysql
[root @ test local] # echo “/usr/local/mysql/lib/mysql” >> /etc/ld.so.conf
[root @ test local] # ldconfig
2、安装 openssl
[root @ test root] # tar zxvf openssl-0.9.8e.tar.gz
[root @ test root] # cd openssl-0.9.8e
[root @ test openssl-0.9.8e] # ./config shared zlib
[root @ test openssl-0.9.8e] # make
[root @ test openssl-0.9.8e] # make test
[root @ test openssl-0.9.8e] # make install
[root @ test openssl-0.9.8e] # mv /usr/bin/openssl /usr/bin/openssl.OFF
[root @ test openssl-0.9.8e] # mv /usr/include/openssl /usr/include/openssl.OFF
[root @ test openssl-0.9.8e] # rm -rf /usr/lib/libssl.so
[root @ test openssl-0.9.8e] # ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl
[root @ test openssl-0.9.8e] #ln -s /usr/local/ssl/include/openssl /usr/include/openssl
[root @ test openssl-0.9.8e] # ln -sv /usr/local/ssl/lib/libssl.so.0.9.8  /usr/lib/libssl.so

配置库文件搜索路径
[root @ test openssl-0.9.8e] #echo "/usr/local/ssl/lib" >> /etc/ld.so.conf
[root @ test openssl-0.9.8e] # ldconfig
检查是否安装 openssl
[root @ test openssl-0.9.8e] # openssl version
OpenSSL 0.9.8e 23 Feb 2007
2、        安装 cyrus-sasl
[root @ test openssl-0.9.8e] # cd
[root @ test root] # tar xzvf cyrus-sasl-2.1.22.tar.gz
[root @ test root] # cd cyrus-sasl-2.1.22
[root @ test 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
[root @ test cyrus-sasl-2.1.22] # make
[root @ test cyrus-sasl-2.1.22] # make install
关闭原有的 sasl
[root @ test cyrus-sasl-2.1.22] # mv /usr/lib/libsasl2.a  /usr/lib/libsasl2.a.OFF
[root @ test cyrus-sasl-2.1.22] # mv /usr/lib/libsasl2.la  /usr/lib/libsasl2.la.OFF
[root @ test cyrus-sasl-2.1.22] # mv /usr/lib/libsasl2.so.2.0.19  /usr/lib/libsasl2.so.2.0.19.OFF
[root @ test cyrus-sasl-2.1.22] # mv /usr/lib/sasl2  /usr/lib/sasl2.OFF
[root @ test cyrus-sasl-2.1.22] # rm -rf /usr/lib/libsasl2.so
[root @ test cyrus-sasl-2.1.22] # rm –rf /usr/lib/libsasl2.so.2
[root @ test cyrus-sasl-2.1.22] # ln -s /usr/local/sasl2/lib/*  /usr/lib
postfix 2.3以后的版本会分别在/usr/local/lib和/usr/local/include中搜索sasl库文件及头文件,故还须将其链接至此目录中:
[root @ test cyrus-sasl-2.1.22] # ln -sv /usr/local/sasl2/lib/*  /usr/local/lib
[root @ test cyrus-sasl-2.1.22] # ln -sv /usr/local/sasl2/include/sasl/*  /usr/local/include
创建运行时需要的目录并调试启动
[root @ test cyrus-sasl-2.1.22] # mkdir -pv /var/state/saslauthd      
[root @ test cyrus-sasl-2.1.22] # /usr/local/sasl2/sbin/saslauthd  -a  shadow  pam  -d

使用Ctrl +C 中断
启动并测试
[root @ test cyrus-sasl-2.1.22] # /usr/local/sasl2/sbin/saslauthd -a shadow pam
配置库文件搜索路径
[root @ test cyrus-sasl-2.1.22] # echo "/usr/local/sasl2/lib" >> /etc/ld.so.conf
[root @ test cyrus-sasl-2.1.22] # echo "/usr/local/sasl2/lib/sasl2" >> /etc/ld.so.conf
[root @ test cyrus-sasl-2.1.22] # ldconfig

开机自动启动
[root @ test cyrus-sasl-2.1.22] # echo "/usr/local/sasl2/sbin/saslauthd -a shadow pam">>/etc/rc.local
4、安装 Berkeley-DB
[root @ test root] # tar zxvf db-4.5.20.tar.gz
[root @ test root] # cd db-4.5.20/build_unix
[root @ test build_unix] #../dist/configure —prefix=/usr/local/BerkeleyDB
[root @ test build_unix] #make
[root @ test build_unix] #make install

修改相应的头文件指向
[root @ test build_unix] # mv  /usr/inculde/db4  /usr/inculde/db4.OFF
[root @ test build_unix] # rm  -rf /usr/inculde/db_cxx.h
[root @ test build_unix] # rm  -rf /usr/inculde/db.h
[root @ test build_unix] # rm  -rf /usr/inculde/db_185.h
[root @ test build_unix] # ln -s /usr/local/BerkeleyDB/include  /usr/include/db4
[root @ test build_unix] # ln -s /usr/local/BerkeleyDB/include/db.h  /usr/include/db.h
[root @ test build_unix] # ln –s /usr/local/BerkeleyDB/include/db_cxx.h  /usr/include/db_cxx.h

配置库文件搜索路径
[root @ test build_unix] # echo "/usr/local/BerkeleyDB/lib" >> /etc/ld.so.conf
[root @ test build_unix] # ldconfig

5、安装httpd-2.2.4
[root @ test root] # tar jxvf httpd-2.2.4.tar.bz2
[root @ test root] # cd httpd-2.2.4
[root @ test httpd-2.2.4] #./configure
--prefix=/usr/local/apache --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  
[root @ test httpd-2.2.4] # make
[root @ test httpd-2.2.4] # make install
[root @ test httpd-2.2.4] # echo "/usr/local/apache/bin/apachectl start" >> /etc/rc.local(系统启动时服务自动启动)

6、安装php-5.2.3

[root @ test root] # tar -zvxf php-5.2.3.tar.gz
[root @ test root] # mkdir -p /usr/local/php
[root @ test root] # cd php-5.2.3
[root @ test php-5.2.3] # ./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-xml   —with-png
  —with-jpeg   —with-zlib   —with-freetype   —with-gd    —enable-track-vars    —enable-mbstring=all
[root @ test php-5.2.3] # make
[root @ test php-5.2.3] # make install
[root @ test php-5.2.3] # cp php.ini-dist  /usr/local/php/lib/php.ini

注:编辑apache配置文件httpd.conf,以apache支持php
[root @ test php-5.2.3] # vi /usr/local/apache/conf/httpd.conf
# 添加如下二行
  AddType application/x-httpd-php  .php
  AddType application/x-httpd-php-source  .phps

# 定位至DirectoryIndex index.html
  修改为:
   DirectoryIndex  index.php  index.html

# 这里将网站根目录指定到/var/www:
找到DocumentRoot “/usr/local/apache/htdocs”
修改为:DocumentRoot “/var/www”(后文中我们还会注释掉此行,以启用虚拟主机)

找到
修改为:





以下这些博文,你可能同样感兴趣:

    
阅读(1567) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~