12月2

pureftpd+web界面管理

| |
17:52Linux  
1:安装pureftpd
pw groupadd ftpusers -g 1001
pw adduser ftpusers -u 1001 -g ftpusers -d /usr/www -s /sbin/nologin
chown ftpusers:ftpusers /usr/www
##其中用户、组、/usr/www等可根据自己的实际情况选择

tar jxvf pure-ftpd-1.0.20.tar.bz2
cd pure-ftpd-1.0.20
./configure --prefix=/usr/local/pureftpd --with-mysql --with-paranoidmsg --with-shadow --with-welcomemsg --with-uploadscript --with-quotas --with-cookie --with-virtualhosts --with-virtualroot --with-diraliases --with-sysquotas --with-ratios --with-ftpwho --with-throttling --with-altlog --with-language=simplified-chinese
make
make install
#########################################
以前用pureftpd的时候还不知道最好用ports安装,所以一直自己编译安装,现在要装,最好用ports安装。
cd /usr/ports/ftp/pure-ftpd
ee Makefile
改成这样就行了:
CONFIGURE_ARGS= --with-everything \
--with-paranoidmsg \
--with-virtualchroot \
--with-tls \
--with-largefile \
--sysconfdir=${PREFIX}/etc

然后make install clean即可。
注:多谢benbenblood 兄提示,原来写的不够清楚,容易误导大家 :em06:
######################################

mkdir /usr/local/pureftpd/etc
cp configuration-file/pure-ftpd.conf /usr/local/pureftpd/etc/pure-ftpd.conf
cp configuration-file/pure-config.pl /usr/local/pureftpd/sbin/pure-config.pl
chmod u+x /usr/local/pureftpd/sbin/pure-config.pl

ee /usr/local/pureftpd/etc/pure-ftpd.conf
可参考其他文章进行设置,需要注意的是:
BrokenClientsCompatibility YES
#如果不设置的话,用IE登陆时.ftpquota会不计数,用户的磁盘配额将不起作用。
# MySQL configuration file (see README.MySQL)
# pureftpd-mysql.conf文件的位置
MySQLConfigFile /usr/local/pureftpd/etc/pureftpd-mysql.conf
##这个文件的地方一定要写对

2:安装pureftpd_php_manager
tar zxvf pureftpd_php_manager.tar.gz
cp -R pureftpd_php_manager /usr/www/phpmanager
#或者直接mv,/usr/www目录为apache的主目录,如果不同请更换
find /usr/www/phpmanager -type d -exec chmod 755 {} \;
find /usr/www/phpmanager -type f -exec chmod 644 {} \;
cd /usr/www/phpmanager/
cp pureftpd-mysql.conf.sample /usr/local/pureftpd/etc/pureftpd-mysql.conf


ee /usr/local/pureftpd/etc/pureftpd-mysql.conf

#MYSQLSocket /var/lib/mysql/mysql.sock
MYSQLServer localhost
MYSQLPort 3306
MYSQLUser pureftpd
##注意此处的用户要和后面在数据库中添加的一致
MYSQLPassword abcdefg
##注意此处的密码要和后面在数据库中添加的一致
MYSQLDatabase pureftpd
##注意此处的数据库名字要和后面在数据库中添加的一致
MYSQLCrypt md5
##如果是默认的pureftpd_php_manager则不能用md5,要用crypt或者cleartext,不管是crypt还是cleartext都要和后面的一致

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")
###############################################

ee /usr/www/phpmanager/pureftp.config.php

<?php
######################
####### SETUP ########
######################

// Your exactly located mysql config file for pureftpd
$PUREFTP_CONFIG_FILE = '/usr/local/pureftpd/etc/pureftpd-mysql.conf';

// The location where all the Forms directed to. (Mayby no change needed)
$SELF_URL = 'index.php';

// The location of your pure-ftpdwho binary (set this to chmod 4711)
$FTP_WHO = "/usr/local/sbin/pure-ftpwho";

#######################
# DEFAULT NEW-USER PARAMS #
#######################

$DefaultUser = ""; # Default User Logon
$DefaultPass = ""; # Default User Password
$DefaultUid = "1001"; # Default User ID ( must be a real user acct )
##此处填上安装pureftpd的时候添加的用户id
$DefaultGid = "1001"; # Default Group ID ( must be a real group acct )
##此处填上安装pureftpd的时候添加的用户组id
$DefaultDir = "/usr/www"; # Default User Dir ( use /./ at the end to chroot )
$DefaultUL = "2000"; # Default Upload Throttle ( 0 disables it )
$DefaultDL = "2000"; # Default Download Throttle ( 0 disables it )
$Defaultip = "*"; # Default IP restrictions ( * = any IP )
$DefaultQS = "2000"; # Default Quota Size ( 0 disables it )
$Defaultcmt = ""; # Default Comment for user

// UA
$DefaultQF = "200000"; # Default Quota Files ( 0 disables it )
$PWC = "24"; # Vorsatz fuerr Crypt Password
?>;



mysql -u root -p

mysql>;
drop database pureftpd;

CREATE DATABASE pureftpd;

use pureftpd;

DROP TABLE IF EXISTS ftpd;
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;

grant all privileges on pureftpd.* to pureftpd@localhost identified by 'abcdefg';
##grant all privileges on 你刚建立的数据库名称.* to 你要建的mysql用户名称@localhost identified by 'mysql新用户密码'

FLUSH PRIVILEGES;
##重载受权表

3:启动pureftpd
/usr/local/pureftpd/sbin/pure-config.pl /usr/local/pureftpd/etc/pure-ftpd.conf

为了以后方便的进行Ftp服务的管理,我自己在/usr/local/etc/rc.d中新建了一个pureftpd.sh文件。

ee /usr/local/etc/rc.d/pureftpd.sh

#!/bin/sh

case "$1" in
start)
if [ -f /usr/local/pureftpd/etc/pure-ftpd.conf ]; then
/usr/local/pureftpd/sbin/pure-config.pl /usr/local/pureftpd/etc/pure-ftpd.conf >; /dev/null 2>;&1 && echo -n 'pure-ftpd Begin!'
fi
;;
stop)
/usr/bin/killall pure-ftpd >; /dev/null 2>;&1 && echo -n 'pure-ftpd Stop!'
;;
*)
echo ""
echo "Usage: `basename $0` { start | stop }"
echo ""
exit 64
;;
esac


设置该文件的可执行权限
chmod u+x /usr/local/etc/rc.d/pureftpd.sh
以后可以用下列命令启动PureFTPd服务
/usr/local/etc/rc.d/pureftpd.sh start
用下列命令停止PureFTPd服务
/usr/local/etc/rc.d/pureftpd.sh stop

让它开机自动启动,在/etc/rc.conf里面加入pureftpd_enable="YES"或者不加也可以。

4:web界面管理
安装了pureftpd_php_manager以后就可以通过http://你的域名或ip/phpmanager/index.php来添加、删除用户了。

Tags: , ,
阅读(604) | 评论(0) | 引用(0)