分享
 
 
 

安装完整的http+ftp+mail的linux server

王朝system·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

从代码安装完整的http+ftp+mail的linux server

菜鸟花了大约两个月装了一台linux server,包括kernel/apache2/PHP(GD)/MYSQL/qmail(smtp用户认证)/pureftp等,现在贴出来让大家分享,有问题请到http://www.garhee.com/bbs/的linux论坛提问(转贴别删)

1、安装linux和重编译linux内核

先到redhat.com下载linux 7.3, 和kernel.org下载需要的linux kernel版本

为什么选择7.3?因为简单,集成的东西少,我只需要http ftp mysql mail,而且为了发扬diy精神,我全部软件都从源代码安装。

安装linux时,注意不要把不要的东西安装

到kernel.org下载你需要的kernel代码包,我下载的是2.4.20 25在linux7.3上我没有编译通过,不知哪位大侠编译通过的,劳驾到我的论坛http://www.garhee.com/bbs/告诉我一声,谢谢!

进入到linux kernel代码的目录,

更改Makefile文件中的EXTRAVERSION = minikernel,并且把安装时装进去的linux kernel0的源代码的config文件拷贝过来用,在redhat最好使用redhat自己提供的config文件

执行下面的命令:

make menuconfig

make dep

make bzImage

make modules

make modules_install

在make menuconfig时,可以去掉这些没必要的东西:

Plug and Play configuration

Telephony Support

IEEE 1394 (FireWire) support (EXPERIMENTAL)

Amateur Radio support

IrDA (infrared) support

ISDN subsystem

Multimedia devices

Sound

USB support

Bluetooth support

其他的子选项请读者自己斟酌去掉以缩小内核大小,还有记得另存为自己知道的config文件

由于我用的是scsi(aix79xx)硬盘,所以到http://adaptec.com下载了最新版本的驱动aic79xx-2.0.2-source.tar.gz,覆盖了drivers/scsi/aic79xx目录,再编译。

这样,硬盘哗啦哗啦的转了一大段时间后,终于编译完成了,该执行如下步骤:

cp arch/i386/boot/bzImage /boot/vmlinuz-2.4.20minikernel

cp vmlinux /boot/vmlinux-2.4.20minikernel

cp System.map /boot/System.map-2.4.20minikernel

cd /lib/modules

mkinitrd /boot/initrd-2.4.20minikernel.img 2.4.20minikernel

这时候编译好的内核就拷贝到/boot目录下了,更改/boot/grub/grub.conf或/etc/lilo.conf,增加一条启动项目指向编译好的新内核。lilo启动的话还有执行/sbin/lilo -v。重启后就可以选择新内核了。

另外,一定要ntsysv禁用掉telnet,用ssh

参考文章:《浅谈Linux安全》 http://www.phpx.com/index.php?itemid=227

《linux下SSH配合SecureCRT的密匙完美使用方法》 http://www.5ilinux.com/ssh01.html

2、安装apache2

到apache.org下载最新的apache2版本,解压并执行:

./configure --prefix=/server/apache2 --enable-so --enable-mods-shared=most

make

make install

参考文章:《apache的静态/动态编译在apache+php+mysql的应用》http://www.5ilinux.com/apache01.html

3、安装mysql

到mysql.com下载,编译命令:

./configure --prefix=/server/mysql

make

make install

在/etc/ld.so.conf增加一行:

/server/mysql/lib/mysql

执行ldconfig

4、安装php+gd+zlib+freetype2+mmcache

freetype2

http://www.freetype.org/下载最新版本的freetype2,编译命令:

./configure --prefix=/server/freetype2

make

make install

zlib

http://www.zlib.org/http://www.gzip.org/zlib/下载最新版本的zlib,编译命令:

./configure --prefix=/server/zlib

make

make install

gd

http://www.boutell.com/gd/下载最新版本

./configure --prefix=/server/gdlib --with-png=/usr --with-jpeg=/usr --with-freetype=/server/freetype

make

make install

在/etc/ld.so.conf增加一行:

/server/gdlib/lib

执行ldconfig

php

到php.net下载php4,我安装时php5用不了mmcache,新版本不知出来了没有

./configure --prefix=/server/php --with-config-file-path=/server/php/etc --with-mysql=/server/mysql --with-apxs2=/server/apache2/bin/apxs --with-gd=/server/gdlib --enable-gd-native-ttf --enable-gd-imgstrttf --with-jpeg-dir=/usr/lib --with-png-dir=/usr/lib --with-zlib-dir=/server/zlib --with-freetype-dir=/server/freetype2

mmcache

http://turck-mmcache.sourceforge.net下载

export PHP_PREFIX="/server/php"

$PHP_PREFIX/bin/phpize

./configure --enable-mmcache=shared --with-php-config=$PHP_PREFIX/bin/php-config

make

make install

在php.ini文件Dynamic Extensions中增加:

extension="/server/php/lib/php/extensions/mmcache.so"

mmcache.shm_size="16"

mmcache.cache_dir="/tmp/mmcache"

mmcache.enable="1"

mmcache.optimizer="1"

mmcache.check_mtime="1"

mmcache.debug="0"

mmcache.filter=""

mmcache.shm_max="0"

mmcache.shm_ttl="0"

mmcache.shm_prune_period="0"

mmcache.shm_only="0"

mmcache.compress="1"

建目录:

mkdir /tmp/mmcache

chmod 0777 /tmp/mmcache

参考文章:《PHP 利器一箩筐》http://www.phpx.com/index.php?itemid=237

5、安装qmail

http://www.qmail.org/下载qmail最新版本和ucspi-tcp daemontools

http://www.inter7.com/下载vpopmail qmailadmin sqwebmail最新版本

qmail

安装文档qmail http://www.lifewithqmail.org/lwq.html#installation-issues

ucspi http://cr.yp.to/ucspi-tcp.html

daemontools http://cr.yp.to/daemontools.html

安装ucspi-tcp:

make

make setup check

安装deamontools:

package/install

mkdir /var/qmail

groupadd nofiles

useradd qmaild -g nofiles -d /var/qmail -s /bin/false

useradd alias -g nofiles -d /var/qmail/alias -s /bin/false

useradd qmaill -g nofiles -d /var/qmail -s /bin/false

useradd qmailp -g nofiles -d /var/qmail -s /bin/false

groupadd qmail

useradd qmailq -g qmail -d /var/qmail -s /bin/false

useradd qmailr -g qmail -d /var/qmail -s /bin/false

useradd qmails -g qmail -d /var/qmail -s /bin/false

make setup check

生成文件/var/qmail/rc

#!/bin/sh

# Using stdout for logging

# Using control/defaultdelivery from qmail-local to deliver message by default

exec env - PATH="/var/qmail/bin:$PATH" qmail-start " cat /var/qmail/control/defaultdelivery "

chmod 755 /var/qmail/rc

mkdir /var/log/qmail

echo ./Mailbox >/var/qmail/control/defaultdelivery

生成文件/var/qmail/bin/qmailctl

#!/bin/sh

# description: the qmail MTA

PATH=/var/qmail/bin:/bin:/usr/bin:/usr/local/bin:/usr/local/sbin

export PATH

QMAILDUID=`id -u qmaild`

NOFILESGID=`id -g qmaild`

case "$1" in

start)

echo "Starting qmail"

if svok /service/qmail-send ; then

svc -u /service/qmail-send /service/qmail-send/log

else

echo "qmail-send supervise not running"

fi

if svok /service/qmail-smtpd ; then

svc -u /service/qmail-smtpd /service/qmail-smtpd/log

else

echo "qmail-smtpd supervise not running"

fi

if svok /service/qmail-pop3d ; then

svc -u /service/qmail-pop3d /service/qmail-pop3d/log

else

echo qmail-pop3d supervise not running

fi

if [ -d /var/lock/subsys ]; then

touch /var/lock/subsys/qmail

fi

;;

stop)

echo "Stopping qmail..."

echo " qmail-smtpd"

svc -d /service/qmail-smtpd /service/qmail-smtpd/log

echo " qmail-send"

svc -d /service/qmail-send /service/qmail-send/log

echo " qmail-pop3d"

svc -d /service/qmail-pop3d /service/qmail-pop3d/log

if [ -f /var/lock/subsys/qmail ]; then

rm /var/lock/subsys/qmail

fi

;;

stat)

svstat /service/qmail-send

svstat /service/qmail-send/log

svstat /service/qmail-smtpd

svstat /service/qmail-smtpd/log

svstat /service/qmail-pop3d

svstat /service/qmail-pop3d/log

qmail-qstat

;;

doqueue|alrm|flush)

echo "Flushing timeout table and sending ALRM signal to qmail-send."

/var/qmail/bin/qmail-tcpok

svc -a /service/qmail-send

;;

queue)

qmail-qstat

qmail-qread

;;

reload|hup)

echo "Sending HUP signal to qmail-send."

svc -h /service/qmail-send

;;

pause)

echo "Pausing qmail-send"

svc -p /service/qmail-send

echo "Pausing qmail-smtpd"

svc -p /service/qmail-smtpd

echo "Pausing qmail-pop3d"

svc -p /service/qmail-pop3d

;;

cont)

echo "Continuing qmail-send"

svc -c /service/qmail-send

echo "Continuing qmail-smtpd"

svc -c /service/qmail-smtpd

echo "Continuing qmail-pop3d"

svc -c /service/qmail-pop3d

;;

restart)

echo "Restarting qmail:"

echo "* Stopping qmail-smtpd."

svc -d /service/qmail-smtpd /service/qmail-smtpd/log

echo "* Sending qmail-send SIGTERM and restarting."

svc -t /service/qmail-send /service/qmail-send/log

echo "* Restarting qmail-smtpd."

svc -u /service/qmail-smtpd /service/qmail-smtpd/log

echo "* Restarting qmail-pop3d."

svc -t /service/qmail-pop3d /service/qmail-pop3d/log

;;

cdb)

tcprules /etc/qmail/tcp.smtp.cdb /etc/qmail/tcp.smtp.tmp < /etc/qmail/tcp.smtp

chmod 644 /etc/qmail/tcp.smtp.cdb

echo "Reloaded /etc/qmail/tcp.smtp."

tcprules /etc/qmail/tcp.pop3.cdb /etc/qmail/tcp.pop3.tmp < /etc/qmail/tcp.pop3

chmod 644 /etc/qmail/tcp.smtp.cdb

echo "Reloaded /etc/qmail/tcp.pop3."

;;

help)

cat < stop -- stops mail service (smtp connections refused, nothing goes out)

start -- starts mail service (smtp connection accepted, mail can go out)

pause -- temporarily stops mail service (connections accepted, nothing leaves)

cont -- continues paused mail service

stat -- displays status of mail service

cdb -- rebuild the tcpserver cdb file for smtp

restart -- stops and restarts smtp, sends qmail-send a TERM & restarts it

doqueue -- schedules queued messages for immediate delivery

reload -- sends qmail-send HUP, rereading locals and virtualdomains

queue -- shows status of queue

alrm -- same as doqueue

flush -- same as doqueue

hup -- same as reload

HELP

;;

*)

echo "Usage: $0 "

exit 1

;;

esac

exit 0

mkdir -p /var/qmail/supervise/qmail-send/log

mkdir -p /var/qmail/supervise/qmail-smtpd/log

生成/var/qmail/supervise/qmail-send/run

#!/bin/sh

exec /var/qmail/rc

生成/var/qmail/supervise/qmail-send/log/run

#!/bin/sh

exec /usr/local/bin/setuidgid qmaill /usr/local/bin/multilog t /var/log/qmail

生成/var/qmail/supervise/qmail-smtpd/run

#!/bin/sh

QMAILDUID=`id -u vpopmail`

NOFILESGID=`id -g vpopmail`

MAXSMTPD=`cat /var/qmail/control/concurrencyincoming`

LOCAL=`head -1 /var/qmail/control/me`

if [ -z "$QMAILDUID" -o -z "$NOFILESGID" -o -z "$MAXSMTPD" -o -z "$LOCAL" ]; then

echo QMAILDUID, NOFILESGID, MAXSMTPD, or LOCAL is unset in

echo /var/qmail/supervise/qmail-smtpd/run

exit 1

fi

if [ ! -f /var/qmail/control/rcpthosts ]; then

echo "No /var/qmail/control/rcpthosts!"

echo "Refusing to start SMTP listener because it'll create an open relay"

exit 1

fi

exec /usr/local/bin/softlimit -m 5000000 /usr/local/bin/tcpserver -v -R -l "$LOCAL" -x /etc/qmail/tcp.smtp.cdb -c "$MAXSMTPD" -u "$QMAILDUID" -g "$NOFILESGID" 0 smtp /var/qmail/bin/qmail-smtpd 2>&1

生成/var/qmail/supervise/qmail-smtpd/log/run

#!/bin/sh

exec /usr/local/bin/setuidgid qmaill /usr/local/bin/multilog t /var/log/qmail/smtpd

生成/var/qmail/supervise/qmail-pop3d/run

#!/bin/sh

QMAILDUID=`id -u vpopmail`

NOFILESGID=`id -g vpopmail`

LOCAL=`head -1 /var/qmail/control/me`

if [ -z "$QMAILDUID" -o -z "$NOFILESGID" -o -z "$LOCAL" ]; then

echo QMAILDUID, NOFILESGID, or LOCAL is unset in

echo /var/qmail/supervise/qmail-pop3d/run

exit 1

fi

exec /usr/local/bin/softlimit -m 5000000 /usr/local/bin/tcpserver -R -H -x /etc/qmail/tcp.pop3.cdb -u "$QMAILDUID" -g "$NOFILESGID" 0 110 /var/qmail/bin/qmail-popup "$LOCAL" /server/vpopmail/bin/vchkpw /var/qmail/bin/qmail-pop3d Maildir 2>&1

生成/var/qmail/supervise/qmail-pop3d/log/run

#!/bin/sh

exec /usr/local/bin/setuidgid qmaill /usr/local/bin/multilog t /var/log/qmail/pop3d

echo 20 > /var/qmail/control/concurrencyincoming

chmod 644 /var/qmail/control/concurrencyincoming

chmod 755 /var/qmail/supervise/qmail-send/run

chmod 755 /var/qmail/supervise/qmail-send/log/run

chmod 755 /var/qmail/supervise/qmail-smtpd/run

chmod 755 /var/qmail/supervise/qmail-smtpd/log/run

mkdir -p /var/log/qmail/smtpd

chown qmaill /var/log/qmail /var/log/qmail/smtpd

mkdir -p /var/log/qmail/pop3d

chown qmaill /var/log/qmail /var/log/qmail/pop3d

mkdir /etc/qmail

echo '127.:allow,RELAYCLIENT=""' >>/etc/qmail/tcp.smtp

echo ':allow' >>/etc/qmail/tcp.pop3

qmailctl cdb

vpopmail

groupadd -g 89 vchkpw

useradd -g vchkpw -u 89 vpopmail

用/server/mysql/bin/mysql登录进mysql,建vpopmail数据库

CREATE DATABASE vpopmail;

GRANT select,insert,update,delete,create,drop ON vpopmail.*

TO vpopmailuser@localhost IDENTIFIED BY 'vpoppasswd';

./configure --prefix=/server/vpopmail --enable-qmaildir=/var/qmail --enable-vpopuser=vpopmail --enable-vpopgroup=vchkpw --enable-roaming-users --enable-tcprules-prog=/usr/local/bin/tcprules --enable-tcpserver-file=/etc/qmail/tcp.smtp --enable-relay-clear-minutes=20 --enable-auth-logging --enable-mysql-logging --enable-clear-passwd --disable-sqwebmail-pass --enable-log-name=vpopmail --enable-incdir=/server/mysql/include/mysql --enable-libdir=/server/mysql/lib/mysql --enable-libs=mysqlclient --enable-auth-module=mysql --enable-ip-alias-domains --enable-mysql-limits --enable-many-domains --disable-passwd --enable-mysql-limits

make

make install-strip

echo "localhost|0|vpopmailuser|vpoppasswd|vpopmail" > /server/vpopmail/etc/vpopmail.mysql

chown vpopmail.vchkpw /server/vpopmail/etc/vpopmail.mysql

chmod 640 ~vpopmail/etc/vpopmail.mysql

echo 'mydomain.com' >/var/qmail/control/rcpthosts

/var/qmail/bin/vadddomain mydomain.com

qmailadmin

./configure --enable-cgibindir=/server/apache2/cgi-bin --enable-htmldir=/server/apache2/htdocs

make

make install

sqwebmail

./configure --prefix=/server/sqwebmail --with-cachedir=/server/sqwebmail/cachetmp --enable-imagedir=/server/apache2/htdocs/webmail --enable-cgibindir=/server/apache2/cgi-bin --enable-softtimeout=1200 --enable-hardtimeout=1800 --with-fcgi

make

make install

ln -s /var/qmail/supervise/qmail-send /var/qmail/supervise/qmail-smtpd /var/qmail/supervise/qmail-pop3d /service

启动apache,就可以从qmailadmin用 postmaster@mydomain.com 来登录管理mydomain.com。增加一个email地址test@mydomain.com后,就可以用outlook和test@mydomain.com用户进行收发email了。

其他安装文章:《基于qmail的完整WEBMAIL解决方案安装详解》http://www.phpx.com/index.php?itemid=130

6、smtpd用户认证功能

下载http://www.garhee.com/download/qmail-smtpd.c ;这个是从netqmail-1.05版本更改过来的,如果要改新版本,请对照更改

/var/qmail/bin/qmailctl stop

更改/var/qmail/supervise/qmail-smtpd/run中的

exec /usr/local/bin/softlimit -m 5000000 /usr/local/bin/tcpserver -v -R -l "$LOCAL" -x /etc/qmail/tcp.smtp.cdb -c "$MAXSMTPD" -u "$QMAILDUID" -g "$NOFILESGID" 0 smtp /var/qmail/bin/qmail-smtpd 2>&1

exec /usr/local/bin/softlimit -m 5000000 /usr/local/bin/tcpserver -v -H -R -l "$LOCAL" -x /etc/qmail/tcp.smtp.cdb -c "$MAXSMTPD" -u "$QMAILDUID" -g "$NOFILESGID" 0 smtp /var/qmail/bin/qmail-smtpd /server/vpopmail/bin/vchkpw /bin/true 2>&1

/var/qmail/bin/qmailctl start

7、安装pureftpd

http://mirrors.sunsite.dk/pure-ftpd/下载(pureftp.org给封掉了)

http://home.9812.net/linux/article/pureftpd/下载安装配置文件

./configure --prefix=/server/pureftp --with-boring --with-throttling --with-ratios --with-virtualhosts --with-virtualchroot --with-peruserlimits --with-mysql=/server/mysql --with-ftpwho --with-language=simplified-chinese --without-inetd --without-shadow --with-diraliases --with-sysquotas --with-altlog --with-quotas --with-privsep

make

make install

cp pureftpd-mysql.conf /server/pureftp/etc/

cp configuration-file/pure-ftpd.conf /server/pureftp/etc/

修改两个configure文件直到满意

cp configuration-file/pure-config.pl /server/pureftp/bin/

增加一行/server/pureftp/sbin/pure-ftpd到:

-x && ($PUREFTPD=$_, last) for qw(

$/sbin/pure-ftpd

/usr/local/pure-ftpd/sbin/pure-ftpd

/usr/local/pureftpd/sbin/pure-ftpd

/usr/local/sbin/pure-ftpd

/usr/sbin/pure-ftpd

/server/pureftp/sbin/pure-ftpd

);

useradd ftp -u 1111 -g proftpgroup -s /bin/false -d /bin/null -c "pureftpd user"

登录mysql执行sql语句:

create database pureftp;

GRANT ALL ON pureftp.* TO pureftp@localhost IDENTIFIED BY 'purepasswd';

CREATE TABLE `users` (

`id` int(32) unsigned NOT NULL auto_increment,

`User` varchar(16) NOT NULL default '',

`Password` varchar(64) NOT NULL default '',

`Uid` varchar(11) NOT NULL default '-1',

`Gid` varchar(11) NOT NULL default '-1',

`Dir` varchar(128) NOT NULL default '',

`QuotaSize` smallint(5) NOT NULL default '0',

`QuotaFiles` int(11) NOT NULL default '0',

`ULBandwidth` smallint(5) NOT NULL default '0',

`DLBandwidth` smallint(5) NOT NULL default '0',

`ULRatio` smallint(6) NOT NULL default '0',

`DLRatio` smallint(6) NOT NULL default '0',

`comment` tinytext NOT NULL,

`ipaccess` varchar(15) NOT NULL default '*',

`status` enum('0','1') NOT NULL default '0',

`create_date` datetime NOT NULL default '0000-00-00 00:00:00',

`modify_date` datetime NOT NULL default '0000-00-00 00:00:00',

PRIMARY KEY (`id`,`User`),

UNIQUE KEY `User` (`User`)

) TYPE=MyISAM AUTO_INCREMENT=5 ;

INSERT INTO users VALUES (5, 'test', MD5('test'), '505', '505', '/tmp', 0, 0, 0, 0, 0, 0, '', '*', '1', '2003-06-26 18:04:33', '2003-06-26 18:04:33');

启动pureftpd

/server/pureftp/bin/pure-config.pl /server/pureftp/etc/pure-ftpd.conf

停止pureftpd

kill -INT `cat /var/run/pure-ftpd.pid | sed 1q`

参考文章:《Pure-FTPd + LDAP + MySQL + PGSQL + Virtual-Users + Quota How To》http://www.chinaunix.net/jh/15/102137.html

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有