前言:
本文着重描述CNFUG服务器具体的配置过程,其中包括了Apache,MySQL,Php,Qmail,Qmailadmin,vpopmail等……
这算是一个完整的服务器的配置过程了!希望大家看了这篇文档能够有所启发,能够更加灵活的运用FreeBSD构建
更强大的服务!
系统环境:
FreeBSD 4.8 Stable(具体如何将系统升级到Stable我就不多说了,请参考FreeBSD的Handbook)
Qmail安装路径/usr/local/qmail/
Vpopmail安装路径/home/vpopmail/
Apache安装路径/server/httpd/
Forum路径/www/cnfug/forum/htdocs/
Mail主页路径/www/cnfug/mail/htdocs/
Mail-cgi-bin路径/www/cnfug/mail/cgi-bin/
MySQL安装路径/server/mysql/
php安装路径/server/php/
[url=http://www.pccode.net].net" class="wordstyle"源码存放路径/source/src/
[url=http://www.pccode.net].net" class="wordstyle"源码编译路径/source/build/
安装MySQL
添加MySQL相应的用户和组 #pw groupadd mysql -g 3306
#pw useradd mysql -u 3306 -c "MySQL Daemon" -d /server/mysql -g 3306 -s /nonexitent
#tar zxvf mysql-4.0.13.tar.gz -C /server/build
#cd /server/build/mysql-4.0.13/
#./configure --prefix=/server/mysql --with-mysqld-ldflag=all-static --with--charset=gbk --with-low-memory --enable-assembler --disable-shared --without-docs
#make
#make install
#scripts/mysql_install_db (安装数据库)
#cp support-files/my-medium.cnf /etc/my.cnf
#vi /etc/my.cnf 添加user=mysql 如果你想让你的数据库独立出来,可以指定数据库的路径
在/etc/my.cnf中添加 datadir=/www/MySQL/data cp /server/mysql/lib/mysql/libmysqlclient* /usr/lib/ //这一步非常重要,不然在后面使用vpopmail添加domain时候会报错//安全设置:修改权限 #chown -R mysql:mysql /server/mysql
#chmod -R go-xwr /server/mysql#/server/mysql/bin/mysqld_safe &
#/server/mysql/bin/mysqladmin -u root password 'newpassword' //修改MySQL的root密码!重要!
#/server/mysql/bin/mysql -u root -p 输入你的密码!你现在就应该可以用MySQL了!
添加MySQL用户:
mysql>use mysql;
//建立vpopmail和ezmlm需要的用户和相应的数据库
mysql>grant select,insert,update,delete,create,drop on vpopmail.* to vpopmail@localhost identified by '12345678';
mysql>grant select,insert,update,delete,create,drop on ezmlm.* to ezmlm@localhost identified by '12345678';
mysql>create database vpopmail;
mysql>create database ezmlm;
mysql>show status;
mysql>status;
mysql>show databases;安装Apache
添加Apache相关的用户和组(默认FreeBSD已经建立了该用户,如果没有请添加) #pw groupadd www -g 80
#pw useradd www -u 80 -c "World Wide Web Owner" -d /server/httpd -g 80 -s /nonexitent如果有,请做如下修改 #pw usermod www -d /server/httpd -s /nonexitent
#tar zxvf httpd-2.0.47.tar.gz -C /source/build
#cd /source/build/httpd-2.0.47/
#./configure --prefix=/server/httpd --enable-mods-shared=all --enable-module=so --enable-ssl=shared --disable-status --disable-userdir --enable-suexec=shared
#make
#make install
#chown -R www:www /server/httpd
#/server/httpd/bin/apachectl start
安装PHP #tar jxvf php-4.3.2.tar.bz2 -C /source/build/
#cd /source/build/php-4.3.2/
#./configure --prefix=/server/php --enable-track-vars --with-mysql=/server/mysql --with-apxs2=/server/httpd/bin/apxs --with-gd=/usr/server/gd(可选)
#make
#make install
#cp php.ini-recommended /server/php/lib/php.ini 在/server/httpd/conf/httpd.conf中添加如下脚本LoadModule php4_module modules/libphp4.so
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps(这一行可以不添加)
安装Qmail
//建立安装目录
mkdir -p /usr/local/qmail/alias
//建立相关的用户和组
#pw groupadd nofiles
#pw useradd alias -g nofiles -m -d /usr/local/qmail/alias -s /nonexistent
#pw useradd qmaild -g nofiles -d /usr/local/qmail -s /nonexistent
#pw useradd qmaill -g nofiles -d /usr/local/qmail -s /nonexistent
#pw useradd qmailp -g nofiles -d /usr/local/qmail -s /nonexistent
#pw groupadd qmail
#pw useradd qmailq -g qmail -d /usr/local/qmail -s /nonexistent
#pw useradd qmailr -g qmail -d /usr/local/qmail -s /nonexistent
#pw useradd qmails -g qmail -d /usr/local/qmail -s /nonexistent
查看建好的用户和组 #pw user show -a
#pw group show -a安装Qmail #tar zxvf qmail-1.03.tar.gz
//对Qmail打补丁
#patch -p0 < qmail-103.patch
#tar zxvf qmail-smtpd-auth-0.30.tar.gz
#cd qmail-smtpd-auth-0.30
#cp base* README.auth ../qmail-1.03
#patch -d ../qmail-1.03 < auth.patch 编辑conf-qmail修改其中的路径为/usr/local/qmail这样qmail就安装到/usr/local/qmail目录下!默认是在/var/qmail目录下!
//执行make检查
#make setup check
./config-fast cnfug.org
//修正SMTP认证信息人员输入和任意更改电子邮件发信人地址的补丁
#cp qmail-smtpd.c qmail-1.03/
#patch < qmail-smtpd.patch.txt
#make qmail-smtpd
#cp qmail-smtpd /usr/local/qmail/bin/qmail-smtpd
//建立邮件帐号的别名
#cd /usr/local/qmail/alias
#touch .qmail-postmaster .qmail-mailer-daemon .qmail-root
#chmod 644 /usr/local/qmail/alias/.qmail*
//建立Qmail启动文件
#cp /usr/local/qmail/boot/home /usr/local/qmail/rc
#perl -i -pe 's/Mailbox/Maildir/' /usr/local/qmail/rc
#perl -i -pe 's/sendmail_enable="YES"/sendmail_enable="NONE"/' /etc/rc.conf
#perl -i -pe 's/sendmail_submit_enable="YES"/sendmail_submit_enable="NO"/' /etc/defaults/rc.conf
#perl -i -pe 's/sendmail_outbound_enable="YES"/sendmail_outbound_enable="NO"/' /etc/defaults/rc.conf
#perl -i -pe 's/sendmail_msp_queue_enable="YES"/sendmail_msp_queue_enable="NO"/' /etc/defaults/rc.conf
#mv /usr/lib/sendmail /usr/lib/sendmail.bak(在FreeBSD下该命令不需要)
#mv /usr/sbin/sendmail /usr/sbin/sendmail.bak
#chmod u+x /usr/local/qmail/bin/sendmail
#ln -s /usr/local/qmail/bin/sendmail /usr/lib/sendmail(在FreeBSD下该命令不需要)
#ln -s /usr/local/qmail/bin/sendmail /usr/sbin/sendmail
#mkdir -p /etc/qmail
#echo "csh -cf '/usr/local/qmail/rc &'">>/etc/qmail/start
#echo "/etc/qmail/smtp.sh">>/etc/qmail/start
安装ucspi-tcp
tar zxvf ucspi-tcp-0.88.tar.gz
cd ucspi-tcp-0.88
修改conf-home为/usr/local/qmail(安装到路径/usr/local/qmail/bin/目录下) #vi conf-home
make
make setup check//生成tcp.smtp.cdb
echo "127.0.0.1:allow,RELAYCLIENT="\"\" > /etc/qmail/tcp.smtp
/usr/local/qmail/bin/tcprules /etc/qmail/tcp.smtp.cdb /etc/qmail/tcp.smtp.tmp < /etc/qmail/tcp.smtp
检查qmaild的uid和gid pw user show qmaild
qmaild:*:3308:3307::0:0:User &:/usr/local/qmail:/nonexistent它的uid是3308,gid是3307 #echo "/usr/local/qmail/bin/tcpserver -H -R -l cnfug.org -t 1 -c 100 -v -p -x /etc/qmail/tcp.smtp.cdb -u 3308 -g 3307 0 smtp /usr/local/qmail/bin/qmail-smtpd /home/vpopmail/bin/vchkpw /usr/bin/true /usr/local/qmail/bin/cmd5checkpw /usr/bin/true 2>&1 | /usr/local/qmail/bin/splogger &">/etc/qmail/smtp.sh#chmod 755 /etc/qmail/smtp.sh
cmd5checkpw的安装 make
cp cmd5checkpw /usr/local/qmail/bin/vpopmail的安装
在MySQL中添加vpopmail的用户! /server/mysql/bin/mysql -u root -p
mysql> grant select,insert,update,delete,create,drop on vpopmail.* to vpopmail@localhost identified by '12345678';#mkdir -p /home/vpopmail/etc
#pw groupadd vchkpw -g 89
#pw useradd vpopmail -u 89 -g 89 -d /home/vpopmail -s /nonexistent
#echo "/etc/qmail/start">>/etc/rc.conf
vi vmysql.h 修改一下内容
#define MYSQL_UPDATE_SERVER "localhost" (mysql服务器名)
#define MYSQL_UPDATE_USER "vpopmail" (用户名)
#define MYSQL_UPDATE_PASSWD "12345678" (改成你设置的密码)
#define MYSQL_READ_SERVER "localhost" (mysql服务器名)
#define MYSQL_READ_USER "vpopmail" (用户名)
#define MYSQL_READ_PASSWD "12345678" (改成你设置的密码)
#./configure --prefix=/home/vpopmail --enable-mysql=y --enable-incdir=/server/mysql/include/mysql --enable-libdir=/server/mysql/lib/mysql --enable-libs=/server/mysql/lib/mysql --enable-default-domain=cnfug.org --enable-passwd=n --enable-defaultquota=52428800s --enable-tcprules-prog=/usr/local/qmail/bin/tcprules --enable-tcpserver-file=/etc/qmail/tcp.smtp --enable-vpopuser=vpopmail --enable-vpopgroup=vchkpw --enable-ip-alias-domains=n --enable-roaming-users=y --enable-sqwebmail-pass=y --enable-qmaildir=/usr/local/qmail
#make
#make install-strip
#chmod +s /home/vpopmail/bin/vchkpw
#cd /home/vpopmai/bin/
#./vadddomain cnfug.org(添加一个cnfug.org的域,按提示输入postmaster的密码!)
#./vdeldomain cnfug.org(将cnfug.org域删除!目的是为了修改vpopmail的数据表的结构)
mysql>use vpopmail;
mysql>drop tables vpopmail;
在mysql中建立数据库vpopmail在数据库中建立如下表: mysql>
create table vpopmail (
pw_id int(5) unsigned NOT NULL auto_increment,
pw_name varchar(32) NOT NULL default '',
pw_domain varchar(64) NOT NULL default '',
pw_passwd varchar(40) NOT NULL default '',
pw_uid int(11) default NULL,
pw_gid int(11) default NULL,
pw_gecos varchar(64) default NULL,
pw_dir varchar(160) default NULL,
pw_shell varchar(20) default NULL,
pw_clear_passwd varchar(16) default NULL,
PRIMARY KEY (pw_id),
KEY pw_name (pw_name,pw_domain)
) TYPE=MyISAM;再次通过/home/vpopmail/bin/vadddomain cnfug.org建立cnfug.org的域#echo "/usr/local/qmail/bin/tcpserver -c 100 -v -l cnfug.org -U -H -R 0 pop3 /usr/local/qmail/bin/qmail-popup cnfug.org /home/vpopmail/bin/vchkpw /usr/local/qmail/bin/qmail-pop3d Maildir 2>&1 | /usr/local/qmail/bin/splogger &">/etc/qmail/pop.sh
#chmod 755 /etc/qmail/pop.sh
安装ezmlm-0.53
在MySQL建立相关的用户和表 mysql> use mysql
Database changed
mysql> create database ezmlm;
mysql> grant select,insert,update,delete,create,drop on ezmlm.* to ezmlm@localhost identified by '12345678'; 解压ezmlm #tar zxvf ezmlm-0.53.tar.gz
#tar zxvf ezmlm-idx.0.40.tar.gz
#cp -Rp ezmlm-idx.0.40/* ezmlm-0.53/