----本人用过vsftp>proftpd>pureftpd,个人感觉才是prueftpd功能强大、好用!本人在原有的安装基础上加上了自己碰到的问题及解决方法。整理出来大家共享!
软件
pureftpd1.0.21.tar.gz
下载地址:http://www.phpx.com/happy/attachment.php?s=&postid=643701
pureftpd_php_manager.tar.gz
下载地址:http://www.phpx.com/happy/attachment.php?s=&postid=643704
tar zvxf pureftpd1.0.21.tar.gz
cd pureftpd1.0.21
#./configure prefix=/usr/local/pureftpd withmysql=/usr/local/mysql withparanoidmsg withshadow withwelcomemsg withuploadscript withquotas withcookie withpam withvirtualhosts withvirtualroot withdiraliases withsysquotas withratios withftpwho withthrottling withlanguage=simplifiedchinese
make
make check
make install
cd configurationfile
chmod u+x pureconfig.pl
cp pureconfig.pl /usr/local/sbin/
cp pureftpd.conf /usr/local/etc/
vi /usr/local/etc/pureftpd.conf
按你的需要编辑pureftpd.conf
# Cage in every user in his home directory
# 限制每个用户到自己的根目录
ChrootEveryone yes
# Disallow anonymous connections. Only allow authenticated users.
# 取消anonymous用户
NoAnonymous yes
# MySQL configuration file (see README.MySQL)
# pureftpdmysql.conf文件的位置
MySQLConfigFile /usr/local/etc/pureftpdmysql.conf
#自己创建用户目录
CreateHomeDir yes
tar zvxf pureftpd_php_manager.tar.gz
cd pureftpd_php_manager
mv pureftpdmysql.conf.sample /usr/local/etc/pureftpdmysql.conf
cd ..
cp R pureftpd_php_manager /home/www/pureftpd_php_manager
cd /home/www/pureftpd_php_manager
vi pureftp.config.php
按照你的需要修改里面的设置代码:
// 设置pureftpdmysql.conf的位置,这个要注意,不要写错哦
$PUREFTP_CONFIG_FILE = ''/usr/local/etc/pureftpdmysql.conf'';
// The location where all the Forms directed to. (Mayby no change needed)
$SELF_URL = ''index.php'';
// The location of your pureftpdwho binary (set this to chmod 4711)
$FTP_WHO = "/usr/local/sbin/pureftpwho";
$DefaultUser = "ftpuser"; # 默认用户
$DefaultPass = ""; # 默认初始用户密码
$DefaultUid = "2002"; # 默认的uid(设置为ftpusers的uid)
$DefaultGid = "2002"; # 默认的gid(设置为ftpusers的gid)
$DefaultDir = "/var/ftproot/ftpusershome"; # 默认的用户主目录
$DefaultUL = "0"; # 默认用户上传速率限制(KB/S)
$DefaultDL = "0"; # 默认用户下载速率限制(KB/S)
$Defaultip = "*"; # 设置用户可以从哪些IP登陆
$DefaultQS = "50"; # 用户默认的quota
$Defaultcmt = ""; # 默认备注信息
$DefaultQF = "0"; # 默认文件数目quota
$PWC = "55"; # Vorsatz fuerr Crypt Password
增加用户组及用户
#groupadd ftpusers g 2002
#useradd ftp u 2002 g ftpusers s /sbin/nologin
删除多余的东西
rm f history.txt pureftpdmysql.conf.sample
如果要投入真实的使用,最好用apache做身份验证!
在mysql中添加FTP用户数据库
代码:
CREATE TABLE ftpd (
User varchar(16) NOT NULL default '''',
status enum(''0'',''1'') NOT NULL default ''0'',
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 '''',
ULBandwidth smallint(5) NOT NULL default ''0'',
DLBandwidth smallint(5) NOT NULL default ''0'',
comment tinytext NOT NULL,
ipaccess varchar(15) NOT NULL default ''*'',
QuotaSize smallint(5) NOT NULL default ''0'',
QuotaFiles int(11) NOT NULL default 0,
PRIMARY KEY (User),
UNIQUE KEY User (User)
) TYPE=MyISAM;
加密pureftpd_php_manager目录
因为我们是放到网上执行的�o所以你肯定不想每个人都跑去看你FTP用户吧�u
我一般采用HTPASSWD验证�o具体请这样子做�o仍用我前面的例子�s
我的pureftpd_php_manager目录位于 /home/onlinecq.com/pureftpd_php_manager目录�o我需要在apache的虚
拟主机那一小节添加如下内容�s
<Directory "/home/www/pureftpd_php_manager">
deny from all
Options None
AllowOverride AuthConfig
Order deny,allow
</Directory>
这样�o若有人想进入该目录�o必须通过apache验证�o保证我们的安全(不是绝对安全)
cd /home/www/pureftpd_php_manager
再进入pureftpd_php_manager的目录�o使用vi建立一个.htaccess的认证文件�s
vi .htaccess
内容如下�s
AuthType Basic
AuthUserFile /usr/www/bin/pureftpd.passwd
AuthName pureftpd
require validuser
satisfy any
存盘退出后�o我们就可以使用htpasswd命令添加允许进入的该目录的用户了�u
cd /usr/www/bin/
进入该目录
./htpasswd bc pureftpd.passwd ftp 123456
这样将会在你的当前目录�o创建一个pureftpd.passwd的身份验证文件�o用户名是ftp�o密码是123654�o你可以
改为你自己需要。
好了�o看起来差不多了�o麻烦你重新启动一下APACHE测试一下�o如果一下顺利�o那祝贺你�o一切成功了�u
编辑/usr/local/etc/pureftpdmysql.conf
vi /usr/local/etc/pureftpdmysql.conf
将刚才在mysql中新建的用户和密码加入其中,选项很简单,只要注意不要输错
MYSQLServer 127.0.0.1
#MYSQL服务器的IP
MYSQLPort 3306
#MYSQL 端口号
MYSQLSocket /var/lib/mysql/mysql.sock
#使用UNIX.sock本地连接
注:MYSQLServer 与 MYSQLSocket 选择一种即可
MYSQLUser ftp
#MYSQLUser 数据用户名
MYSQLPassword 123456
#MYSQL数据库用户的密码
MYSQLDatabase ftpusers
#FTP数据数据库
MYSQLCrypt md5
#密码加密方式"cleartext", "crypt", "md5" and "password"
# cleartext 明文,crypt,md5,password是Backend password(‘yourpasswd’)函数(MYSQL数据库所使用的
password()函数)
MYSQLGetPW SELECT Password FROM users WHERE User="L"
# 密码字段,我使用users表中的Password做为密码字段
MYSQLGetUID SELECT Uid FROM users WHERE User="L"
#UID用户ID字段
MYSQLDefaultUID 1000
#默认的UID (注:如何开启该选项,MYSQLGetUID将失去作用)
MYSQLGetGID SELECT Gid FROM users WHERE User="L"
#GID组ID字段
MYSQLDefaultGID 1000
#默认的GID (注:如何开启该选项,MYSQLGetGID将失去作用)
MYSQLGetDir SELECT Dir FROM users WHERE User="L"
#FTP用户目录如/home/web/www9812net
MySQLGetQTAFS SELECT QuotaFiles FROM users WHERE User="L"
#磁盘限额,文件数限制。如1000,允许用户上传1千个文件
MySQLGetQTASZ SELECT QuotaSize FROM users WHERE User="L"
#磁盘限额,FTP用户空间限制(单位为M),如:100M
MySQLGetRatioUL SELECT ULRatio FROM users WHERE User="L"
MySQLGetRatioDL SELECT DLRatio FROM users WHERE User="L"
#上传/下载比率。MySQLGetRatioUL为上传比,MySQLGetRatioDL下载比。如:1:5
MySQLGetBandwidthUL SELECT ULBandwidth FROM users WHERE User="L"
MySQLGetBandwidthDL SELECT DLBandwidth FROM users WHERE User="L"
#下传/下载带宽(单位KB/s)。MySQLGetBandwidthUL上传带宽,MySQLGetBandwidthDL下载带宽。如上传
500KB/s,下载50KB/s
MySQLForceTildeExpansion 1
MySQLTransactions On
启动
#/usr/local/sbin/pureconfig.pl /usr/local/etc/pureftpd.conf
然后测试<a href="http://ip/pureftpd_php_manager/index.php" target="_blank">http://ip/pureftpd_php_manager/index.php</a>
添加一个用户,然后用FTP客户端登陆试试,ok!
自动启动(1)
pureftp支持多种启动方式,俺采用了最容易的一种:
vi /etc/rc.d/rc.local
添加
cd /usr/local/pureftpd/sbin
./pureftpd A B C 1 c 50 E G I 2 l unix l puredb:/usr/local/pureftpd/pureftpd.pdb p
40000:50000 R w
启动脚本(2)这种好用
在/usr/local/etc/rc.d中建一个pureftpd.sh
chmod u+x pureftpd.sh
就可以:/usr/local/etc/rc.d/pureftpd.sh start
/usr/local/etc/rc.d/pureftpd.sh stop
#!/bin/sh
case "$1" in
start)
[ x /usr/local/etc/pureftpd.conf ] &&
/usr/local/sbin/pureconfig.pl /usr/local/etc/pureftpd.conf > /dev/null &&
echo n '' pureftp''
;;
stop)
killall pureftpd > /dev/null &&
echo n '' pureftp''
;;
*)
echo "Usage: `basename $0` {start | stop}" >&2
;;
esac
exit 0