分享
 
 
 

ProFTPD + MySQL + mod_quota 安装

王朝mysql·作者佚名  2006-12-16
窄屏简体版  字體: |||超大  

前言:

本文的描述平台为Red Hat Linux/x86 8.0 (Psyche),适用于Red Hat Linux/x86 9.0 (Shrike)。

一、软件获取(本文以proftpd-1.2.7、mod_quota-1.28和MySQL-3.23.56为例)

1. ProFTPD

proftpd-1.2.7.tar.gz

proftpd-1.2.7-1.i386.rpm

proftpd-standalone-1.2.7-1.i386.rpm

下载: http://www.mysql.com/

二、安装ProFTPD

1. 卸载wu-ftpd

rpm -e anonftp

rpm -e wu-ftpd

2. 安装ProFTPD

rpm -ivh proftpd-1.2.7-1.i386.rpm

rpm -ivh proftpd-standalone-1.2.7-1.i386.rpm

3. 编译ProFTPD

tar -zxvf proftpd-1.2.7.tar.gz

cp mod_quota.c_for_1.2.7 ./proftpd-1.2.7/contrib/mod_quota.c

vi ./proftpd-1.2.7/contrib/mod_quota.c

# 将其中的“/* #define QUOTA_MYSQL *' target="_blank">http://www.proftpd.org

proftpd.conf 配置详情:http://www.proftpd.org/docs/configuration.html

2. mod_quota v1.28

mod_quota.c_for_1.2.7

下载: ftp://pooh.urbanrage.com/pub/c/

3. MySQL

MySQL-3.23.56-1.i386.rpm

MySQL-client-3.23.56-1.i386.rpm

MySQL-devel-3.23.56-1.i386.rpm

MySQL-shared-3.23.56-1.i386.rpm

下载: http://www.mysql.com/

二、安装ProFTPD

1. 卸载wu-ftpd

rpm -e anonftp

rpm -e wu-ftpd

2. 安装ProFTPD

rpm -ivh proftpd-1.2.7-1.i386.rpm

rpm -ivh proftpd-standalone-1.2.7-1.i386.rpm

3. 编译ProFTPD

tar -zxvf proftpd-1.2.7.tar.gz

cp mod_quota.c_for_1.2.7 ./proftpd-1.2.7/contrib/mod_quota.c

vi ./proftpd-1.2.7/contrib/mod_quota.c

# 将其中的“/* #define QUOTA_MYSQL */ ”改为“#define QUOTA_MYSQL”

cd ../proftpd-1.2.7

./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var/run --mandir=/usr/man --with-libraries=/usr/lib/mysql --with-includes=/usr/include/mysql --with-modules=mod_sql:mod_sql_mysql:mod_quota

make

make install

三、安装MySQL和建立数据库

1. 安装MySQL

rpm -ivh MySQL-3.23.56-1.i386.rpm

rpm -ivh MySQL-client-3.23.56-1.i386.rpm

rpm -ivh MySQL-devel-3.23.56-1.i386.rpm

rpm -ivh MySQL-shared-3.23.56-1.i386.rpm

2. 建立数据库

#建立数据库proftpd

CREATE DATABASE proftpd;

#选定使用的数据(proftpd)

USE 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 '104857600.0',

PRIMARY KEY (`userid`)

) TYPE=MyISAM;

#建立数据库用户及初始化用户密码(数据库用户名:proftpd , 密码: 12345678)

grant all privileges on proftpd.* to proftpd@localhost identified by '12345678';

flush privileges;

四、设置proftpd ( 配置文件 /etc/proftpd.conf )

#将“User nobody”改为“User ftp”

User ftp

#将“Group nogroup”改为“Group ftp”

Group ftp

#关闭proftpd的反向解析查询, 从而加速ftp连线登录

UseReverseDNS off

#将用户限制自己的目录下

DefaultRoot ~

#不使用shell

RequireValidShell no

#打开磁盘配额限制

Quotas on

QuotaCalc on

#硬性限制,将上传超出配额限制的文件删除

QuotaType hard

#默认的配额(100MB)

DefaultQuota 102400

#将默认的单位由“byte”改为“KB”

QuotaBlockSize 1024

QuotaBlockName "K bytes"

#Disable ident protocol (RFC1413)

IdentLookups off

#MySQL的连接参数:数据库@主机名 用户名 密码

SQLConnectInfo proftpd@localhost proftpd 12345678

#指定认证方式

SQLAuthenticate users

#用户密码类型(本文的设置把持Backend、Crypt加密密码和不加密码)

SQLAuthTypes Backend Crypt Plaintext

#用户表信息:表名“user”, 字段名“passwd 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

#Quota信息的表名

SQLQuotaTable users

#MySQL的连接参数: 主机名 用户名 密码 数据库

SQLQuotaInfo localhost proftpd 12345678 proftpd

#用户的字段名

SQLQuotaName userid

#用户已经使用空间的字段名

SQLQuotaUsed used

#用户磁盘配额的字段名

SQLQuotaQuota quota

||||||五、测试

1. 启动Proftd

/etc/rc.d/init.d/proftpd start

2. 建立测试用户

测试用户: test

密码(加密): 87654321

uid: 14

gid: 50

目录:/home/ftp/test

shell: /sbin/nologin

已登录数: 0

已使用空间: 0

磁盘限额: 100MB

方法一: 命令行方式创建

shell> mysql -u proftpd -p

mysql> USE proftpd

mysql> INSERT INTO users VALUES ("test", PASSWORD( "87654321" ) , 14, 50, "/home/ftp/test", "/sbin/nologin", 0, 0, 10240000);

方法二: 用phpMyAdmin方式创建(在选定proftpd数据库的情况执行下列SQL语句)

INSERT INTO users VALUES ("test", PASSWORD( "87654321" ) , 14, 50, "/home/ftp/test", "/sbin/nologin", 0, 0, 10240000);

ceiba

2003-05-18

补充: 常用设置参数

ServerIdent on ftp.abc.com # ftp登录时,显示指的域名ftp.abc.com, 而不显示默认的主机名(域名)

UseReverseDNS off # 关闭proftpd的反向解析查询, 从而加速ftp连线登录

DefaultRoot ~ # 把ftp用户强制限定在自己目录下 — 加强系统安全

TimesGMT off # 关闭GMT与本地时区绑定 — 使用目录和文件的时间显示与系统一致

调试proftpd:

/usr/sbin/proftpd -c /etc/proftpd.conf -d 5 -n

参考:

Proftpd+mysql+quota的实现方法

http://www.eduhr.com/edu/2002-12-30/149.htm

以下是/etc/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 "ProFTPD Default Installation"

ServerType standalone

DefaultServer on

# 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

# 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 under which the server will run.

User ftp

Group ftp

# To cause every FTP user to be "jailed" (chrooted) into their home

# directory, uncomment this line.

UseReverseDNS off

TimesGMT off

DefaultRoot ~

RequireValidShell no

Quotas on

QuotaCalc on

QuotaType hard

DefaultQuota 102400

QuotaBlockSize 1024

QuotaBlockName "K bytes"

IdentLookups off

SQLConnectInfo proftpd@localhost proftpd 12345678

SQLAuthenticate users

SQLAuthTypes Backend Crypt Plaintext

SQLUserInfo users userid passwd uid gid homedir shell

SQLGroupInfo groups groupname gid members

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

SQLQuotaTable users

SQLQuotaInfo localhost proftpd 12345678 proftpd

SQLQuotaName userid

SQLQuotaUsed used

SQLQuotaQuota quota

# Normally, we want files to be overwriteable.

<Directory />

AllowOverwrite on

</Directory>

# A basic anonymous configuration, no upload directories. If you do not

# want anonymous users, simply delete this entire <Anonymous> section.

<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>

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有