安装Pure-FTPD

| |
[不指定 2005/01/31 23:15 | by ipaddr ]
对比了几个FTP服务器,发现还是Pure-ftpd好用,Proftpd空间配额都要打补丁,麻烦.

1.Download
http://www.pureftpd.org
不知国内的电信是干嘛的,Pure-ftpd,Proftpd都被封了,这些人真是无聊.
可以通过代理上这两个网站,随便找一个国外的代理服务器,设置好IE的连接就可以上了.



2.编译安装
#tar zxvf purexxxx.tgz
#cd purxxxxx
#./configure \
--prefix=/usr/local/pureftpd \
--with-mysql \
--with-paranoidmsg \
--with-welcomemsg \
--with-uploadscript \
--with-cookie \
--with-virtualchroot \
--with-virtualhosts \
--with-virtualroot \
--with-diraliases \
--with-quotas \
--with-sysquotas \
--with-ratios \
--with-ftpwho \
--with-throttling \
--with-language=simplified-chinese
这时,我们只用Mysql用户认证,不用LDAP,也不用其这的.
#make
#make check
#make install

3.测试
#/usr/local/pureftpd/sbin/pure-ftpd &
运行后,用FTP登录一下看,此时是系统用户认证.登录成功,表示Pure-FTPD安装好了

4.与Mysql结合
由于编译时带了--with-mysql选项,所以,无需修改Pure-FTPD.
A.
先在Mysql中建一个FTP用户表(和数据库):

CREATE TABLE tblUser (
 UserID int(11) unsigned NOT NULL auto_increment,
 UserName varchar(50) NOT NULL default '',
 UserPasswd varchar(50) binary NOT NULL default '',
 UserUID int(11) NOT NULL default '14',
 UserGID int(11) NOT NULL default '5',
 UserDir varchar(250) NOT NULL default '',
 UserQF int(10) NOT NULL default '500',
 UserQS int(10) NOT NULL default '30',
 UserStatus tinyint(1) unsigned NOT NULL default '1',
 PRIMARY KEY  (UserID),
 UNIQUE KEY User (UserName)
) TYPE=MyISAM AUTO_INCREMENT=1 ;

说明
 UserID 用户ID
 UserName 用户名
 UserPasswd 用户密码,用MD5加密
 UserUID 用户对应的系统ID,请注意,默认情况下,低于100的UID不可以登录
 UserGID 用户对应的系统组ID
 UserDir 用户主目录
 UserQF 用户最大文件数
 UserQS 用户最大空间M
 UserStatus 用户状态,为1时可以使用(用SQL语句实现,见后面的Mysql.conf)

b.配置Pure-FTPD
我们用Pure-FPTD自带的启动脚本启动.
进入Pure-fptd的源代码目录
[root@linux pure-ftpd-1.0.15]# cd configuration-file
[root@linux configuration-file]# chmod u+x pure-config.pl
[root@linux configuration-file]# cp pure-config.pl /usr/local/pureftpd/bin
[root@linux configuration-file]# mkdir /usr/local/pureftpd/etc
[root@linux configuration-file]# cp pure-ftpd.conf /usr/local/pureftpd/etc
[root@linux configuration-file]# cd ..
[root@linux pure-ftpd-1.0.15]# cp pureftpd-mysql.conf /usr/local/pureftpd/etc/mysql.conf
[root@linux pure-ftpd-1.0.15]# cd /usr/local/pureftpd/etc
[root@linux etc]#vi pure-ftpd.conf
   修改pure-ftpd.conf的配置,详细配置见后面
[root@linux etc]#vi mysql.conf
   修改Mysql连接的配置,详细配置见后面

c.启动:
#/usr/local/pureftpd/bin/pure-config.pl /usr/local/pureftpd/etc/pure-ftpd.conf

d.测试

#groupadd ftpuser
#useradd -g ftpuser -s /sbin/nologin -d /ftp/ ftpwrite
#useradd -g ftpuser -s /sbin/nologin -d /ftp/ ftpread
#mkdir /ftp
#mkdir /ftp/ipaddr
#chown ftpwrite.ftpuser /ftp/ipaddr
加入两个FTP系统用户,假设ftpuser的GID为500,ftpwrite的UID为500,ftpread的UID为501
加入一个Mysql用户:
 UserID=100
 UserName=ipaddr
 UserPasswd=md5(ipaddr)
 UserUID=500 (501时,用户只读)
 UserGID=500
 UserDir=/ftp/ipaddr
 UserQF=500
 UserQS=30
 UserStatus=1
重启PureFTPD,再用FTP客户端测试
#killall pure-ftpd
#/usr/local/pureftpd/bin/pure-config.pl /usr/local/pureftpd/etc/pure-ftpd.conf

e.自启动.
可以将启动脚本写入/etc/rc.d/rc.local里,自启动,但不太方便,
可以写一个脚本,如下:


#!/bin/sh
# Startup script for the FTP Server
#
# chkconfig: - 99 99
# description: FTP Serve

case "$1" in
start)
 /usr/local/pureftpd/bin/pure-config.pl /usr/local/pureftpd/etc/pure-ftpd.conf
 ;;
stop)
 killall pure-ftpd > /dev/null
 ;;

*)
 echo "Usage: `basename $0` {start | stop}" >&2
 ;;
esac
exit 0



:w /etc/init.d/pureftpd (保存到/etc/init.d/pureftpd)
#chkconfig --add pureftpd
#chkconfig pureftpd on
f.用户管理
用PHP写一个程序管理Mysql表就行了.



附录:
A.mysql.conf

MYSQLSocket     /var/lib/mysql/mysql.sock
MYSQLUser       sqluser
MYSQLPassword   password
MYSQLDatabase   kk
MYSQLCrypt      md5
MYSQLGetPW      SELECT UserPasswd FROM tblUser WHERE UserStatus=1 and UserName="\L"
MYSQLGetUID     SELECT UserUID FROM tblUser WHERE UserStatus=1 and UserName="\L"
MYSQLGetGID     SELECT UserGID FROM tblUser WHERE UserStatus=1 and UserName="\L"
MYSQLGetDir     SELECT UserDir FROM tblUser WHERE UserStatus=1 and UserName="\L"MySQLGetQTAFS  SELECT UserQF FROM tblUser WHERE UserStatus=1 and UserName="\L"
MySQLGetQTAFS  SELECT UserQF FROM tblUser WHERE UserStatus=1 and UserName="\L"
MySQLGetQTASZ  SELECT UserQS FROM tblUser WHERE UserStatus=1 and UserName="\L"

B.pure-ftpd.conf

.....
MySQLConfigFile               /usr/local/pureftpd/etc/mysql.conf
#把这个打开就行了,其它的用默认
.....

C.定制PURE-FTPD的Banner

vi src/ftpd.c

4329 # ifdef BORING_MODE
4330     addreply_noformat(0, MSG_WELCOME_TO " Pure-FTPd.");
4331 # else
4332     addreply_noformat(0, "--------- " MSG_WELCOME_TO
4333                       " Pure-FTPd" VERSION_PRIVSEP VERSION_TLS " ----------");
4334 # endif
将Pure-FPD改为自定义的名称,比如:IPADDR-FTPD
Net | 评论(0) | 引用(0) | 阅读(5122)