Pureftpd是一款快速,高质量,功能齐全的ftp服务器,最重要的是可以支持设置客户端默认编码,今天我给大家详细介绍下:Pureftpd 和 mysql 架设FTP服务器的具体过程。
下载mysql5.1.31 rpm文件和pure-ftpd源码包
安装mysql5.1.31共享包
rpm -ivh MySQL-shared-community-5.1.31-0.rhel5.i386.rpm
编译安装pure-ftpd
- #./configure –prefix=/usr/local/pureftpd –with-mysql –with-paranoidmsg –with-welcomemsg –with-uploadscript –with-cookie –with-virtualchroot –with-virtualhosts –with-virtualroot –with-diraliases –with-quotas –with-sysquotas –with-ratios –with-ftpwho –with-throttling
- #make
- #make check
- #make install
配置pure-ftpd
- #cd configuration-file
- #chmod u+x pure-config.pl
- #cp pure-config.pl /usr/local/sbin/
- #cp pure-ftpd.conf /usr/local/etc/
- vi /usr/local/etc/pure-ftpd.conf
确认以下三项
ChrootEveryone yes
MySQLConfigFile /etc/pureftpd-mysql.conf
CreateHomeDir yes
为puer-ftpd创建mysql数据库和用户
CREATE DATABASE pureftpd;
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP ON pureftpd.* TO ‘pureftpd’@'localhost’ IDENTIFIED BY ‘password’;
FLUSH PRIVILEGES;
USE pureftpd;
CREATE TABLE ftpd (
User varchar(16) NOT NULL default ”,
status enum(’0′,’1′) NOT NULL default ’0′,
Password varchar(64) NOT NULL default ”,
Uid varchar(11) NOT NULL default ‘-1′,
Gid varchar(11) NOT NULL default ‘-1′,
Dir varchar(128) NOT NULL default ”,
ULBandwidth smallint(5) NOT NULL default ’0′,
DLBandwidth smallint(5) NOT NULL default ’0′,
comment tinytext NOT NULL,
ipaccess varchar(15) NOT NULL default ‘*’,
QuotaSize smallint(5) NOT NULL default ’0′,
QuotaFiles int(11) NOT NULL default 0,
PRIMARY KEY (User),
UNIQUE KEY User (User)
) TYPE=MyISAM;
配置pureftpd-mysql.conf
vi /etc/pureftpd-mysql.conf
录入
MYSQLSocket /tmp/mysql.sock
#MYSQLServer localhost
#MYSQLPort 3306
MYSQLUser pureftpd
MYSQLPassword password
MYSQLDatabase pureftpd
#MYSQLCrypt md5, cleartext, crypt() or password() – md5 is VERY RECOMMENDABLE uppon cleartext
MYSQLCrypt md5
MYSQLGetPW SELECT Password FROM ftpd WHERE User=”L” AND status=”1″ AND (ipaccess = “*” OR ipaccess LIKE “R”)
MYSQLGetUID SELECT Uid FROM ftpd WHERE User=”L” AND status=”1″ AND (ipaccess = “*” OR ipaccess LIKE “R”)
MYSQLGetGID SELECT Gid FROM ftpd WHERE User=”L”AND status=”1″ AND (ipaccess = “*” OR ipaccess LIKE “R”)
MYSQLGetDir SELECT Dir FROM ftpd WHERE User=”L”AND status=”1″ AND (ipaccess = “*” OR ipaccess LIKE “R”)
MySQLGetBandwidthUL SELECT ULBandwidth FROM ftpd WHERE User=”L”AND status=”1″ AND (ipaccess = “*” OR ipaccess LIKE “R”)
MySQLGetBandwidthDL SELECT DLBandwidth FROM ftpd WHERE User=”L”AND status=”1″ AND (ipaccess = “*” OR ipaccess LIKE “R”)
MySQLGetQTASZ SELECT QuotaSize FROM ftpd WHERE User=”L”AND status=”1″ AND (ipaccess = “*” OR ipaccess LIKE “R”)
MySQLGetQTAFS SELECT QuotaFiles FROM ftpd WHERE User=”L”AND status=”1″ AND (ipaccess = “*” OR ipaccess LIKE “R”)
#p#
各参数注释
User:用户名
status:状态 1为激活状态 0为非激活状态
Password :密码
Uid:用户系统ID号
GID:用户组ID号
ULBandwidth :上传***带宽 单位 KB/S
DLBandwidth:下载***带宽 单位 KB/S
comment :注释
ipaccess :允许访问IP地址
QuotaSize :磁盘配额总大小 单位MB
QuotaFiles :允许存放的文件数目个数 0为不限制
关掉进程
killall pure-ftpd
启动服务
/usr/local/sbin/pure-config.pl /usr/local/etc/pure-ftpd.conf
为ftp添加用户
USE pureftpd;
INSERT INTO `ftpd` (`User`, `status`, `Password`, `Uid`, `Gid`, `Dir`, `ULBandwidth`, `DLBandwidth`, `comment`, `ipaccess`, `QuotaSize`, `QuotaFiles`) VALUES (‘test’, ’1′, MD5(‘test’), ’60031′, ’60031′, ‘/home/test’, ’128′, ’56′, ”, ‘*’, ’100′, ’0′);
即可用数据库里的用户和密码登陆ftp
将pureftpd加载为系统服务
vi /etc/init.d/pureftpd
录入
- #!/bin/bash
- # chkconfig: 35 95 1
- # description: script to start/stop pureftpd
case $1 in
start)
/usr/local/sbin/pure-config.pl /usr/local/etc/pure-ftpd.conf
;;
stop)
killall pure-ftpd
;;
*)
echo “Usage: $0 (start|stop)”
;;
esac
更改权限
# chmod 775 pureftpd
加入自动启动
# chkconfig –add pureftpd
查看自动启动设置
# chkconfig –list pureftpd
pureftpd 0:off 1:off 2:off 3:on 4:off 5:on 6:off
以后可以用以下命令启动和停止脚本
# service pureftpd start 启动
# service pureftpd stop 停止
启动和停止mysql服务
#service mysql start
#service mysql stop
若无法上传文件,设置ftp文件夹权限
chmod -R 777 /data0/htdocs
通过文章的介绍和分析,我们可以清楚的知道利用Pureftpd 和 mysql 架设FTP服务器的详细过程。希望本文对大家有所帮助!
【编辑推荐】