百独托管7500 紫田网络超高转化播放器收cps[推荐]速盾CDN 免实名免备防屏蔽阿里云 爆款特卖9.9元封顶提升alexa、IP流量7Q5团队
【腾讯云】中小企福利专场【腾讯云】多款产品1折起高防 随时退换 好耶数据小飞国外网赚带你月入万元炎黄网络4H4G10M 99每月
香港带宽CN2/美国站群优惠中客数据中心 服务器租用联盟系统移动广告平台 中易企业专场腾讯云服务器2.5折九九数据 工信部正规资质
腾讯云新用户大礼包代金券高价收cpa注册量高价展示【腾讯云】2核2G/9.93起租服务器找45互联 随时退换阿里云 短信服务 验证秒达

[其它内容] 美国VPS使用数据库管理FTP用户 [复制链接]
查看:758 | 回复:6

71

主题

86

帖子

2

积分

落伍者(一心一意)

Rank: 1

贡献
27
鲜花
1
注册时间
2012-7-5
发表于 2012-11-18 22:44:40 | |阅读模式 来自 中国广东东莞
在安装ProFTPd与配置MySQL虚拟用户之前,请确保你的系统已经正常运行MySQL服务器。曰本VPS vps.gl/jpvps/

编译安装ProFTPd
wget ftp:  ftp-stud.fht-esslingen.de/pub/Mirrors/ftp.proftpd.net/distrib/source/proftpd-1.3.1.tar.gz
tar xzvf proftpd-1.3.1.tar.gz
cd proftpd-1.3.1
./configure –with-modules=mod_sql:mod_sql_mysql:mod_quotatab:mod_quotatab_sql \
–with-includes=/usr/include/mysql \
–with-libraries=/usr/lib/mysql
make && make install
请根据你的MySQL安装路径修改–with-includes和–with-libraries的参数。

添加ftp用户和用户组
groupadd -g 5500 ftpgroup
adduser -u 5500 -s /bin/false -d /bin/null -c “proftpd user” -g ftpgroup ftpuser
MySQL配置
登录MySQL并创建数据库。

mysql -u root -p
create database ftpdb;
grant select, insert, update on ftpdb.* to proftpd@localhost identified by ‘password’;
use ftpdb;
#
# Table structure for table `ftpgroup`
#
CREATE TABLE ftpgroup (
groupname varchar(16) NOT NULL default ”,
gid smallint(6) NOT NULL default ’5500′,
members varchar(16) NOT NULL default ”,
KEY groupname (groupname)
) TYPE=MyISAM COMMENT=’ProFTP group table’;
#
# Dumping data for table `ftpgroup`
#
INSERT INTO `ftpgroup` VALUES (‘ftpgroup’, 5500, ‘ftpuser’);
INSERT INTO `ftpgroup` VALUES (‘ftpgroup’, 5500, ‘ftpguest’);
CREATE TABLE `ftpquotatallies` (
`name` varchar(30) NOT NULL default ”,
`quota_type` enum(‘user’,'group’,'class’,'all’) NOT NULL default ‘user’,
`bytes_in_used` float NOT NULL default ’0′,
`bytes_out_used` float NOT NULL default ’0′,
`bytes_xfer_used` float NOT NULL default ’0′,
`files_in_used` int(10) unsigned NOT NULL default ’0′,
`files_out_used` int(10) unsigned NOT NULL default ’0′,
`files_xfer_used` int(10) unsigned NOT NULL default ’0′
) TYPE=MyISAM;
# ——————————————————–
#
# Table structure for table `ftpuser`
#
CREATE TABLE ftpuser (
id int(10) unsigned NOT NULL auto_increment,
userid varchar(32) NOT NULL default ”,
passwd varchar(32) NOT NULL default ”,
uid smallint(6) NOT NULL default ’5500′,
gid smallint(6) NOT NULL default ’5500′,
homedir varchar(255) NOT NULL default ”,
shell varchar(16) NOT NULL default ‘/sbin/nologin’,
count int(11) NOT NULL default ’0′,
accessed datetime NOT NULL default ’0000-00-00 00:00:00′,
modified datetime NOT NULL default ’0000-00-00 00:00:00′,
PRIMARY KEY (id),
UNIQUE KEY userid (userid)
) TYPE=MyISAM COMMENT=’ProFTP user table’;
INSERT INTO `ftpuser` VALUES (1, ‘testaccount’, ‘ftppasswd’, 5500, 5500, ‘/home/testdomain.com’, ‘/sbin/nologin’,0,”,”);
exit;
proftpd配置文件
要目录下建proftpd.conf配置文件,请在下面的代码修改好MySQL数据库登录信息。

ServerName “Khoosys Proftpd Server”
ServerType Standalone
ServerAdmin stephen@khoosys.net
# Hide as much as possible to outside users
ServerIdent on “Welcome to the Khoosys FTP server. Please login…”
DeferWelcome on
DefaultServer on
# Allow FTP resuming.
# Remember to set to off if you have an incoming ftp for upload.
AllowStoreRestart on
# Port 21 is the standard FTP port.
Port 21
# Umask 022 is a good standard umask to prevent new dirs and files
# from being group and world writable.
Umask 022
# To prevent DoS attacks, set the maximum number of child processes
# to 30. If you need to allow more than 30 concurrent connections
# at once, simply increase this value. Note that this ONLY works
# in standalone mode, in inetd mode you should use an inetd server
# that allows you to limit maximum number of processes per service
# (such as xinetd).
MaxInstances 30
# Set the user and group under which the server will run.
User ftpuser
Group ftpgroup
# To cause every FTP user to be “jailed” (chrooted) into their home
# directory, uncomment this line.
DefaultRoot ~
# Normally, we want files to be overwriteable.
AllowOverwrite on
# The passwords in MySQL are encrypted using CRYPT
SQLAuthTypes Plaintext Crypt
SQLAuthenticate users* groups*
# used to connect to the database
# databasename@host database_user user_password
SQLConnectInfo ftpdb@localhost proftpd password
# Here we tell ProFTPd the names of the database columns in the “usertable”
# we want it to interact with. Match the names with those in the db
SQLUserInfo ftpuser userid passwd uid gid homedir shell
# Here we tell ProFTPd the names of the database columns in the “grouptable”
# we want it to interact with. Again the names match with those in the db
SQLGroupInfo ftpgroup groupname gid members
# set min UID and GID – otherwise these are 999 each
SQLMinID 500
# create a user’s home directory on demand if it doesn’t exist
SQLHomedirOnDemand on
# Update count every time user logs in
SQLLog PASS updatecount
SQLNamedQuery updatecount UPDATE “count=count+1, accessed=now() WHERE userid=’%u’” ftpuser
# Update modified everytime user uploads or deletes a file
SQLLog STOR,DELE modified
SQLNamedQuery modified UPDATE “modified=now() WHERE userid=’%u’” ftpuser
# User quotas
# ===========
QuotaEngine on
QuotaDirectoryTally on
QuotaDisplayUnits Mb
QuotaShowQuotas on
SQLNamedQuery get-quota-limit SELECT “name, quota_type, per_session, limit_type, bytes_in_avail, bytes_out_avail, bytes_xfer_avail, files_in_avail, files_out_avail, files_xfer_avail FROM ftpquotalimits WHERE name = ‘%{0}’ AND quota_type = ‘%{1}’”
SQLNamedQuery get-quota-tally SELECT “name, quota_type, bytes_in_used, bytes_out_used, bytes_xfer_used, files_in_used, files_out_used, files_xfer_used FROM ftpquotatallies WHERE name = ‘%{0}’ AND quota_type = ‘%{1}’”
SQLNamedQuery update-quota-tally UPDATE “bytes_in_used = bytes_in_used + %{0}, bytes_out_used = bytes_out_used + %{1}, bytes_xfer_used = bytes_xfer_used + %{2}, files_in_used = files_in_used + %{3}, files_out_used = files_out_used + %{4}, files_xfer_used = files_xfer_used + %{5} WHERE name = ‘%{6}’ AND quota_type = ‘%{7}’” ftpquotatallies
SQLNamedQuery insert-quota-tally INSERT “%{0}, %{1}, %{2}, %{3}, %{4}, %{5}, %{6}, %{7}” ftpquotatallies
QuotaLimitTable sql:/get-quota-limit
QuotaTallyTable sql:/get-quota-tally/update-quota-tally/insert-quota-tally
RootLogin off
RequireValidShell off
proftpd启动文件
创建/etc/init.d/proftpd文件,并写入下面的代码。美国VPS vps.gl/usavps/

#!/bin/sh
# $Id: proftpd.init,v 1.1 2004/02/26 17:54:30 thias Exp $
#
# proftpd This shell script takes care of starting and stopping
# proftpd.
#
# chkconfig: – 80 30
# description: ProFTPD is an enhanced FTP server with a focus towards \
# simplicity, security, and ease of configuration. \
# It features a very Apache-like configuration syntax, \
# and a highly customizable server infrastructure, \
# including support for multiple ‘virtual’ FTP servers, \
# anonymous FTP, and permission-based directory visibility.
# processname: proftpd
# config: /etc/proftp.conf
# pidfile: /var/run/proftpd.pid
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0
[ -x /usr/sbin/proftpd ] || exit 0
RETVAL=0
prog=”proftpd”
start() {
echo -n $”Starting $prog: “
daemon proftpd
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/proftpd
}
stop() {
echo -n $”Shutting down $prog: “
killproc proftpd
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/proftpd
}
# See how we were called.
case “$1″ in
start)
start
;;
stop)
stop
;;
status)
status proftpd
RETVAL=$?
;;
restart)
stop
start
;;
condrestart)
if [ -f /var/lock/subsys/proftpd ]; then
stop
start
fi
;;
reload)
echo -n $”Re-reading $prog configuration: “
killproc proftpd -HUP
RETVAL=$?
echo
;;
*)
echo “Usage: $prog {start|stop|restart|reload|condrestart|status}”
exit 1
esac
exit $RETVAL
chmod 755 /etc/init.d/proftpd
之后,我们可以使用
service proftpd (start|stop|restart|reload|condrestart|status)来管理proftpd服务器。

测试proftpd
之前在配置MySQL的时候,我们添加了测试帐号testaccount和密码ftppasswd,可以用这个帐号来测试proftpd是否运行正常。VPS代理 vps.gl/dealer/
头像被屏蔽

1

主题

6152

帖子

-3

积分

禁访

贡献
76
鲜花
0
注册时间
2012-11-14
发表于 2012-11-19 08:01:01 | 来自 中国辽宁沈阳
提示: 作者被禁止或删除 内容自动屏蔽
签名被屏蔽

3

主题

756

帖子

-3

积分

接近落伍(少量栏能发帖)

贡献
76
鲜花
0
注册时间
2012-9-26
发表于 2012-11-20 23:03:42 | 来自 中国湖北武汉
太长了。。没看。。直接复制了
http://mdgcyy.com
头像被屏蔽

1

主题

129

帖子

-4

积分

禁言

贡献
117
鲜花
0
注册时间
2012-10-4
发表于 2012-11-22 22:09:28 | 来自 中国福建福州
提示: 作者被禁止或删除 内容自动屏蔽
签名被屏蔽
头像被屏蔽

50

主题

3256

帖子

474

积分

禁言

贡献
535
鲜花
0
注册时间
2012-10-29
发表于 2012-11-23 17:15:32 | 来自 中国湖北武汉
提示: 作者被禁止或删除 内容自动屏蔽
签名被屏蔽

68

主题

1430

帖子

1238

积分

落伍者(两全齐美)

Rank: 2

贡献
1308
鲜花
2
注册时间
2005-10-10

落伍手机绑定

发表于 2012-11-23 19:13:18 | 来自 中国浙江温州
学习中!
书法学习网http://www.wzxx.org
爱好乒乓网http://www.ihpp.net
论坛客服/商务合作/投诉举报:2171544 (QQ)
落伍者创建于2001/03/14,本站内容均为会员发表,并不代表落伍立场!
拒绝任何人以任何形式在本论坛发表与中华人民共和国法律相抵触的言论!
落伍官方微信:2030286 邮箱:(djfsys@gmail.com|tech@im286.com)
© 2001-2014

浙公网安备 33060302000191号

浙ICP备11034705号 BBS专项电子公告通信管[2010]226号

  落伍法律顾问: ITlaw-庄毅雄

手机版|找回帐号|不能发帖?|Archiver|落伍者

GMT+8, 2024-6-6 04:06 , Processed in 0.160496 second(s), 36 queries , Gzip On.

返回顶部