我的proftpd+mysql+quota @ debian 安装流水笔记
发表于:2007-07-04来源:作者:点击数:
标签:
一。准备工做 1。你的机器上已调试好了apache+ php + mysql 环境 2。下载PROFTPD wget ftp://ftp.proftpd.org/distrib/source/proftpd-1.2.10rc3.tar.bz2 因为发现1.2.10直接支持sql和quota 二。安装 tar-jxvfproftpd-1.2.10rc3.tar.bz2 cdproftpd* [quote:0
一。准备工做
1。你的机器上已调试好了apache+
php+
mysql环境
2。下载PROFTPD
wget
ftp://ftp.proftpd.org/distrib/source/proftpd-1.2.10rc3.tar.bz2因为发现1.2.10直接支持sql和quota
二。安装
tar -jxvf proftpd-1.2.10rc3.tar.bz2
cd proftpd*
[quote:06f83d2b02]
./configure --prefix=/usr/local/proftpd \ --with-modules=mod_sql:mod_sql_mysql:mod_quotatab:mod_quotatab_sql \ --with-includes=/usr/local/mysql/include/mysql \ --with-libraries=/usr/local/mysql/lib/mysql
make&&make install
修改proftpd配置
vim /usr/local/proftpd/etc/proftpd.conf
内容改为:
ServerName "mail2004.3322.org"
ServerType standalone
DefaultServer on
# 用户登陆时不显示ftp
服务器版本信息
ServerIdent off
# Port 21 is the standard FTP port.
Port 21
# Umask 022 is a good standard umask to prevent new dirs and files
# from being group and world writable.
Umask 022
MaxLoginAttempts 3
TimeoutLogin 120
TimeoutIdle 600
TimeoutNoTransfer 900
TimeoutStalled 3600
MaxClients 100
# 设置每台主机最多并发连接数
MaxClientsPerHost 3
AllowOverwrite no
AllowStoreRestart on
UseReverseDNS off
# 设置如果shell为空时允许用户登录
RequireValidShell off
# 将用户限制在自己的主目录下
DefaultRoot ~
# 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
.netd 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 under which the server will run.
User nobody
Group nobody
# Normally, we w
ant files to be overwriteable.
<Directory />
AllowOverwrite on
</Directory>
# A basic anonymous configuration, no upload directories.
# 匿名登录设置。匿名用户目录为/ftp
<Anonymous /ftp>
User ftp
Group ftp
# We want clients to be able to login with "anonymous" as well as "ftp"
# UserAlias anonymous ftp 停了它
# Limit the maximum number of anonymous logins
MaxClients 10
# We want 'welcome.msg' displayed at login, and '.message' displayed
# in each newly chdired directory.
DisplayLogin welcome.msg
DisplayFirstChdir .message
# Limit WRITE everywhere in the anonymous chroot
#<Limit WRITE>
# DenyAll
#</Limit>
</Anonymous>
以上是PROFTPD.conf
下面加入sql和quota
#
数据库联接的信息,proftpdb是数据库名,localhost是主机名,proftpd是连接数据库的用户名,
#proftpdb是密码
#(如果没有密码留空)
SQLConnectInfo proftpdb@localhost proftp proftpdb
# 数据库认证的类型
SQLAuthTypes Backend Plaintext
# 数据库的鉴别
SQLAuthenticate users* groups*
# 指定用来做用户认证的表的有关信息。
SQLUserInfo ftpuser userid passwd uid gid homedir shell
SQLGroupInfo ftpgroup groupname gid members
# 如果home目录不存在,则系统会根据它的home项新建一个目录
SQLHomedirOnDemand on
这是目录所有者,我觉得这个很重要。所以我用nobody来做,在此我的nobody为99.
SQLDefaultGID99
SQLDefaultUID99
SQLLog PASS updatecount
SQLNamedQuery updatecount UPDATE "count=count+1,a
clearcase/" target="_blank" >ccessed=now() WHERE userid='%u'" ftpuser
# Update modified everytime user uploads or deletes a file
SQLLog STOR,DELE modified
SQLNamedQuery modified UPDATE "modified=now() WHERE userid='%u'" ftpuser
# 启用磁盘限额
QuotaDirectoryTally on
# 磁盘限额单位 b"|"Kb"|"Mb"|"Gb"
QuotaDisplayUnits "Kb"
QuotaEngine on
# 磁盘限额日志记录
QuotaLog "/var/log/quota.log"
# 打开磁盘限额信息,当登陆FTP帐户后,使用命令 "quote SITE QUOTA" 后可显示当前用#户的磁盘限额
QuotaShowQuotas on
以下为sql语句:
SQLNamedQuery get-quota-limit SELECT "name, quota_type, per_session, limit_type, bytes_in_avail,bytes_out_ava
il, bytes_xfer_avail, files_in_avail, files_out_avail, files_xfer_avail FROM ftpquotalimits WHERE name = '%{0
}'AND quota_type = '%{1}'"
SQLNamedQuery get-quota-tally SELECT "name, quota_type, bytes_in_used, bytes_out_used, bytes_xfer_used, files
_in_used, files_out_used, files_xfer_used FROM ftpquotatallies WHERE name = '%{0}' AND quota_type = '%{1}'"
SQLNamedQuery update-quota-tally UPDATE "bytes_in_used = bytes_in_used + %{0}, bytes_out_used = bytes_out_used + %{1}, bytes_xfer_used = bytes_xfer_used + %{2}, files_in_used = files_in_used + %{3}, files_out_used = files_out_used + %{4}, files_xfer_used = files_xfer_used + %{5} WHERE name = '%{6}' AND quota_type = '%{7}'" ftpquotatallies
SQLNamedQuery insert-quota-tally INSERT "%{0}, %{1}, %{2}, %{3}, %{4}, %{5}, %{6}, %{7}" ftpquotatallies
QuotaLimitTable sql:/get-quota-limit
QuotaTallyTable sql:/get-quota-tally/update-quota-tally/insert-quota-tally
下面可以用phpmyadmin在mysql里加入,我的sql为以下
CREATE TABLE `ftpgroup` (
`groupname` varchar(16) NOT NULL default '',
`gid` smallint(6) NOT NULL default '99',
`members` varchar(16) NOT NULL default '',
KEY `groupname` (`groupname`)
) TYPE=MyISAM COMMENT='ProFTP group table';
INSERT INTO `ftpgroup` VALUES ('nobody', 99, 'nobody');
CREATE TABLE `ftpquotalimits` (
`name` varchar(30) default NULL,
`quota_type` enum('user','group','class','all') NOT NULL default 'user',
`per_session` enum('false','true') NOT NULL default 'false',
`limit_type` enum('soft','hard') NOT NULL default 'soft',
`bytes_in_avail` float NOT NULL default '0',
`bytes_out_avail` float NOT NULL default '0',
`bytes_xfer_avail` float NOT NULL default '0',
`files_in_avail` int(10) unsigned NOT NULL default '0',
`files_out_avail` int(10) unsigned NOT NULL default '0',
`files_xfer_avail` int(10) unsigned NOT NULL default '0'
) TYPE=MyISAM;
CREATE TABLE `ftpquotatallies` (
`name` varchar(30) NOT NULL default '',
`quota_type` enum('user','group','class','all') NOT NULL default 'user',
`bytes_in_used` float NOT NULL default '0',
`bytes_out_used` float NOT NULL default '0',
`bytes_xfer_used` float NOT NULL default '0',
`files_in_used` int(10) unsigned NOT NULL default '0',
`files_out_used` int(10) unsigned NOT NULL default '0',
`files_xfer_used` int(10) unsigned NOT NULL default '0'
) TYPE=MyISAM;
CREATE TABLE `ftpuser` (
`id` int(10) unsigned NOT NULL auto_increment,
`userid` varchar(32) NOT NULL default '',
`passwd` varchar(32) NOT NULL default '',
`uid` smallint(6) NOT NULL default '99',
`gid` smallint(6) NOT NULL default '99',
`homedir` varchar(255) NOT NULL default '',
`shell` varchar(16) NOT NULL default '/sbin/nologin',
`count` int(11) NOT NULL default '0',
`accessed` datetime NOT NULL default '0000-00-00 00:00:00',
`modified` datetime NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (`id`)
) TYPE=MyISAM COMMENT='ProFTP user table' ;
[/quote:06f83d2b02]
启动proftpd
/usr/local/proftpd/sbin/proftpd start
在数据数中的ftpuser中加入用户,密码他路径就可以了。
以上只是一个流水笔记
platinum 回复于:2004-09-02 13:55:32 |
好,我今天 @ AS3 试试看
|
mb 回复于:2004-09-02 14:12:50 |
gid uid 解快了 加上SQLDefaultGIDxx SQLDefaultUIDxx
|
platinum 回复于:2004-09-02 14:15:29 |
晕,还讨论呢,呵呵
我学习学习吧
你把文章再整理一下,我给你加个精华好了
文章里有乱码,部分注释不够详细,建立数据表时失败
|
mb 回复于:2004-09-02 14:26:21 |
好的,谢谢,我再整理一下,konqueror 没汉化好,所以乱码了,mysql就4.13的,4.1以下的不行,我改一下这就整理
|
双眼皮的猪 回复于:2004-09-02 16:45:53 |
我帮你顶一下...
|
platinum 回复于:2004-09-02 17:22:28 |
[quote:5b3bab3471] 以上是PROFTPD.conf
下面加入sql和quota [/quote:5b3bab3471] 下面的东西写到哪里?
|
tianci3982730 回复于:2004-09-02 18:03:12 |
[quote:fe18dbf0ef="platinum"] 下面的东西写到哪里?[/quote:fe18dbf0ef] 也写到PROFTPD.conf 中啊
|
platinum 回复于:2004-09-02 19:14:56 |
刚才实验了一下,设置test/test,可以登录 但是如果设置了QUOTA之后就无法登录了
我设置 QuotaDisplayUnits Mb
name: - 用户帐号 quota type: - user, group, class, all (we use user) per_session: - true or false (we use true) limit_type: - 硬限制 or 软限制 (我们一般用硬限制) bytes_in_avail: - 允许上传的字节数 bytes_out_avail: - 允许下载的字节数 bytes_xfer_avail: - 允许传输的字节数(包括上传/下载) files_in_avail: - 允许上传的文件数 files_out_avail: - 允许下载的文件数 files_xfer_avail: - 允许传输的文件数(包括上传/下载)
也都是照网上资料做的,但是如果做了QUOTA,就无法登录了 不提示 [quote:5221eda8e9] 530 Login incorrect. Login failed. [/quote:5221eda8e9] 而是提示 [quote:5221eda8e9] Connection closed by remote host.
C:\> [/quote:5221eda8e9] 直接退出了
你遇到这样的问题没有
|
Linux@初学者 回复于:2004-09-02 20:52:59 |
是啊,楼主试验了吗?按照好多这样的贴子,都无法连接FTP啊!
|
platinum 回复于:2004-09-02 21:59:38 |
[quote:38bdaa93d6="Linux@初学者"]是啊,楼主试验了吗?按照好多这样的贴子,都无法连接FTP啊![/quote:38bdaa93d6] 是的,好多都不成功,但是楼主这个可以,我也试过了,所以给他加了原创精华 但是,有一个小问题,我不知道该如何解决,在你的楼上那个贴子里
|
Linux@初学者 回复于:2004-09-02 22:04:32 |
是啊,网上有N多这样的问题,加了quota就连不上了。
|
platinum 回复于:2004-09-02 22:18:52 |
原来我照网上其他文章做的,别说加QUOTA了,就是不加QUOTA,服务起都起不来
|
mb 回复于:2004-09-03 11:11:55 |
我的正常呀 [quote:d61353524b] root@wxb:~# ftp 127.0.0.1 Connected to 127.0.0.1. 220 ProFTPD 1.2.10rc3 Server (WinScok5.12) [localhost] Name (127.0.0.1:root): test 331 Password required for test. Password: 230 User test logged in. Remote system type is UNIX. Using binary mode to transfer files. ftp> quote site quota 200-The current quota for this session are [current/limit]: Name: test Quota Type: User Per Session: False Limit Type: Hard Uploaded Mb: 0.00/976.56 Downloaded Mb: 0.00/0.00 Transferred Mb: 0.00/1953.12 Uploaded files: 0/50000 Downloaded files: 0/5000 Transferred files: 0/1000 200 Please contact root@localhost if these entries are inaccurate ftp> bye 221 Goodbye. root@wxb:~# killall proftpd root@wxb:~# /usr/local/proftpd/sbin/proftpd start root@wxb:~# ftp 127.0.0.1 Connected to 127.0.0.1. 220 ProFTPD 1.2.10rc3 Server (WinScok5.12) [localhost] Name (127.0.0.1:root): test 331 Password required for test. Password: 230 User test logged in. Remote system type is UNIX. Using binary mode to transfer files. ftp> quote site quota 200-The current quota for this session are [current/limit]: Name: test Quota Type: User Per Session: False Limit Type: Hard Uploaded Mb: 668.56/976.56 Downloaded Mb: 0.00/0.00 Transferred Mb: 668.56/1953.12 Uploaded files: 3/50000 Downloaded files: 0/5000 Transferred files: 3/1000 200 Please contact root@localhost if these entries are inaccurate ftp> ls 200 PORT command successful 150 Opening ASCII mode data connection for file list -rw-r--r-- 1 test nobody 27655955 Sep 3 03:07 30000.rm -rw-r--r-- 1 test nobody 36384457 Sep 3 03:07 j2sdk-1_4_2_05-linux-i586.bin -rw-r--r-- 1 test nobody 637000704 Sep 3 03:08 ship.db.cpio 226 Transfer complete. ftp> Per Session: False -----,看一下mysql.log吧,认证都是在user表里呢,再看看quota.log,应没有问提的 [/quote:d61353524b]
|
platinum 回复于:2004-09-03 11:30:17 |
我再从头做一遍好了,可能哪里出现问题了
|
zhaoshan 回复于:2004-09-03 12:11:23 |
既然是debian 为什么还要这么麻烦的安装啊? apt-get install proftpd mysql-server
|
platinum 回复于:2004-09-03 12:40:41 |
我查了一下问题,我原来的proftpd.conf用到mysql支持的时候就有问题了,换成楼主的就没问题
具体哪句话影响的还不清楚,我也不想查了,改用楼主的那个conf好了,再稍微改改就符合我的要求了
楼主的贴子果然不错
|
mb 回复于:2004-09-03 12:58:37 |
[quote:fcd278034d="zhaoshan"]既然是debian 为什么还要这么麻烦的安装啊? apt-get install proftpd mysql-server[/quote:fcd278034d] 是呀,不过我还是喜欢用源码,apt-get我只在系统升级时用,呵呵,个人爱好不同吧了
|
platinum 回复于:2004-09-03 13:24:01 |
[quote:756899d75f="mb"]是呀,不过我还是喜欢用源码,apt-get我只在系统升级时用,呵呵,个人爱好不同吧了[/quote:756899d75f] 同意 太智能化反而不习惯,比如FreeBSD里的PORTS
|
platinum 回复于:2004-09-05 00:34:39 |
现在发现一个问题 每个用户建立的目录,上传的文件,属主不是数据库里设定好的 这个问题怎么解决?
|
jeason2008 回复于:2004-09-05 10:38:08 |
[quote:15393d163c="platinum"]现在发现一个问题 每个用户建立的目录,上传的文件,属主不是数据库里设定好的 这个问题怎么解决?[/quote:15393d163c]
删除了文件后,实际QUOTA会减少吗(可用QUOTA会增加吗)?
|
platinum 回复于:2004-09-05 10:46:02 |
会 有4个表
ftpquotalimits 这个是做限制的,里面写上某用户的限制参数
ftpquotatallies 这个是针对上面那个表的,里面反映当前用户所用资源
ftpuser 这个表是用户登记表,帐号就在这里面,同时也有uid和gid,问题就在这里,里面的用户(比如test)他创建的文件,uid和gid都是65533,并非里面规定的uid和gid,加了sqldefaultuid以后,所有用户的uid都是那里面设置好的,也依然不听uid的分配
ftpgroup 这个就三个字段:groupname、gid、members,还不知道怎么用
|
jeason2008 回复于:2004-09-05 11:19:39 |
[quote:391a0f3d6a="platinum"]会 有4个表
ftpquotalimits 这个是做限制的,里面写上某用户的限制参数
ftpquotatallies 这个是针对上面那个表的,里面反映当前用户所用资源
ftpuser 这个表是用户登记表,帐号就在这里面,同时也有uid..........[/quote:391a0f3d6a]
ths,我试试.有问题再提出,望指教.
|
原文转自:http://www.ltesting.net