proftpd+mod_sql+mod_quota安装手记
我使用的操作系统是FreeBSD 4.2,在安装的过程中针对FreeBSD增加了--enable-force-setpassent请根据自己的情况确定。
1、安装前的准备
从http://www.proftpd.org下载proftpd的最新版proftpd-1.2.6,将下载后的软件解开,如果扩展名是
.tar.gz用tar zxf xxx.tar.gz,如果.tar.bz2用命令tar xjf xxx.tar.bz2。
从ftp://pooh.urbanrage.com/pub/c/下载mod_quota.c,放在modules/下(proftpd.1.2.6没有
mod_quota.c)
2、编译安装
根据自己的需要增加选项,我的选项是:
./configure --prefix=/var/proftpd --with-modules=mod_sql:mod_sql_mysql \
--enable-force-setpassent
这个时候您一定疑惑,怎么没有--with-modules=mod_quota呢,我安装的时候尝试了很多的方法都不将两
个模块一起选中,只有这样办了。
vi Make.modules
MODULES=mod_core.o后边加入mod_quota.o
BUILD_MODULES=modules/mod_core.o后边加上modules/mod_quota.o
然后开始编译
make
make install
如果找不到mysql.h或者libmysqlclient.so等,请检查是否安装了mysql-devel或者从完整的mysql代码
编译的,如果不是,请安装mysql-devel或者从
http://www.mysql.com/Downloads/MySQL-3.23/mysql-3.23.52.tar.gz
下载安装最新的mysql-3.23.52
./configure的使用指定头文件的路径和联结库的路径,如--with-includes=/usr/include \
--with-libraries=/usr/lib/mysql
也可以设置环境变量
INCS=-I/usr/local/mysql/include/mysql
export INCS
LIBS="-L/usr/local/mysql/lib/mysql -lmysqlclient -lz"
export LIBS
CPPFLAGS=-I/usr/local/mysql/include/mysql
LDFLAGS=-L/usr/local/mysql/lib/mysql
export CPPFLAGS
export LDFLAGS
将其加入/etc/profile里。
3、建立数据库
#建立数据库proftpd
CREATE DATABASE proftpd;
#建立组表
DROP TABLE IF EXISTS `groups`;
CREATE TABLE `groups` (
`groupname` varchar(255) binary NOT NULL default '',
`gid` int(11) NOT NULL default '0',
`members` text NOT NULL,
PRIMARY KEY (`groupname`)
)TYPE=MyISAM;
#建立用户表
DROP TABLE IF EXISTS `users`;
CREATE TABLE `users` (
`userid` varchar(255) binary NOT NULL default '',
`passwd` varchar(255) binary NOT NULL default '',
`uid` int(11) default NULL,
`gid` int(11) default NULL,
`homedir` varchar(255) default NULL,
`shell` varchar(255) default NULL,
`count` int(11) default NULL,
`used` double(10,1) default '0.0',
`quota` double(10,1) default '10000000.0',
PRIMARY KEY (`userid`)
) TYPE=MyISAM;
#如果表已经存在,不想删除,可以使用以下命令更改表的结构
alter table users add column used double(10,1) default '0.0';
alter table users add column quota double(10,1) default '10000000.0';
4、配置proftpd.conf
在这里我把我的proftpd.conf贴出来,并给以相应的注释,仅供参考
# This is a basic ProFTPD configuration file (rename it to
# 'proftpd.conf' for actual use. It establishes a single server
# and a single anonymous login. It assumes that you have a user/group
# "nobody" and "ftp" for normal operation and anon.
ServerName "FTP.BJSING.NET"
ServerType standalone
DefaultServer on
ServerIdent on "BJSING.NET: ftp.bjsing.net is ready. Please you login."
ServerAdmin xiaojb@868cn.com
Port 2121
# Umask 022 is a good standard umask to prevent new dirs and files
# from being group and world writable.
Umask 002
#允许尝试3次登录
MaxLoginAttempts 3
#关于超时
TimeoutLogin 120
TimeoutIdle 600
TimeoutNoTransfer 900
TimeoutStalled 3600
#限制连接数
MaxClients 10 "最大允许10个用户同时访问"
MaxClientsPerHost 1 "对不起,一台主机只允许一个连接"
#不使用SHELL
RequireValidShell no
#允许断点续传
AllowOverwrite no
AllowStoreRestart on
#不使用反解析
UseReverseDNS off
#磁盘配额限制
Quotas on
QuotaCalc on
QuotaType soft
#默认的配额
DefaultQuota 100000
#这里默认的是一子节为单位,我改成了K
QuotaBlockSize 1024
QuotaBlockName "K bytes"
MultilineRFC2228 on
SystemLog /var/proftpd/log/proftpd.log
#MySQL的信息写入了另一个文件中
Include /var/vmysql.conf
#连接时的MSG
DisplayConnect /var/proftpd/etc/connect.msg
DisplayGoAway /var/proftpd/etc/goway.msg
#输入quit命令后的MSG
DisplayQuit /var/proftpd/etc/quit.msg
#Disable Ident protecol(RFC 1413)
IdentLookups off
#configation手册中说这是一种安全的上传模式
HiddenStor on
DisplayLogin welcome.msg
DisplayFirstChdir .message
AllowOverwrite yes
# To prevent DoS attacks, set the maximum number of child processes
# to 30. If you need to allow more than 30 concurrent connections
# at once, simply increase this value. Note that this ONLY works
# in standalone mode, in inetd mode you should use an inetd server
# that allows you to limit maximum number of processes per service
# (such as xinetd)
MaxInstances 30
# Set the user and group that the server normally runs at.
User nobody
Group nogroup
PathDenyFilter "(\.ftpaccess)|(\.htaccess)$"
# Normally, we want files to be overwriteable.
<Directory /*>
AllowOverwrite on
</Directory>
#删除了anonymous登录的设置
vmysql.conf的内容
#mod_sql的设置
###############DATABASE@SERVER:PORT MySQL-User passwd
SQLConnectInfo proftpd@localhost root xxxxxx
SQLAuthenticate users*
#密码未加密
SQLAuthTypes Plaintext
#用户表信息
############表名 user字段名 pass uid gid 用户目录 SHELL
SQLUserInfo users userid passwd uid gid homedir shell
#组表信息
#############表名 组名字段 组值字段 成员字段
SQLGroupInfo groups groupname gid members
####用户登录后,将用户的登录次数+1
SQLLog PASS updatecount
SQLNamedQuery updatecount UPDATE "count=count+1 WHERE userid='%u'" users
#####用户登录后,显示已经登录过的次数(特别说明,已经登录过的次数,不算当前的连接
SQLNamedQuery count SELECT "count FROM users WHERE userid='%u'"
SQLShowInfo PASS "230" "You've logged on %{count} times, %u"
###如果用户目录不存在,自动创建目录
SQLHomedirOnDemand on
#mod_quota的相关设置
#Quota信息的表名
SQLQuotaTable users
#MySQL的连接参数#Server User Password 数据库
SQLQuotaInfo localhost root xxxxxxx proftpd
#保存用户名的字段名
SQLQuotaName userid
#保存用户已经使用空间的