内容有点乱,回头有空再整理
Pure-Ftpd 采用 MariaDB 数据库,确保下面几项都已安装
yum -y install MariaDB-client MariaDB-server MariaDB-devel
下载并解压pure-ftpd包
进入pure-ftp目录,执行
./configure --prefix=/usr/local/pureftpd --with-cookie --with-throttling --with-ratios --with-quotas --with-sysquotas --with-largefile --with-welcomemsg --with-uploadscript --with-virtualhosts --with-virtualroot --with-virtualchroot --with-diraliases --with-peruserlimits --with-language=simplified-chinese --with-mysql --with-paranoidmsg --with-altlogmake && make install
配置
准备文件
cd configuration-filecp pure-config.pl /usr/local/pureftpd/bin/.chmod 755 /usr/local/pureftpd/bin/pure-config.plmkdir /usr/local/pureftpd/etc //新建FTP的配置文件夹目录cp pure-ftpd.conf /usr/local/pureftpd/etc/. //复制ftp配置文件到etc中cd .. //切换到/pure-ftpd-1.0.22目录中cp pureftpd-ldap.conf /usr/local/pureftpd/etc/. //相关配置文件复制到etc中cp pureftpd-mysql.conf /usr/local/pureftpd/etc/. //相关配置文件复制到etc中cp pureftpd-pgsql.conf /usr/local/pureftpd/etc/. //相关配置文件复制到etc中
pure-ftpd.conf配置
vi /usr/local/pureftpd/etc/pureftpd-mysql.conf
MYSQLSocket /tmp/mysql.sock#MYSQLServer localhost#MYSQLPort 3306MYSQLUser pureftpdMYSQLPassword 这里输入前面给mysql授权时的密码MYSQLDatabase pureftpd#MYSQLCrypt md5, cleartext, crypt() or password() - md5 is VERY RECOMMENDABLE uppon cleartextMYSQLCrypt md5MYSQLGetPW 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")
pure-ftpd.conf配置
vi /usr/local/pureftpd/etc/pure-ftpd.conf
ChrootEveryone yesMySQLConfigFile /usr/local/pureftpd/etc/pureftpd-mysql.confCreateHomeDir yes
创建组和用户以及mysql表创建
# groupadd ftpgroup –g 1000# useradd ftpuser –g ftpgroup –u 1000 –d /data/ftp –s /sbin/nologin
CREATE DATABASE pureftpd;GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP ON pureftpd.* TO 'pureftpd'@'localhost' IDENTIFIED BY '对应的密码';GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP ON pureftpd.* TO 'pureftpd'@'localhost.localdomain' IDENTIFIED BY '对应的密码';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;
数据表说明:User:帐号名;status:0 表示帐号被禁用,无法登录服务器;Password:密码,使用MD5加密;Uid:前面创建的ftpuser帐户号,我们填写的是2001;Gid:前面创建的ftpgroup组号,我们填写的是2001;Dir:虚拟用户的个人目录路径,将在/home下创建(第一次登录);ULBandwidth:上传文件限制速度,KB/s,0为不限制;DLBandwidth:下载文件限制速度,KB/s,0为不限制;comment:备注信息;ipaccess:* 表示任意IP都可以访问此ftp服务器,输入具体IP地址可以只允许此IP连接服务器;QuotaSize:用户磁盘空间分配,单位:MB,0表示不加限制;QuotaFiles:用户可以保存的文件数量限制,0表示不加限制。
添加pureftpd为系统服务
vi /etc/init.d/pureftpd
#!/bin/sh## ScriptName: /etc/init.d/pureftpd# chkconfig: - 60 50# description: pureftpd is a ftp daemon, which is the program \# that answers incoming ftp service requests.# processname: pureftpd## Author : cnscn# Time : 2006-04-18 09:30##tput funcfuncTput(){tput initfor argsdocase "$args" ingreen_black)echo -e -n "\033[;32m";;red_black)echo -e -n "\033[;31m";;endtput)tput sgr0esacdone}case "$1" instart)ps aux | grep pure-ftp | grep -v grep > /dev/null 2>&1if [ $? -eq 0 ]thenecho -n "Pureftpd has already been running ... "funcTput red_blackecho "[failed]"funcTput endtputexit 1fiecho -n "start pureftpd.... "/usr/local/pureftpd/bin/pure-config.pl /usr/local/pureftpd/etc/pure-ftpd.conf > /dev/null 2>&1if [ $? -eq 0 ] ; thenfuncTput green_blackecho " [OK]"funcTput endtputelsefuncTput red_blackecho " [Failed] ";funcTput endtputfi;;stop)ps aux | grep pure-ftp | grep -v grep > /dev/null 2>&1if [ $? -eq 1 ]thenecho -n "Pureftpd has not been runned now ... "funcTput red_blackecho "[failed]"funcTput endtputexit 1fiecho -n "Stop pureftpd... "killall pure-ftpd > /dev/null 2>&1if [ $? -eq 0 ] ; thenfuncTput green_blackecho " [OK]"funcTput endtputelsefuncTput red_blackecho " [Failed] ";funcTput endtputfi;;restart)ps aux | grep pure-ftp | grep -v grep > /dev/null 2>&1if [ $? -eq 0 ]thenecho -n "Stop pureftpd... "killall pure-ftpd > /dev/null 2>&1if [ $? -eq 0 ] ; thenfuncTput green_blackecho " [OK]"funcTput endtputelsefuncTput red_blackecho " [Failed] ";funcTput endtputfifiecho -n "start pureftpd.... "/usr/local/pureftpd/bin/pure-config.pl /usr/local/pureftpd/etc/pure-ftpd.conf >/dev/null 2>&1if [ $? -eq 0 ] ; thenfuncTput green_blackecho " [OK]"funcTput endtputelsefuncTput red_blackecho " [Failed] ";funcTput endtputfi;;*)echo "Usage: `basename $0` {start | stop | restart}";;esacexit 0
参考: