pureftpd安装文档

PHP代码:
  
    

--------------------------------------pureftpd安装文档-----------------------------------
需要的软件
pure
-ftpd-1.0.21.tar.gz
pureftpd_php_manager
.tar.gz

全面设置
tar zvxf pure
-ftpd-1.0.21.tar.gz
cd pure
-ftpd-1.0.21
#./configure --prefix=/usr/local/pureftpd --with-mysql=/usr/local/mysql --with-paranoidmsg

--with-shadow --with-welcomemsg --with-uploadscript --with-quotas --with-cookie --with-pam

--with-virtualhosts --with-virtualroot --with-diraliases --with-sysquotas --with-ratios

--with-ftpwho --with-throttling --with-language=simplified-chinese


make
make check
make install
cd configuration
-file
chmod u
+x pure-config.pl
cp pure
-config.pl /usr/local/sbin/
cp pure-ftpd.conf /usr/local/etc/
vi /usr/local/etc/pure-ftpd.conf
按你的需要编辑pure
-ftpd.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)
# pureftpd-mysql.conf文件的位置
MySQLConfigFile               /usr/local/etc/pureftpd-mysql.conf
CreateHomeDir               yes
-------------------------------------

tar zvxf pureftpd_php_manager.tar.gz
cd pureftpd_php_manager
mv pureftpd
-mysql.conf.sample /usr/local/etc/pureftpd-mysql.conf
cd
..
cp -R pureftpd_php_manager /home/www/pureftpd_php_manager
cd
/home/www/pureftpd_php_manager
vi pureftp
.config.php

按照你的需要修改里面的设置代码
:

-------------------------------------------------------------------------------------

        
// 设置pureftpd-mysql.conf的位置,这个要注意,不要写错哦
        
$PUREFTP_CONFIG_FILE    = '/usr/local/etc/pureftpd-mysql.conf';

        
// The location where all the Forms directed to. (Mayby no change needed)
        
$SELF_URL                               = 'index.php';

        
// The location of your pure-ftpdwho binary  (set this to chmod 4711)
        
$FTP_WHO                                = "/usr/local/sbin/pure-ftpwho";


   
$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 pureftpd-mysql.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目录-----------------------------

因为我们是放到网上执行的﹐所以你肯定不想每个人都跑去看你FTP用户吧﹗
我一般采用HTPASSWD验证﹐具体请这样子做﹐仍用我前面的例子﹕
我的pureftpd_php_manager目录位于
/home/onlinecq.com/pureftpd_php_manager目录﹐我需要在apache的虚

拟主机那一小节添加如下内容﹕

<Directory "/home/www/pureftpd_php_manager">
    
deny from all
    Options None
    AllowOverride AuthConfig
    Order deny
,allow
</Directory>

这样﹐若有人想进入该目录﹐必须通过apache验证﹐保证我们的安全(不是绝对安全)
cd
/home/www/pureftpd_php_manager
再进入pureftpd_php_manager的目录﹐使用vi建立一个
.htaccess的认证文件﹕
vi
.htaccess
内容如下﹕
AuthType Basic
AuthUserFile
/usr/www/bin/pureftpd.passwd
AuthName pureftpd
require valid-user
satisfy any
存盘退出后﹐我们就可以使用htpasswd命令添加允许进入的该目录的用户了﹗
cd
/usr/www/bin/
进入该目录
./htpasswd -bc pureftpd.passwd ltsnet 980405
这样将会在你的当前目录﹐创建一个pureftpd
.passwd的身份验证文件﹐用户名是ftp﹐密码是123654﹐你可以

改为你自己需要。
好了﹐看起来差不多了﹐麻烦你重新启动一下APACHE测试一下﹐如果一下顺利﹐那祝贺你﹐一切成功了﹗


------------------编辑/usr/local/etc/pureftpd-mysql.conf --------------------------
vi /usr/local/etc/pureftpd-mysql.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(‘your-passwd’)函数(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/www-9812-net
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/pure-config.pl /usr/local/etc/pure-ftpd.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
  
./pure-ftpd -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/pure-ftpd.conf ] &&  
/
usr/local/sbin/pure-config.pl /usr/local/etc/pure-ftpd.conf > /dev/null &&
echo -
n ' pure-ftp'
;;

stop)
killall pure-ftpd > /dev/null &&
echo -
n ' pure-ftp'
;;

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


附件: pure-ftpd.rar 管理FTP的PHP程序

你可能感兴趣的:(ftp)