from: http://bbs.bsdbase.com/index.php?s=&act=ST&f=1&t=224&st=0&#entry307
代码:
################## pure-ftpd ###########################
Aborigen Yin
2003.06.07
pure-ftpd + mysql + PureFTP PHP User Management 安装配置实例
freeBSD 4.8 stable
#mysql apache请自行安装。
#文档中的一些路径是我的环境中使用的,请自行修改以符合你的实际情况;
#相关网址:
http://www.pureftpd.org (国内可能无法访问)
http://sourceforge.net
/projects/pureftpd/ (国内现在可以访问了)
8.1.安装
cd /usr/local/src/distfiles
##172.16.100.245是我的文件服务器
wget ftp://172.16.100.245/pub/distfiles/pure-ftpd-1.0.14.tar.gz
tar xfz pure-ftpd-1.0.14.tar.gz -C ..
cd ../pure-ftpd-1.0.14
mkdir -p /usr/local/modules/support/pure-ftpd/etc
mkdir -p /usr/local/modules/support/pure-ftpd/var/run
mkdir -p /usr/local/modules/support/pure-ftpd/var/log
#用puredb;
#使用英文,WITH_LANG=simplified-chinese可以使用简体中文,不过在某些情况下,你可能更希望看到英文;
./configure --prefix=/usr/local/modules/support/pure-ftpd \
--with-everything \
--with-diraliases \
--with-paranoidmsg \
--with-virtualchroot \
--without-shadow \
--with-welcomemsg \
--with-quotas \
--with-sysquotas \
--without-inetd \
--without-banner \
--with-uploadscript \
--with-mysql=/usr/local/modules/support/mysql
#安装程序好象“忘记”这两个文件了
cp configuration-file/pure-ftpd.conf /usr/local/modules/support/pure-ftpd/etc
cp configuration-file/pure-config.pl /usr/local/modules/support/pure-ftpd/sbin
chmod 755 /usr/local/modules/support/pure-ftpd/sbin/pure-config.pl
8.2.配置主配置文件
#程序在/usr/local/modules/support/pure-ftpd/sbin/pure-ftpd,配置文件在/usr/local/modules/support/pure-ftpd/etc/pure-ftpd.conf
#注意一下参数,配置文件中默认的文件位置不对(其实放哪里看自己喜欢罢了);
#vi /usr/local/modules/support/pure-ftpd/etc/pure-ftpd.conf
#begin of pure-ftpd.conf
############################################################
# #
# Configuration file for pure-ftpd wrappers #
# #
############################################################
ChrootEveryone yes
BrokenClientsCompatibility yes
MaxClientsNumber 150
Daemonize yes
MaxClientsPerIP 20
VerboseLog no
DisplayDotFiles no
AnonymousOnly no
NoAnonymous no
SyslogFacility ftp
DontResolve yes
MaxIdleTime 5
MySQLConfigFile /usr/local/modules/support/pure-ftpd/etc/pureftpd-mysql.conf
#PureDB /usr/local/modules/support/pure-ftpd/etc/pureftpd.pdb
LimitRecursion 2000 8
AnonymousCanCreateDirs no
MaxLoad 4
PassivePortRange 40000 50000
#ForcePassiveIP 192.168.0.1
AntiWarez yes
# Bind 127.0.0.1,21
#AnonymousBandwidth 50
# UserBandwidth 8
Umask 133:022
#MinUID 100
MinUID 100
AllowUserFXP yes
AllowAnonymousFXP no
ProhibitDotFilesWrite no
ProhibitDotFilesRead no
AutoRename no
AnonymousCantUpload yes
#NoChmod yes
#Quota 1000:10
PIDFile /usr/local/modules/support/pure-ftpd/var/run/pure-ftpd.pid
AltLog w3c:/usr/local/modules/support/pure-ftpd/var/log/pure-ftpd-w3c.log
MaxDiskUsage 95
CustomerProof yes
#end of pure-ftpd.conf
###日志设置
###没有这一行,ftp日志就会发到/var/log/messages,很讨厌的说。
echo "ftp.* /usr/local/modules/support/pure-ftpd/var/log/pure-ftpd.log" >> /etc/syslog.conf
###
touch /usr/local/modules/support/pure-ftpd/var/log/pure-ftpd-w3c.log
touch /usr/local/modules/support/pure-ftpd/var/log/pure-ftpd.log
#使日志设置生效;
killall -HUP syslogd
#####
#用phpMyAdmin 创建用户配置 ###
user:pureftpd@localhost
passwd:wahaha
database:pureftpd
################为了使用 PureFTPD PHP User Management #####
###mysql 的设置是按照PureFTPD PHP User Management的readme作的。
##
################
http://www.solariz.de
http://www.solariz.de/Ffiledb/filedb.php?action=category&id=1
http://www.solariz.de/Ffiledb/download.php?id=1
#mysql 配置文件。
#vi /usr/local/modules/support/pure-ftpd/etc/pureftpd-mysql.conf
#
# If you want to use the Socket connect methode comment out the
# Lines with MMYSQLServer and MYSQLPort.
# If you want to use the Port methode comment out the MYSQLSocket line
#MYSQLSocket /var/lib/mysql/mysql.sock
MYSQLServer localhost
MYSQLPort 3306
MYSQLUser pureftpd
MYSQLPassword wahaha
MYSQLDatabase pureftpd
MYSQLCrypt cleartext
MYSQLGetPW SELECT Password FROM ftpd WHERE User="\L" AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R")
MYSQLGetUID SELECT Uid FROM ftpd WHERE User="\L" AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R")
MYSQLGetGID SELECT Gid FROM ftpd WHERE User="\L"AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R")
MYSQLGetDir SELECT Dir FROM ftpd WHERE User="\L"AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R")
MySQLGetBandwidthUL SELECT ULBandwidth FROM ftpd WHERE User="\L"AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R")
MySQLGetBandwidthDL SELECT DLBandwidth FROM ftpd WHERE User="\L"AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R")
MySQLGetQTASZ SELECT QuotaSize FROM ftpd WHERE User="\L"AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R")
MySQLGetQTAFS SELECT QuotaFiles FROM ftpd WHERE User="\L"AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R")
#end of mysql configure.
#####数据库初始化 ####用phpmyadmin 执行
use pureftpd;
DROP TABLE IF EXISTS ftpd;
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;
####
####
8.5.虚拟用户管理
#为匿名用户设置帐户,必须有一个系统帐户ftp,匿名ftp才会生效;
#ftp用户的主目录就是匿名ftp的根;
#匿名ftp是为ftp://ftp.anti-spamming.com这个匿名服务器服务的;
userdel ftp
groupdel ftp
groupadd ftp
useradd -g ftp ftp
#虚拟用户统一用这个帐号和组;
pw groupadd virtual
mkdir -p /data/home/virtual
pw useradd virtual -g virtual -d /data/home/virtual -s /sbin/nologin
chown -R virtual:virtual /data/home/virtual
#为了方便管理,clone一个可以登陆的virtual帐号:
#vipw
virtual:x:503:503::/data/home/virtual:/sbin/nologin
vvuser:x:503:503::/data/home/virtual:/bin/sh
#end
#end
修改密码
passwd vvuser
################为了使用 PureFTPD PHP User Management #####
###mysql 的设置是按照PureFTPD PHP User Management的readme作的。
http://www.solariz.de
http://www.solariz.de/Ffiledb/filedb.php?action=category&id=1
http://www.solariz.de/Ffiledb/download.php?id=1
###
cd /usr/local/modules/support/apache/htdocs
fetch ftp://172.16.100.245/pub/distfiles/pureftpd_php_manager.tgz
tar xfz pureftpd_php_manager.tgz
rm -f pureftpd_php_manager.tgz
cd pureftpd_php_manager
#vi pureftp.config.php
<?php
######################
####### SETUP ########
######################
// Your exactly located mysql config file for pureftpd
//$PUREFTP_CONFIG_FILE = '/etc/pureftpd-mysql.conf';
$PUREFTP_CONFIG_FILE = '/usr/local/modules/support/pure-ftpd/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";
$FTP_WHO = "/usr/local/modules/support/pure-ftpd/sbin";
#######################
# DEFAULT NEW-USER PARAMS #
#######################
$DefaultUser = ""; # Default User Logon
$DefaultPass = ""; # Default User Password
$DefaultUid = "virtual"; # Default User ID ( must be a real user acct )
$DefaultGid = "virtual"; # Default Group