您的位置:首页 > 运维架构 > 网站架构

构建企业网站和邮件应用平台

2012-03-30 10:01 447 查看
构建企业网站和邮件应用平台
任务:
0、搭建dns(benet.com)(具体步骤此文档省略)
1、
构建LAMP环境(采用源码包安装)
2、
架设Discuz中文论坛
3、
安装配置电子邮件系统
4、
安装配置vsfptd服务器 (具体步骤此文档省略)

步骤1:构建LAMP环境(采用源码包安装)
共享所需数据包:
[root@localhost ~]#
mkdir /share
[root@localhost ~]#
mount -o username=wgn //192.168.1.66/bb /share
Password:
[root@localhost ~]# cd
/share
[root@localhost share]#
ls
Discuz_6.1.0_SC_UTF8.zip php-5.2.6.tar.bz2
httpd-2.2.9.tar.gz
phpMyAdmin-2.11.9.5-all-languages.tar.gz
mysql-5.0.56.tar.gz UCenter_1.0.0_SC_UTF8.zip

1.1安装apache
1.1.1先卸载rpm包安装的httpd
[root@localhost
~]# rpm -e httpd --nodeps
[root@localhost ~]# service httpd status
httpd: 未被识别的服务
1.1.2安装apache
[root@localhost share]# tar zxvf httpd-2.2.9.tar.gz
-C /usr/src/
[root@localhost share]# cd /usr/src/ httpd-2.2.9/
[root@localhost httpd-2.2.9]#
./configure --prefix=/usr/local/apache2 --enable-so --enable-rewrite
--enable-cgi --enable-suexec --enable-ssl --enable-charset-lite && make
&& make install
(注:安装过程较长大约15[/b]分钟左右,可同时进行安装mysql[/b],合理安排时间)[/b]
1.1.3调整服务控制脚本及开机启动
[root@localhost ~]# cp -pf /usr/local/apache2/bin/apachectl
/etc/init.d/httpd
[root@localhost ~]# echo "service
httpd start" >> /etc/rc.local

1.2安装mysql
1.2.1安装mysql
[root@localhost share]# tar zxvf mysql-5.0.56.tar.gz
-C /usr/src/
[root@localhost share]# cd /usr/src/mysql-5.0.56/
[root@localhost mysql-5.0.56]#
useradd -M -s /sbin/nologin mysql
[root@localhost mysql-5.0.56]#
./configure --prefix=/usr/local/mysql && make && make install
1.2.2调整配置文件,服务控制脚本及开机启动
[root@localhost ~]# cd /usr/src/mysql-5.0.56/
[root@localhost mysql-5.0.56]#
cp support-files/my-medium.cnf /etc/my.cnf
[root@localhost mysql-5.0.56]#
cp support-files/mysql.server /etc/init.d/mysqld
[root@localhost mysql-5.0.56]#
chmod a+x /etc/init.d/mysqld
[root@localhost mysql-5.0.56]#
chkconfig --add mysqld
[root@localhost mysql-5.0.56]#
chkconfig --level 35 mysqld on
1.2.3初始化数据库
[root@localhost ~]# cd
/usr/local/mysql/
[root@localhost
mysql]# bin/mysql_install_db --user=mysql
1.2.4设置目录权限
[root@localhost mysql]#
chown -R :mysql ./
[root@localhost
mysql]# chown -R mysql var
[root@localhost
mysql]# ln -sf /usr/local/mysql/bin/mysql /usr/bin
[root@localhost
mysql]# cat /etc/ld.so.conf

[root@localhost
mysql]# echo "/usr/local/mysql/lib/mysql" >> /etc/ld.so.conf

[root@localhost
mysql]# ldconfig
(此步骤如果不做,会影响后面postfix的安装)

1.3安装php
1.3.1编译安装php
[root@localhost ~]# cd /share/
[root@localhost
share]# tar jxvf php-5.2.6.tar.bz2 -C
/usr/src/
[root@localhost share]# cd /usr/src/php-5.2.6/
[root@localhost
php-5.2.6]#./configure --prefix=/usr/local/php5
--with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql --enable-sockets
&& make && make install
1.3.2复制配置文件
[root@localhost ~]# cd /usr/src/php-5.2.6/
[root@localhost php-5.2.6]#
cp php.ini-dist /usr/local/php5/php.ini
[root@localhost php-5.2.6]#
ln -sf /usr/local/php5/bin/php /usr/bin/php

1.4配置lamp,并启动相关服务
1.4.1配置httpd,并启动服务
vi
/usr/local/apache2/conf/httpd.conf

ServerName www.benet.com
DirectoryIndex index.html index.php
AddType application/x-httpd-php .php

vi /etc/hosts
192.168.1.2 www.benet.com
(第一步dns[/b]如若没做,验证的时候可暂时先在host[/b]文件加如上配置)[/b]
[/b]
[root@localhost ~]# service httpd start
[root@localhost
~]# netstat -anptu | grep :80
tcp
0 0 :::80 :::* LISTEN 4501/httpd

[root@localhost
~]# cd /usr/local/apache2/htdocs/
[root@localhost
htdocs]# vi index.php

<?php
phpinfo();
?>php

测试能不能正常访问[/b]index.html[/b]和[/b]index.php[/b]

1.4.2启动mysql服务
[root@localhost htdocs]# service mysqld
start
Starting
MySQL. [确定]
[root@localhost
htdocs]# netstat -naptu | grep mysql
tcp 0
0 0.0.0.0:3306 0.0.0.0:* LISTEN 4657/mysqld

步骤2:架设Discuz中文论坛
2.1建立用于bbs的数据库及用户
[root@localhost ~]# export
PATH=/usr/local/mysql/bin:$PATH
[root@localhost ~]# mysql
mysql> create database bbsdb;
mysql> grant all on bbsdb.* to
runbbs@localhost identified by 'pwd@123';
2.2配置Ucenter
[root@localhost share]# unzip UCenter_1.0.0_SC_UTF8.zip
-d /ucenter
[root@localhost share]# mv /ucenter/upload/
/usr/local/apache2/htdocs/ucenter
[root@localhost share]# cd
/usr/local/apache2/htdocs/ucenter/
[root@localhost ucenter]# chown -R daemon
./data/
浏览中访问http://www.benet.com/ucenter/install,对Ucenter进行安装



2.3配置Discuz
[root@localhost share]# cd /share/
[root@localhost share]# unzip Discuz_6.1.0_SC_UTF8.zip
-d /discuz
[root@localhost share]# mv /discuz/upload/
/usr/local/apache2/htdocs/bbs
[root@localhost share]# cd
/usr/local/apache2/htdocs/bbs/
[root@localhost bbs]# chown -R daemon
config.inc.php attachments/ forumdata/ uc_client/

浏览中访问:http://www.benet.com/bbs/install,安装bbs

步骤3:安装配置电子邮件系统
[root@localhost share]#
cd /share/
[root@localhost share]#
ls
dovecot-1.1.4.tar.gz postfix-2.4.6-vda-ng.patch.gz zh_CN-1.4.13-20071220.tar.bz2
postfix-2.4.6.tar.gz squirrelmail-1.4.13.tar.bz2

3.1停止系统自带的sendmail服务
[root@localhost ~]#
service sendmail status
sendmail (pid 2613
2605) 正在运行...
[root@localhost ~]#
service sendmail stop
关闭 sm-client: [确定]
关闭 sendmail: [确定]
[root@localhost ~]#
chkconfig --list sendmail
sendmail 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭
[root@localhost ~]#
chkconfig sendmail off
[root@localhost ~]#
chkconfig --list sendmail
sendmail 0:关闭 1:关闭 2:关闭 3:关闭 4:关闭 5:关闭 6:关闭

3.2编译安装并配置postfix
穿件邮件相关用户、组:[/b]
[root@localhost ~]#
groupadd -g 1000 postfix
[root@localhost ~]#
groupadd -g 1200 postdrop
[root@localhost ~]#
useradd -u 1000 -g postfix -G postdrop -M -s /sbin/nologin postfix

编译安装:[/b]
[root@localhost share]#
tar zxvf postfix-2.4.6.tar.gz -C
/usr/src/
[root@localhost
~]# cd /usr/src/postfix-2.4.6/
[root@localhost
postfix-2.4.6]# make makefiles
'CCARGS=-DHAS_MYSQL -I/usr/local/mysql/include/mysql -DUSE_SASL_AUTH
-DUSE_CYRUS_SASL -I/usr/include/sasl'
'AUXLIBS=-L/usr/local/mysql/lib/mysql -lmysqlclient -lz -lm
-L/usr/lib/sasl2 -lsasl2 ' && make &&
make install
(提醒:编译[/b]postfix[/b]可同时进行[/b]dovecot[/b]的安装以节省时间)[/b]

建立配置文件:[/b]
root@localhost
postfix]# postconf -n > main2.cf
[root@localhost
postfix]# mv main.cf main.cf.bak
[root@localhost
postfix]# mv main2.cf main.cf

[root@localhost
postfix]# vi main.cf
inet_interfaces =
192.168.1.2,127.0.0.1
myhostname = mail.benet.com
mydomain = benet.com
myorigin = $mydomain
mydestination = $myhostname,$mydomain
home_mailbox = Maildir/
alias_maps = hash:/etc/aliases //别名设置,用语群发
message_size_limit = 10000000 //设置邮件大小限制(10M左右)
mailbox_size_limit = 100000000 //设置邮箱大小限制(100M左右)

启动服务:[/b]
[root@localhost
postfix]# echo "/usr/sbin/postfix start" >> /etc/rc.local
[root@localhost
postfix]# postfix start

3.3编译安装并配置dovecot
[root@localhost ~]#
useradd -M -s /sbin/nologin dovecot
[root@localhost ~]# cd
/share/
[root@localhost share]#
tar zxvf dovecot-1.1.4.tar.gz -C /usr/src/

编译安装:[/b]
[root@localhost share]#
cd /usr/src/dovecot-1.1.4/
[root@localhost
dovecot-1.1.4]# ./configure
--sysconfdir=/etc/ && make
&& make install
[/b]
建立配置文件:[/b]
[root@localhost
dovecot-1.1.4]# cp /etc/dovecot-example.conf
/etc/dovecot.conf
[root@localhost
dovecot-1.1.4]# vi /etc/dovecot.conf
protocols = imap pop3
disable_plaintext_auth = no
ssl_disable = yes
mail_location =
maildir:~/Maildir

建立认证文件:[/b]
[root@localhost
dovecot-1.1.4]# vi /etc/pam.d/dovecot
#%PAM-1.0
auth
required pam_nologin.so
auth
include system-auth
account
include system-auth
session
include system-auth

启动服务:[/b]
[root@localhost
dovecot-1.1.4]# echo
"/usr/local/sbin/dovecot -c /etc/dovecot.conf" >> /etc/rc.local
[root@localhost
dovecot-1.1.4]# dovecot
[root@localhost
dovecot-1.1.4]# netstat -naptu | grep dovecot
tcp 0
0 0.0.0.0:110 0.0.0.0:* LISTEN 28019/dovecot
tcp 0
0 0.0.0.0:143 0.0.0.0:* LISTEN 28019/dovecot

3.4测试smtp发信、pop3收信
[root@localhost ~]#
useradd tom
[root@localhost ~]#
useradd jerry
[root@localhost ~]#
passwd tom
[root@localhost ~]#
passwd jerry
测试发信:[/b]
[root@localhost named]#
telnet mail.benet.com 25
Trying 192.168.1.2...
Connected to
mail.benet.com (192.168.1.2).
Escape character is
'^]'.
220 mail.benet.com
ESMTP Postfix
mail from:tom@benet.com
250 2.1.0
Ok
rcpt to:jerry@benet.com
250 2.1.5
Ok
data
354 End data with
<CR><LF>.<CR><LF>
subject: test
hellllllllllllllllllllooooooooooooooo
.
250 2.0.0
Ok: queued as 2F0F37680BF
quit
221 2.0.0
Bye
Connection closed by
foreign host.

测试收信:[/b]
[root@localhost named]#
telnet mail.benet.com 110
Trying 192.168.1.2...
Connected to
mail.benet.com (192.168.1.2).
Escape character is
'^]'.
+OK Dovecot ready.
user jerry
+OK
pass jerry
+OK Logged in.
list
+OK 1 messages:
1 480
.
retr 1
+OK 480 octets
Return-Path:
<tom@benet.com>
X-Original-To:
jerry@benet.com
Delivered-To:
jerry@benet.com
Received: from
www.benet.com (www.benet.com [192.168.1.2])
by mail.benet.com (Postfix) with SMTP id 2F0F37680BF
for <jerry@benet.com>; Sat, 11 Dec 2010 16:38:51 +0800 (CST)
subject: test
Message-Id:
<20101211083900.2F0F37680BF@mail.benet.com>
Date: Sat, 11 Dec 2010
16:38:51 +0800 (CST)
From: tom@benet.com
To:
undisclosed-recipients:;

hellllllllllllllllllllooooooooooooooo
.
quit
+OK Logging out.
Connection closed by
foreign host.

3.5安装邮件系统的web见面程序
解压缩:[/b]
root@localhost ~]# cd
/share/
[root@localhost share]#
tar jxvf squirrelmail-1.4.13.tar.bz2 -C
/usr/local/apache2/htdocs/
[root@localhost share]#
cd /usr/local/apache2/htdocs/
[root@localhost
htdocs]# mv squirrelmail-1.4.13 webmail

中文包支持:[/b]
[root@localhost
htdocs]# cd webmail/
[root@localhost
webmail]# tar jxvf /share/zh_CN-1.4.13-20071220.tar.bz2

穿件附件目录和数据目录:[/b]
[root@localhost
webmail]# mkdir -p attach data
[root@localhost
webmail]# chown -R daemon:daemon attach/ data/
[root@localhost webmail]#
chmod 730 attach/

建立配置文件:[/b]
[root@localhost
webmail]# cp config/config_default.php config/config.php
[root@localhost
webmail]# vi config/config.php
$squirrelmail_default_language = 'zh_CN';
$default_charset = 'zh_CN.UTF-8';
$domain = 'benet.com';
$imap_server_type = 'dovecot';
$data_dir =
'usr/local/apache2/htdocs/webmail/data/';
$attachment_dir =
'/usr/local/apache2/htdocs/webmail/attach/';

配置基于域名的虚拟主机:[/b]
[root@localhost
webmail]# vi /usr/local/apache2/conf/httpd.conf
NameVirtualHost
192.168.1.2
<VirtualHost
192.168.1.2>
DocumentRoot "/usr/local/apache2/htdocs"
ServerName www.benet.com
</VirtualHost>
<VirtualHost 192.168.1.2>

DocumentRoot
"/usr/local/apache2/htdocs/webmail"

ServerName mail.benet.com
</VirtualHost>
[root@localhost
webmail]# service httpd restart

3.6在客户端使用邮件系统
浏览器中访问:http://mail.benet.com



内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息