软件环境:
pure-ftpd-1.0.36.tar.gz(pure-ftp)
PureAdmin-0.3.tar.gz(web管理)
pureftp.sql(虚拟账号的数据库导入文件)
pureftpd-mysql.conf(虚拟账号链接数据库的配置文件)
一.安装Pure-ftp server
# wget http://download.pureftpd.org/pub/pure-ftpd/releases/pure-ftpd-1.0.36.tar.gz
# tar -zxvf pure-ftpd-1.0.36.tar.gz -C /usr/local/src/
# cd /usr/local/src/pure-ftpd-1.0.36/
#
./configure \
--prefix=/usr/local/pureftpd \
--with-mysql \
--with-shadow \
--with-pam \
--with-welcomemsg \
--with-uploadscript \
--with-cookie \
--with-virtualchroot \
--with-virtualhosts \
--with-diraliases \
--with-quotas \
--with-puredb \
--with-sysquotas \
--with-ratios \
--with-ftpwho \
--with-throttling
# make && make install
拷贝生成pureftp服务的主配置文件和服务脚本:
# chmod a+x configuration-file/pure-config.pl
# cp configuration-file/pure-config.pl /usr/local/pureftpd/sbin/
# mkdir /usr/local/pureftpd/etc
# cp configuration-file/pure-ftpd.conf /usr/local/pureftpd/etc/
拷贝生成pureftp服务的启动脚本,并编辑修改相应参数:
# cp contrib/redhat.init /etc/init.d/pureftpd
# vim /etc/init.d/pureftpd
# chmod 755 /etc/init.d/pureftpd
# chkconfig --add pureftpd
# chkconfig pureftpd on
配置pure-ftp的主配置文件,添加虚拟账号的登录环境参数:
# vim /usr/local/pureftpd/etc/pure-ftpd.conf
创建用户的家目录:
# mkdir /data/resources/ftpdata
# useradd virtualftp -d /data/resources/ftpdata/ -s /sbin/nologin -M
虚拟账号的认证配置:
# vim /usr/local/pureftpd/etc/pure-ftpd.conf
建立虚拟账号与服务器本地账号的映射:
# cd /usr/local/pureftpd/bin/
说明:
user1是用户名,-u virtualftp是其实际的linux用户,-d指定起始目录,并锁定于该目录。如果不锁定,则用-D;如果需要不同的权限,可以建立新的linux用户与组,如果用的系统自带的ftp用户,这样的话还需修改配置文件pure-ftpd.conf中的MinUID为ftp用户的UID 14,否则登录时会出现530错误;所以这里建议创建另一个非系统自带的用户做映射.
建立用户数据库:
# ./pure-pw mkdb /usr/local/pureftpd/pureftpf.pdb
二、安装PureAdmin web管理
# tar -zxvf PureAdmin-0.3.tar.gz
导入数据文件pureftp.sql到MySQL数据库,因为小编使用的MYSQL是5.1以上的版本,所以PureAdmin的表结构的引擎并不能够完全兼容,要做出修改.
注:导入前作如下修改.
INSERT INTO mysql.user (Host, User, Password, Select_priv, Insert_priv, Update_priv, Delete_priv, Create_priv, Drop_priv, Reload_priv, Shutdown_priv, Process_priv, File_priv, Grant_priv, References_priv, Index_priv, Alter_priv,ssl_cipher,x509_issuer,x509_subject) VALUES('localhost','ftp',PASSWORD('passwd'),'Y','Y','Y','Y','N','N','N','N','N','N','N','N','N','N','Y','Y','Y');
FLUSH PRIVILEGES;
CREATE DATABASE ftpusers;
USE ftpusers;
CREATE TABLE admin (
Username varchar(35) NOT NULL default '',
Password char(32) binary NOT NULL default '',
PRIMARY KEY (Username)
) ;
INSERT INTO admin VALUES ('admin',MD5('123456'));
CREATE TABLE `users` (
`User` varchar(16) NOT NULL default '',
`Password` varchar(32) binary 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`)
) ;
导入数据,并授权:
# /etc/init.d/mysqld start
# mysql -rroot -p < pureftp.sql
mysql>grant all privileges on ftpusers.* to ftp@localhost identified by 'tmppasswd';
mysql> flush privileges;
mysql> quit
修改pureadmin的配置文件,修改数据库的相关参数:
# vim /var/www/html/pureadmin/config.php
遇到的错误:
报错:configure: error: PAM headers not found.