#################################安装ftp服务器pure-ftpd############################
cd /usr/ports/ftp/pure-ftpd
ee /usr/ports/ftp/pure-ftpd/Makefile
add
--with-everything \
--with-paranoidmsg \
--with-virtualchroot \
--with-tls \
--with-largefile \
--with-welcomemsg \
--with-uploadscript \
--with-cookie \
--with-virtualhosts \
--with-virtualroot \
--with-diraliases \
--with-quotas \
--with-sysquotas \
--with-ratios \
--with-ftpwho \
--with-throttling \
--sysconfdir=${PREFIX}/etc
make WITH_MYSQL=1 WITH_LANG=simplified-chinese
make install
make clean
make rmconfig
cd /usr/local/etc
cp pureftpd-mysql.conf.sample pureftpd-mysql.conf
cp pure-ftpd.conf.sample pure-ftpd.conf
ee /usr/local/etc/pure-ftpd.conf
changes
NoAnonymous no
77 NoAnonymous yes
# MySQLConfigFile /etc/pureftpd-mysql.conf
116 MySQLConfigFile /usr/ocal/etc/pureftpd-mysql.conf
#UserRatio 1 10
201 UserRatio 1 10
MinUID 100
240 MinUID 2000
AllowUserFXP no
246 AllowUserFXP yes
#AltLog w3c:/var/log/pureftpd.log
318 AltLog w3c:/var/log/pureftpd.log
#NoChmod yes
324 NoChmod yes
# KeepAllFiles yes
330 KeepAllFiles no
#CreateHomeDir yes
336 CreateHomeDir yes
ee /usr/local/etc/pureftpd-mysql.conf
# MYSQLServer 127.0.0.1
12 MYSQLServer 127.0.0.1
# MYSQLPort 3306
17 MYSQLPort 3306
MYSQLUser root
27 MYSQLUser ftp
MYSQLPassword rootpw
32 MYSQLPassword e89120d9dfeb
MYSQLDatabase pureftpd
37 MYSQLDatabase ftpusers
MYSQLCrypt cleartext
45 MYSQLCrypt md5
MYSQLDefaultUID 1000
73 MYSQLDefaultUID 2000
#MYSQLDefaultGID 1000
83 MYSQLDefaultGID 2000
# MySQLGetQTAFS ELECT QuotaFiles FROM users WHERE User="\L"
94 MySQLGetQTAFS SELECT QuotaFiles FROM users WHERE User="\L"
#MySQLGetQTASZ SELECT QuotaSize FROM users WHERE User="\L"
101 MySQLGetQTASZ SELECT QuotaSize FROM users WHERE User="\L"
# MySQLGetRatioUL SELECT ULRatio FROM users WHERE User="\L"
# MySQLGetRatioDL SELECT DLRatio FROM users WHERE User="\L"
106 MySQLGetRatioUL SELECT ULRatio FROM users WHERE User="\L"
107 MySQLGetRatioDL SELECT DLRatio FROM users WHERE User="\L"
# MySQLGetBandwidthUL SELECT ULBandwidth FROM users WHERE User="\L"
114 MySQLGetBandwidthDL SELECT DLBandwidth FROM users WHERE User="\L"
# MySQLForceTildeExpansion 1
115 MySQLForceTildeExpansion 1
# MySQLTransactions On
129 MySQLTransactions On
###################################建立ftp用户组###################################
pw groupadd ftpusers -g 2000
pw useradd ftp -u 2000 -g ftpusers -s /sbin/nologin
#########################################添加ftp用户数据库#########################
upload
script.mysql
mysql -u root # < script.mysql
######################################script.mysql##################################
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','ftp',PASSWORD('e89120d9dfeb'),'Y','Y','Y','Y','N','N','N','N',
'N','N','N','N','N','N');
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)
) TYPE=MyISAM;
INSERT INTO admin VALUES ('Administrator',MD5('E89120D9DFEBtjyzhychb'));
CREATE TABLE users (
User char(16) NOT NULL default '',
Password char(32) binary NOT NULL default '',
Uid int(11) NOT NULL default '2000',
Gid int(11) NOT NULL default '2000',
Dir char(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',
status enum('0','1') NOT NULL default '1',
ipaccess varchar(15) NOT NULL default '*',
comment tinytext NOT NULL,
PRIMARY KEY (User),
UNIQUE KEY User (User)
) TYPE=MyISAM;
INSERT INTO `users` VALUES ('test1',MD5('123456'),2001,2000,'/home/test1',500,30,80,5,1,'*','*');
#################################################################################################
####################################启动pure-ftpd###################################
/usr/local/sbin/pure-config.pl /usr/local/etc/pure-ftpd.conf
提示一下信息证明pure-ftpd已经工作
Running: /usr/local/sbin/pure-ftpd -A -c50 -B -C8 -D -E -fftp -H -I15
-lmysql:/usr/local/etc/pureftpd-mysql.conf -L2000:8 -m4 -Q1:10 -s -U133:022
-u100 -Ow3c:/var/log/pureftpd.log -j -k99 -Z
####################################设置ftp管理界面################################
upload
chinaPHP_Manager
ee config.php
require 'language.php';
$LANG = $ZH_CN; // Language (Options are $DUTCH, $ENGLISH, $PT_BR, $RUSSIAN
// $SPANISH, $COREAN, $FRENCH, $HUNGARIAN, $GERMAN
// $TURKISH, $DANISH , $NORWEGIAN or $ZH_CN)
$LocationImages = "images"; // Location of images
$DBHost = "localhost"; // Ip-adres of MySQL server
// (Dont change this if you are using the default database)
$DBLogin = "ftp"; // Username of MySQL user
$DBPassword = "e89120d9dfeb"; // Password of MySQL user
$DBDatabase = "ftpusers"; // Name of database
$FTPAddress = "192.168.0.209:21"; // Domain name or ip-address of your ftp server
$DEFUserID = "2000"; // nobody // Default user id of virtual ftp user.
$DEFGroupID = "2000"; // guest // Default group is of virtual ftp user.
###############################设置ftp管理的虚拟主机##############################
ee /usr/local/etc/apache/httpd.conf
DocumentRoot "/web/ftp"
ServerName pureftp.tjhaina.net
deny from all
Options None
AllowOverride AuthConfig
Order deny,allow
ee /web/ftp/.htaccess
添加以下内容
AuthType Basic
AuthUserFile /usr/local/etc/pureftpd.passwd
AuthName FTP服务器后台管理登陆界面
require valid-user
satisfy any
cd /web/chinaPHP_Manager/ftp
chown www .htaccess
chmod 644 .htaccess
touch pureftpd.passwd
htpasswd -bc /usr/local/etc/pureftpd.passwd 用户名 123456
chmod 644 /usr/local/etc/pureftpd.passwd
#################################增加ftp启动项#####################################
ee /etc/rc.conf
add
pureftpd_enable="YES"