pureftpd安装配置

运维 ouk 1351℃ 0评论

第一步部分pureftpd安装
1、下载pure-ftpd安装包
[root@oukweb ouk]# wget http://download.pureftpd.org/pub/pure-ftpd/releases/pure-ftpd-1.0.39.tar.gz
–2015-06-03 17:38:04– http://download.pureftpd.org/pub/pure-ftpd/releases/pure-ftpd-1.0.39.tar.gz
Resolving download.pureftpd.org… 91.121.49.42
Connecting to download.pureftpd.org|91.121.49.42|:80… connected.
HTTP request sent, awaiting response… 200 OK
Length: 593173 (579K) [text/plain]
Saving to: 鈥減ure-ftpd-1.0.39.tar.gz鈥
100%[======================================>] 593,173 220K/s in 2.6s
2015-06-03 17:38:09 (220 KB/s) – 鈥減ure-ftpd-1.0.39.tar.gz鈥saved [593173/593173]
[root@oukweb ouk]# tar -xzvf pure-ftpd-1.0.39.tar.gz
[root@oukweb ouk]# cd pure-ftpd-1.0.39
2、编译:
[root@oukweb pure-ftpd-1.0.39]# ./configure –prefix=/usr/local/pureftpd –with-mysql=/usr/local/mysql –with-throttling –with-puredb –with-virtualhosts –with-virtualroot –with-cookie –with-quotas –with-sysquotas –with-ratios –with-welcomemsg –with-peruserlimits –with-lanaguage=simplified-chinese
[root@oukweb pure-ftpd-1.0.39]# make && make install
/usr/local/pureftpd 为安装地址 –with-mysql=/usr/local/mysql 为mysql安装路径 如果mysql是yum安装则直接为 –with-mysql

第二部分,pureftpd配置
1、配置pureftpd启动服务
mkdir -p /usr/local/pureftpd/etc 【创建配置文件的存放目录】
[root@oukweb pure-ftpd-1.0.39] cd configuration-file/
cp pure-ftpd.conf /usr/local/pureftpd/etc/ 【创建主配置文档】
cp pure-config.pl /usr/local/pureftpd/sbin/ 【启动服务时调用的文件】
chmod 755 /usr/local/pureftpd/pure-config.pl 【赋予执行权限】
[root@oukweb pureftpd]# cp /home/ouk/pure-ftpd-1.0.39/contrib/redhat.init /etc/init.d/pure-ftpd【创建启动脚本】
chmod 755 /etc/init.d/pure-ftpd 【赋予执行权限】
vi /etc/init.d/pure-ftpd 【修改几处绝对路径】
18行修改为:fullpath=/usr/local/pureftpd/sbin/$prog
19行修改为:pureftpwho=/usr/local/pureftpd/sbin/pure-ftpwho
24行修改为:/usr/local/pureftpd/etc/pure-ftpd.conf –daemonize
(以上修改的位置实际上是编译的时候prefix=的位置)

2、修改pure-ftpd.conf 文件
ChrootEveryone yes
# TrustedGID 100
BrokenClientsCompatibility no
MaxClientsNumber 50
Daemonize yes
MaxClientsPerIP 8
VerboseLog no
DisplayDotFiles yes
AnonymousOnly no
NoAnonymous no
SyslogFacility ftp
DontResolve yes
MaxIdleTime 15
MySQLConfigFile /usr/local/pureftpd/etc/pureftpd-mysql.conf
#PureDB /usr/local/pureftpd/etc/pureftpd.pdb
UnixAuthentication yes
LimitRecursion 10000 8
AnonymousCanCreateDirs no
MaxLoad 4
# PassivePortRange 30000 50000
# ForcePassiveIP 192.168.0.1
AntiWarez yes
Umask 133:022
AllowUserFXP yes
AllowAnonymousFXP no
ProhibitDotFilesWrite no
ProhibitDotFilesRead no
AutoRename no
AnonymousCantUpload no
#TrustedIP 10.1.1.1
#LogPID yes
#NoChmod yes
#KeepAllFiles yes
CreateHomeDir yes
MaxDiskUsage 99
CustomerProof yes
IPV4Only yes
3、修改pureftpd-mysql.conf配置
复制pureftpd-mysql.conf 到 /usr/local/pureftpd/etc/目录中
MYSQLServer localhost
MYSQLPort 3306
MYSQLSocket /tmp/mysql.sock
MYSQLUser ftp #MYSQLUser 数据用户名
MYSQLPassword ftppass. #MYSQLUser 数据库密码
MYSQLDatabase pureftpd #MYSQLUser 数据库名称
MYSQLCrypt md5 #密码加密方式”cleartext”, “crypt”, “md5″ and “password”
MYSQLGetPW SELECT password FROM pf_ftp WHERE user=’\L’ AND status=’0′
MYSQLGetUID SELECT uid FROM pf_ftp WHERE user=’\L’ AND status=’0′
MYSQLGetGID SELECT gid FROM pf_ftp WHERE user=’\L’ AND status=’0′
MYSQLGetDir SELECT dir FROM pf_ftp WHERE user=’\L’ AND status=’0′
MySQLGetQTAFS SELECT quotafiles FROM pf_ftp WHERE user=’\L’ AND status=’0′
MySQLGetQTASZ SELECT quotasize FROM pf_ftp WHERE user=’\L’ AND status=’0′
# MySQLGetRatioUL SELECT ulratio FROM pf_ftp WHERE user=’\L’ AND status=’0′
# MySQLGetRatioDL SELECT dlratio FROM pf_ftp WHERE user=’\L’ AND status=’0′
#MySQLGetBandwidthUL SELECT ulbandwidth FROM pf_ftp WHERE user=’\L’ AND status=’0′
#MySQLGetBandwidthDL SELECT dlbandwidth FROM pf_ftp WHERE user=’\L’ AND status=’0′
# MySQLForceTildeExpansion 1
# MySQLTransactions On
5、创建对应数据表
CREATE TABLE IF NOT EXISTS `pf_ftp` (
`id` int(10) unsigned NOT NULL,
`mid` int(10) unsigned NOT NULL DEFAULT ‘0’,
`sid` int(10) unsigned NOT NULL DEFAULT ‘0’,
`nid` int(4) unsigned NOT NULL DEFAULT ‘0’,
`user` varchar(20) 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` tinyint(1) NOT NULL DEFAULT ‘3’,
`ulratio` smallint(5) NOT NULL DEFAULT ‘1’,
`dlratio` smallint(5) NOT NULL DEFAULT ‘1’,
`rtime` int(11) unsigned NOT NULL DEFAULT ‘0’,
`utime` int(11) unsigned NOT NULL DEFAULT ‘0’,
`vtime` int(11) unsigned NOT NULL DEFAULT ‘0’
) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
6、虚拟账号创建
现在服务器上创建虚拟账号映射账号
groupadd -g 1001 ftpgroup
useradd ftpuser -g ftpgroup -u 1001 -d /www -s /sbin/nologin -M 【创建虚拟用户映射的系统账户】
chown ftpuser:ftpgroup /www 【将虚拟账号的根目录文件夹/www 的组与用户设置为ftpuser组和ftpgroup用户】
插入数据
INSERT INTO `pf_ftp` (`user`,`status`,`password`,`uid`,`gid`,`dir`,`ulbandwidth`,`dlbandwidth`,`comment`,`ipaddress`,`ulratio`,`dlratio`,`quotafiles`,`quotasize`)VALUES(‘test’,’3′,MD5(‘123456′),’1001′,’1001′,’/www/test/’,”,”,”,’*’,”,”,”,”);
其中1001为uid ,第二个1001gid
账号添加完成后,测试账号是否能够登陆

如果不使用数据库形式,则在直接使用pureDB,则在pure-ftpd.conf中注释mysql ,开启PureDB /usr/local/pureftpd/etc/pureftpd.pdb
创建ftp用户:
/usr/local/pureftpd/bin/pure-pw useradd ftpuser -f /usr/local/pureftpd/etc/pureftpd.passwd -u 1001 -g 1001 -d /www
(1001是/etc/passwd里面的uid和gid)
cat /usr/local/pureftpd/etc/pureftpd.passwd 密码是加密的
(如果创建的user不是/etc/passwd已经存在的话,把ftp所在目录给777权限才能上传文件)
刷新数据库使添加的用户生效:(注意每次添加删除账号都要刷新一次)
/usr/local/pureftpd/bin/pure-pw mkdb /usr/local/pureftpd/etc/pureftpd.pdb -f /usr/local/pureftpd/etc/pureftpd.passwd

这样就直接生成虚拟账号不用连接数据
配置完成后就可以通过各种方式测试ftp连接

转载请注明:OUK技术人生 » pureftpd安装配置

喜欢 (0)
发表我的评论
取消评论
表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址