pure-ftpd 安装与配置

环境 :centos 5.5 x86_32  
软件列表:
Pure-ftpd         http://download.pureftpd.org/pub/pure-ftpd/releases/pure-ftpd-1.0.24.tar.g
Pureadmin         http://www.yiyou.org/docs/PureAdmin_03_php/PureAdmin-0.3.tar.gz
Apache
Mysql
  实现功能 :通过 web 管理 ftp 用户,实现新增、删除、密码修改、上传 / 下载限速、磁盘限额、文件数量等。
Apache mysql 安装
为了快速达建好 pure-ftpd 服务器平台, apache mysql 将采取 yum 安装方式安装。
yum -y install httpd mysql-develmysql-server php php-xml php-cli php-pdo php-mbstring php-mcrypt php-gdphp-common php-devel php-mysql

Pure-ftpd 安装
#   wget  http://download.pureftpd.org/pub/pure-ftpd/releases/pure-ftpd-1.0.24.tar.gz
#  tar zxvf pure-ftpd-1.0.24.tar.gz
#   cd pure-ftpd-1.0.24
#   ./configure --prefix=/opt/pureftpd \
       --with-mysql= \
                    --with-paranoidmsg \
                    --with-shadow \
                    --with-welcomemsg \
                    --with-uploadscript \
                    --with-quotas \
                    --with-cookie \
                    --with-virtualhosts \
                    --with-diraliases \
                   --with-sysquotas \
                   --with-ratios \
                   --with-ftpwho \
                   --with-throttling \
                   --with-language=simplified-chinese
#   make
#   make install 
Pure-ftpd 配置
#   cppureftpd-mysql.conf /etc
#   cpconfiguration-file/pure-ftpd.conf /etc 
修改pureftpd-mysql.conf
#   vi/etc/pureftpd-mysql.conf
保证配置文件里有下面 3  
ChrootEveryone yes                                # 锁定用户在主目录中
MySQLConfigFile /etc/pureftpd-mysql.conf   # 使用 mysql 验证与 apache 整合
CreateHomeDir yes                                  # 自动创建用户主目录  
修改pureftpd-mysql.conf
#   vi/etc/pureftpd-mysql.conf
确定有以下配置文件,如没有,则自行添加。
MYSQLSocket       /var/lib/mysql/mysql.sock  # mysql.sock 文件
MYSQLUser          ftpuser                           # mysql 用户名
MYSQLPassword   ftppass                           # mysql 密码
MYSQLDatabase   ftpname                          # mysql 数据库名
MYSQLCrypt         md5                               # 加密方式,这里用 md5 加密
MYSQLGetPW       SELECT Password FROM users WHEREUser="\L" AND Status="1" AND (Ipaddress = "*" ORIpaddress LIKE "\R")
MYSQLGetUID      SELECT Uid FROM users WHEREUser="\L" AND Status="1" AND (Ipaddress = "*" ORIpaddress LIKE "\R")
MYSQLGetGID      SELECT Gid FROM users WHEREUser="\L" AND Status="1" AND (Ipaddress = "*" ORIpaddress LIKE "\R")
MYSQLGetDir      SELECT Dir FROM users WHEREUser="\L" AND Status="1" AND (Ipaddress = "*" ORIpaddress LIKE "\R")
MySQLGetQTAFS   SELECT QuotaFiles FROM users WHERE User="\L"AND Status="1" AND (Ipaddress = "*" OR Ipaddress LIKE"\R")
MySQLGetQTASZ   SELECT QuotaSize FROM users WHEREUser="\L" AND Status="1" AND (Ipaddress = "*" ORIpaddress LIKE "\R")
MySQLGetRatioUL SELECT ULRatio FROM usersWHERE User="\L" AND Status="1" AND (Ipaddress ="*" OR Ipaddress LIKE "\R")
MySQLGetRatioDL SELECT DLRatio FROM usersWHERE User="\L" AND Status="1" AND (Ipaddress ="*" OR Ipaddress LIKE "\R")
MySQLGetBandwidthUL SELECT ULBandwidth FROMusers WHERE User="\L" AND Status="1" AND (Ipaddress ="*" OR Ipaddress LIKE "\R")
MySQLGetBandwidthDL SELECT DLBandwidth FROMusers WHERE User="\L" AND Status="1" AND (Ipaddress ="*" OR Ipaddress LIKE "\R") 
Pure-ftpd 启动
#   cpconfiguration-file/pure-config.pl /etc
#   vi/etc/init.d/pureftpd
脚本如下
#!/bin/sh
/etc/pure-config.pl /etc/pure-ftpd.conf
设置权限
# chmod 755 /etc/ pure-config.pl 
#  ln -s /opt/pureftpd/sbin/pure-ftpd /usr/sbin/    # 创建连接文件
: 如不创建pure-ftpd 连接文件,启动将会出错。  
#  /etc/init.d/pureftpd
Running: /usr/sbin/pure-ftpd -A -c50 -B -C8-D -fftp -H -I15 -lmysql:/etc/pureftpd-mysql.conf -L2000:8 -m4 -s -U133:022-u100 -j -k99 –Z
看到以上内容,说明启动成功。  
建立ftp 用户和目录
创建 ftp 组和用户
#   groupadd ftpgroup –g 10000
#   useradd ftpuser –g ftpgroup –u 10000 –d /dev/null –s /sbin/nologin
创建 ftp 目录和设置权限
#   mkdir –p /opt/ftpuser
#   chown –R ftpuser.ftpgroup /opt/ftpuser
#   chmod –R 775 /opt/ftpuser
创建mysql 数据库
#   vi pureftp.sql
sql 脚本如下
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) VALUES('localhost','ftpuser',PASSWORD('ftppass'),'Y','Y','Y','Y','N','N','N','N','N','N','N','N','N','N');
FLUSH PRIVILEGES;

CREATE DATABASE ftpname
USE ftpname;
--
-- Table structure for table 'admin'
--
CREATE TABLE admin (
  Username varchar(35) NOT NULL default '',
  Password char(32) binary NOT NULL default '',
  PRIMARY KEY   (Username)
) TYPE=MyISAM;
--
-- Data for table 'admin'
--
INSERT INTO admin VALUES('admin',MD5('passwd'));
--
-- Table structure for table 'users'
--
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`)
) TYPE=MyISAM; 
导入 mysql 数据库
#   mysql –uroot –p < pureftp.sql
PureAdmin 安装
#  wget http://www.yiyou.org/docs/PureAdmin_03_php/PureAdmin-0.3.tar.gz
#  tar zxvf PureAdmin-0.3# mv PureAdmin-0.3 /var/www/html/pureadmin 
# 将PureAdmin-0.3移动到apache默认根目录下
PureAdmin配置
#  cd/var/www/html/pureadmin
#  viconfig.php
修改以下几行。
$cfg['dbhost']='localhost';                                           //mysql主机地址
$cfg['dbname']='ftpname';                                          //mysql数据库名
$cfg['dbuser']='ftpuser';                                              //mysql用户名
$cfg['dbpasswd']='ftppass';                                          //mysql用户密码
$cfg['passwdtype']='MD5';                                           //md5加密方式
$cfg['uid']=10000;                  //uid
$cfg['gid']=10000;                 //gid
$cfg['dir']='/opt/ftproot';                 //ftp用户目录

PureAdmin 管理
访问 http://IP/pureadmin ,提示输入用户密码,默认用户名 :admin 密码 :passwd 如下图所示:
111.jpg
 
可以对 ftp 用户相关权限设置。       
Pure-ftpd 相关参考链接  
http://ybadmin.blog.163.com/blog/static/3777647020091861917697
http://bbs.linuxtone.org/viewthread.php?tid=846&highlight=pureftpd
http://www.tpblog.cn/show-8-1.html
http://www.chinaunix.net/jh/15/2424.html

 

你可能感兴趣的:(centos,pureftpd)