ubuntu pure-ftpd + mysql 配置详情

上一篇文章是使用PureDB来存储虚拟用户信息,本篇文章将会使用mysql来存储ftp用户数据信息

一 下载安装

编译安装
./configure --with-mysql --with-rfc2640 --with-everything --with-puredb
在安装的时候出现了一个小问题:ubuntu configure: error: libmysqlclient is needed for MySQL support
解决方法:安装libmysqlclient-dev包

二 配置

ChrootEveryone               yes
BrokenClientsCompatibility   no
MaxClientsNumber             50
Daemonize                    yes
MaxClientsPerIP              8
VerboseLog                   no
DisplayDotFiles              yes
AnonymousOnly                no
NoAnonymous                  yes  #禁止匿名用户登陆
SyslogFacility               auth
DontResolve                  yes
MaxIdleTime                  15
MySQLConfigFile              /etc/pureftpd-mysql.conf    #mysql验证
PureDB                       /etc/pureftpd.pdb
LimitRecursion               10000 8
AnonymousCanCreateDirs       no
MaxLoad                      4
PassivePortRange             30000 50000  #被动模式
ForcePassiveIP              172.30.51.200 
AntiWarez                    yes
Umask                        133:022
MinUID                       100
AllowUserFXP                 no
AllowAnonymousFXP            no
ProhibitDotFilesWrite        no
ProhibitDotFilesRead         no
AutoRename                   no
AnonymousCantUpload          no
MaxDiskUsage                   99
CustomerProof                yes

三 创建用户

建立mysql认证数据库

[root@localhost ~]# mysql -uroot -p
mysql>create database pureftpd;
mysql>grant all privileges on pureftpd.* to 'pureftpuser'@'%' identified by 'pureftpuser';
mysql>flush privileges;
mysql>use pureftpd;
mysql> create table if not exists `users`(
	`user` varchar(16) not null default '',
	`password` varchar(32) not null default '',
	`uid` int(11) not null default '1000',
	`gid` int (11) not null default '1000',
	`dir` varchar(128) not null default '',
	`quotafiles` int(10) not null default '0',
	`quotasize` int(10) not null default '0',
	`ulbandwidth` int(10) not null default '0',
	`dlbandwidth` int(10) not null default '0',
	`ipaddress` varchar(15) not null default '*',
	`comment` tinytext,
	`status` enum('0','1') not null default '1',
	`ulratio` smallint(5) not null default '1',
	`dlratio` smallint(5) not null default '1',
	primary key (`user`),
	unique key `user` (`user`)
	)engine=innodb default charset=utf8;
mysql> show tables;
+--------------------+
| Tables_in_pureftpd |
+--------------------+
| users              |
+--------------------+
1 row in set (0.00 sec)
mysql> desc users;
+-------------+---------------+------+-----+---------+-------+
| Field       | Type          | Null | Key | Default | Extra |
+-------------+---------------+------+-----+---------+-------+
| user        | varchar(16)   | NO   | PRI |         |       |
| password    | varchar(32)   | NO   |     |         |       |
| uid         | int(11)       | NO   |     | NULL    |       |
| gid         | int(11)       | NO   |     | NULL    |       |
| dir         | varchar(128)  | NO   |     |         |       |
| quotafiles  | int(10)       | NO   |     | 0       |       |
| quotasize   | int(10)       | NO   |     | 0       |       |
| ulbandwidth | int(10)       | NO   |     | 0       |       |
| dlbandwidth | int(10)       | NO   |     | 0       |       |
| ipaddress   | varchar(15)   | NO   |     | *       |       |
| comment     | tinytext      | YES  |     | NULL    |       |
| status      | enum('0','1') | NO   |     | 1       |       |
| ulratio     | smallint(5)   | NO   |     | 1       |       |
| dlratio     | smallint(5)   | NO   |     | 1       |       |
+-------------+---------------+------+-----+---------+-------+

User:帐号名;
Password:密码,使用MD5加密;
Uid:前面创建的ftpuser帐户号;
Gid:前面创建的ftpgroup组号;
Dir:虚拟用户的个人目录路径;
ULBandwidth:上传文件限制速度,KB/s,0为不限制;
DLBandwidth:下载文件限制速度,KB/s,0为不限制;
comment:备注信息;
ipaccess:* 表示任意IP都可以访问此ftp服务器,输入具体IP地址可以只允许此IP连接服务器;
QuotaSize:用户磁盘空间分配,单位:MB,0表示不加限制;
QuotaFiles:用户可以保存的文件数量限制,0表示不加限制。
status:0 表示帐号被禁用,无法登录服务器;

在数据库中创建pureftp虚拟用户

mysql> insert into users values ('xixi','password','7777','7777','/ftp','500','30','30','50','*','','1','1','1');
mysql> select * from users\G;
*************************** 1. row ***************************
       user: bev
   password: 5bc915d575ad9c57aa0fc6e1fd719615
        uid: 7777
        gid: 7777
        dir: /ftp
 quotafiles: 500
  quotasize: 30
ulbandwidth: 30
dlbandwidth: 50
  ipaddress: *
    comment: 
     status: 1
     ulratio: 1
    dlratio: 1
1 row in set (0.11 sec)

ERROR: 
No query specified

注意mysql账户密码的加密方式需要与pureftp支持的机密方式相吻合,不然会出现530错误

mysql> update users set password=md5('pureftpuser') where user='bev';
   我在这里选择的MD5加密方式,那么在下面配置pureftp的加密方式时一定选择MD5。

修改pureftp关于mysql模块的配置文档 /etc/pureftpd-mysql.conf 如果文件不存在,请在源码包中拷贝即可

# Optional : define the location of mysql.sock if the server runs on this host.
MYSQLSocket     /var/lib/mysql/mysql.sock      # mysql.sock文件
MYSQLUser       pureftpuser                    # mysql用户名
MYSQLPassword   pureftpuser                    # mysql密码
MYSQLDatabase   pureftpd                       # mysql数据库名
MYSQLCrypt      md5                            #加密方式,这里用md5加密

MYSQLGetPW      SELECT Password FROM users WHERE User='\L'
MYSQLGetUID     SELECT Uid FROM users WHERE User='\L'
MYSQLGetGID     SELECT Gid FROM users WHERE User='\L'
MYSQLGetDir     SELECT Dir FROM users WHERE User='\L'
MySQLGetQTAFS   SELECT QuotaFiles FROM users WHERE User='\L'
MySQLGetQTASZ   SELECT QuotaSize FROM users WHERE User='\L'
MySQLGetRatioUL SELECT ULRatio FROM users WHERE User='\L'
MySQLGetRatioDL SELECT DLRatio FROM users WHERE User='\L'
MySQLGetBandwidthUL SELECT ULBandwidth FROM users WHERE User='\L'
MySQLGetBandwidthDL SELECT DLBandwidth FROM users WHERE User='\L'

这里重点说下;这个配置文件是你数据库的对应的数据库和表的内容,不要按照网上的复制,根据自己数据库建立的数据库和表做相应的配置。
表中必须的内容有 用户名,密码,Uid,Gid,Dir,其余皆可省略。请注意与你的配置文件相对应。

重启pureftp,测试刚刚建立的xixi是否生效了
在这里,我提醒大家出现错误先去vi /var/log/messages 看下ftp标签所报错误,对症下药。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值