debian+pureftpd+mysql+ftpadmin

来源:互联网 发布:android 网络ip电话 编辑:程序博客网 时间:2024/05/13 22:45

强大灵活的ftp服务器pureftpd debian下搭建过程:

 

1.Install PureFTPd With MySQL Support

For Debian there is a pre-configured pure-ftpd-mysql package available. Install it like this:

aptitude install pure-ftpd-mysql

Then we create an ftp group (ftpgroup) and user (ftpuser) that all our virtual users will be mapped to. Replace the group- and userid 2001 with a number that is free on your system:

groupadd -g 2001 ftpgroup
useradd -u 2001 -s /bin/false -d /bin/null -c "pureftpd user" -g ftpgroup ftpuser

 

 

2.创建数据库,并授权

mysql> CREATE DATABASE ftpusers;

mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP ON ftpusers.* TO 'ftp'@'%' IDENTIFIED BY ' tmppasswd';

mysql> FLUSH PRIVILEGES;

 

 

mysqldump的完整库

# more ftpusers.sql
-- MySQL dump 10.11
--
-- Host: localhost    Database: ftpusers
-- ------------------------------------------------------
-- Server version       5.0.51a-24+lenny4-log

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

--
-- Table structure for table `admin`
--

DROP TABLE IF EXISTS `admin`;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `admin` (
  `Username` varchar(35) NOT NULL default '',
  `Password` char(32) character set utf8 collate utf8_bin NOT NULL default '',
  PRIMARY KEY  (`Username`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
SET character_set_client = @saved_cs_client;

--
-- Dumping data for table `admin`
--

LOCK TABLES `admin` WRITE;
/*!40000 ALTER TABLE `admin` DISABLE KEYS */;
INSERT INTO `admin` VALUES ('Administrator','e10adc3949ba59abbe56e057f20f883e');
/*!40000 ALTER TABLE `admin` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `users`
--

DROP TABLE IF EXISTS `users`;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `users` (
  `User` varchar(16) NOT NULL default '',
  `Password` varchar(32) character set utf8 collate utf8_bin NOT NULL default '',
  `Uid` int(11) NOT NULL default '14',
  `Gid` int(11) NOT NULL default '5',
  `Dir` varchar(128) NOT NULL default '',
  `QuotaFiles` int(10) NOT NULL default '500',
  `QuotaSize` int(10) NOT NULL default '30',
  `ULBandwidth` int(10) NOT NULL default '80',
  `DLBandwidth` int(10) NOT NULL default '80',
  `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=MyISAM DEFAULT CHARSET=utf8;
SET character_set_client = @saved_cs_client;

--
-- Dumping data for table `users`
--

LOCK TABLES `users` WRITE;
/*!40000 ALTER TABLE `users` DISABLE KEYS */;
INSERT INTO `users` VALUES ('sp001','cc6dac5d322a2f50298ab2013c8d5696',2001,2001,'/data/ftp/sp001',0,0,0,0,'*','???é…· videos provid
ers ','1',0,0),('cp001','736bb3b39f434eb1f9642ffed2fa0a1e',2001,2001,'/data/ftp/cp001',200,200,100,100,'*','é???????????100K','1',0,0
),('cp002','f6609c420213f7ec6ba6a4fe80fdb4ac',2001,2001,'/data/ftp/cp002',100,100,0,0,'*','','1',0,0),('cp003','754a789dcac670c26ed0
76fca0fe6879',2001,2001,'/data/ftp/cp003',0,0,80,5,'*','?”μè§??‰§?????????','1',0,0),('isp001','e749ae7518a08c579820d0b5d6bc14b3',2001
,2001,'/data/ftp/isp001',2,5,0,0,'*','é?????2??a?–????5M?¤§?°?','1',0,0),('sp002','4ea655252d9034cc10e0ac5865774340',2001,2001,'/data/
ftp/sp002',0,0,0,0,'*','','1',0,0);
/*!40000 ALTER TABLE `users` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2010-09-26  9:20:39

 

 

3。编辑配置文件

# vi /etc/pure-ftpd/db/mysql.conf

MYSQLServer     192.168.206.120
MYSQLPort       3300
MYSQLUser       ftp
MYSQLPassword   tmppasswd
MYSQLDatabase   ftpusers
#MYSQLCrypt md5, cleartext, crypt() or password() - md5 is VERY RECOMMENDABLE uppon cleartext
MYSQLCrypt      md5
MYSQLGetPW      SELECT Password FROM users WHERE User="/L" AND status="1" AND (Ipaddress = "*" OR Ipaddress LIKE "/R")
MYSQLGetUID     SELECT Uid FROM users WHERE User="/L" AND status="1" AND (Ipaddress = "*" OR Ipaddress LIKE "/R")
MYSQLGetGID     SELECT Gid FROM users WHERE User="/L"AND status="1" AND (Ipaddress = "*" OR Ipaddress LIKE "/R")
MYSQLGetDir     SELECT Dir FROM users WHERE User="/L"AND status="1" AND (Ipaddress = "*" OR Ipaddress LIKE "/R")
MySQLGetBandwidthUL SELECT ULBandwidth FROM users WHERE User="/L"AND status="1" AND (Ipaddress = "*" OR Ipaddress LIKE "/R")
MySQLGetBandwidthDL SELECT DLBandwidth FROM users WHERE User="/L"AND status="1" AND (Ipaddress = "*" OR Ipaddress LIKE "/R")
MySQLGetQTASZ   SELECT QuotaSize FROM users WHERE User="/L"AND status="1" AND (Ipaddress = "*" OR Ipaddress LIKE "/R")
MySQLGetQTAFS   SELECT QuotaFiles FROM users WHERE User="/L"AND status="1" AND (Ipaddress = "*" OR Ipaddress LIKE "/R")

 

 

允许创建目录

# more /etc/pure-ftpd/conf/CreateHomeDir
yes

# more /etc/pure-ftpd/conf/MySQLConfigFile
/etc/pure-ftpd/db/mysql.conf

开启chroot

# more /etc/pure-ftpd/conf/ChrootEveryone
yes

以单独进程方式运行pureftpd

# vi /etc/default/pure-ftpd-common

STANDALONE_OR_INETD=standalone

VIRTUALCHROOT=false

UPLOADSCRIPT=/usr/local/sbin/uploadhandler.pl

UPLOADUID=2001
UPLOADGID=2001

 

# /etc/init.d/pure-ftpd-mysql restart

 

 

4.web 管理采用

http://machiel.generaal.net/index.php?subject=user_manager_pureftpd

 

 

 

 

 

 

 

 

 

 

 

 

原创粉丝点击