摘要 本文介绍一个非常好的ftp服务安装,实现了数据库管理和磁盘限额。只要稍微修改一下,就可以作为个人主业页服务器的服务平台!(文章参考了一些网上的文档,因为写的时间久了,记不起,希望不要见怪!)(2003-08-15 10:39:43)
By 光辉
Proftpd1.2.8+mysql3.23.56用户认证+quota磁盘限额
安装环境:redhat8,安装选择的是自定义,没选数据库和ftp部分(因为我们要自己编译,如果安装了也没问题,你可以rpm -qa|grep mysql ,然后rpm -e mysql*.rpm卸载掉 网上关于proftpd的安装文章实在是不少,我只是稍微整理了一下,并且使用了新的 quota磁盘限额模块,mysql选择3.23.56版。 首先下载源码 proftpd1.2.8: ftp://ftp.proftpd.org/上下载吧 ftp://ftp.proftpd.org/distrib/source/proftpd-1.2.8.tar.gz
mod_quotatab-1.2.7 http://www.castaglia.org/proftpd/modules/proftpd-mod-quotatab-1.2.7.tar.gz(对应proftpd1.2.8版本的) mysql3.23.56: http://www.mysql.com/downloads/mysql-3.23.html#Source 注意是下载源代码包(我一般喜欢自己编译) 全部下载到/root目录。
1,安装mysql3.23.56 #groupadd mysql #useradd -g mysql mysql #cd /root #tar -zxvf mysql-3.23.56.tar.gz #cd mysql-3.23.56 #./configure --prefix=/usr/local/mysql #make #make install #scripts/mysql_install_db #chown -R root /usr/local/mysql #chown -R mysql /usr/local/mysql/var #chgrp -R mysql /usr/local/mysql #cp support-files/my-medium.cnf /etc/my.cnf #/usr/local/mysql/bin/safe_mysqld --user=mysql &
2,安装proftpd 将proftpd的源码包解压缩到某临时目录下: localhost# tar -zxvf proftpd-1.2.8.tar.gz 解压缩 mod_quotatab-1.2.7 localhost# tar -zxvf proftpd-mod-quotatab-1.2.7.tar.gz 进入 mod_quotatab 目录 localhost proftpd# cd mod_quotatab 把mod_quotatab中的文件拷贝到 proftpd 中的modules 目录中 localhost mod_quotatab# cp * ../proftpd-1.2.8/modules 在开始运行configure之前,我们要先改动一个文件 进入 proftpd-1.2.8/contrib 目录 localhost mod_quotatab # cd ../proftpd-1.2.8/contrib 修改 mod_sql_mysql.c localhost contrib# vi mod_sql_mysql.c 找到#include 把他该为你实际路径 如果你的mysql 安装在/usr/local/mysql 下,就像我前面一样,就把它修改为#include 然后 localhost contrib# cd .. localhostproftpd-1.2.7#./configure --prefix=DIR --with-modules=mod_sql:mod_sql_mysql:mod_quotatab:mod_quotatab_sql --with-includes=DIR --with-libraries=DIR 需要修改的三个地方 --prefix=DIR 你要安装到哪里 --with-includes=DIR mysql 的includes 目录 --with-libraries=DIR mysql 的lib 目录 然后 make make install 完成安装
3.配置proftpd.conf 接下来,进入你安装好的proftpd目录 ,修改etc/proftpd.conf 文件开始配置 基本配置讲解: 示例:proftpd.conf ServerName "HRBEU''''s ftp server" #服务名 ServerType standalone #f服务器启动方式 DefaultServer 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 #limit the user in his owner directory DefaultRoot ~ #限制用户只能在自己的目录里,不能上去进入其他目录 #put the proftpd log files in /var/log/ftp.syslog SystemLog /data/logs/ftp.syslog #proftpd的系统日志存放地 #TransferLog log files TransferLog /data/logs/ftp.transferlog #传输日志存放地 #set The maxtimes user Attempts times MaxLoginAttempts 30 #当登陆失败后,可以尝试登陆的次数 #setup the Restart AllowRetrieveRestart on #setup the download and upload speed #TransferRate [kilobytes-per-sec[:100]] #1.2.8版本的速率限制 #setup the disk quota QuotaDirectoryTally on #quota b"|"Kb"|"Mb"|"Gb" #setup the disk quota #QuotaDirectoryTally on #quota b"|"Kb"|"Mb"|"Gb" QuotaDisplayUnits Kb QuotaEngine on QuotaLog /data/logs/Quota.log QuotaShowQuotas on # We put our mod_sql directives in a block so they''''ll be # inherited by the block below, and any other # blocks we may want to add. For a simple server these don''''t need to # be in a block but it won''''t hurt anything.
# Specify our connection information. Both mod_sql_mysql and # mod_sql_postgres use the same format, other backends may specify a # different format for the first argument to SQLConnectInfo. By not # specifying a fourth argument, we''''re defaulting to ''''PERSESSION'''' # connections -- a connection is made to the database at the start of # the session and closed at the end. This should be fine for most # situations. # SQLConnectInfo dbname@host:port username password SQLConnectInfo ftp@localhost:3306 wgh 58648217 # Specify our authentication schemes. Assuming we''''re using # mod_sql_mysql, here we''''re saying ''''first try to authenticate using # mysql''''s password scheme, then try to authenticate the user''''s # password as plaintext''''. Note that ''''Plaintext'''' isn''''t a smart way to # store passwords unless you''''ve got your database well secured. SQLAuthTypes Backend Plaintext # Specify the table and fields for user information. If you''''ve # created the database as it specifies in ''''README.mod_sql'''', you don''''t # need to have this directive at all UNLESS you''''ve elected not to # create some fields. In this case we''''re telling mod_sql to look in # table ''''users'''' for the fields ''''username'''',''''password'''',''''uid'''', and # ''''gid''''. The ''''homedir'''' and ''''shell'''' fields are specified as ''''NULL'''' -- # this will be explained below. # SQLUserInfo users username password uid gid NULL NULL SQLUserInfo FTPUSERS userid passwd uid gid home shell SQLGroupInfo FTPGRPS groupname gid members # Here we tell mod_sql that every user it authenticates should have # the same home directory. A much more common option would be to # specify a homedir in the database and leave this directive out. Note # that this directive is necessary in this case because we specified # the homedir field as ''''NULL'''', above. mod_sql needs to get homedir # information from *somewhere*, otherwise it will not allow access. # SQLDefaultHomedir "/tmp" # This is not a mod_sql specific directive, but it''''s here because of # the way we specified ''''SQLUserInfo'''', above. By setting this to # ''''off'''', we''''re telling ProFTPD to allow users to connect even if we # have no (or bad) shell information for them. Since we specified the # shell field as ''''NULL'''', above, we need to tell ProFTPD to allow the # users in even though their shell doesn''''t exist. RequireValidShell off # Here we tell mod_sql how to get out group information. By leaving # this commented out, we''''re telling mod_sql to go ahead and use the # defaults for the tablename and all the field names. # SQLGroupInfo groups groupname gid members # For small sites, the following directive will speed up queries at # the cost of some memory. Larger sites should read the complete # description of the ''''SQLAuthenticate'''' directive; there are options # here that control the use of potentially expensive database # queries. NOTE: these arguments to ''''SQLAuthoritative'''' limit the way # you can structure your group table. Check the README for more # information. SQLAuthenticate users # Finally, some example logging directives. If you have an integer # field named ''''count'''' in your users table, these directives will # automatically update the field each time a user logs in and display # their current login count to them. # SQLNamedQuery getcount SELECT "count, userid from users where userid=''''%u''''" # SQLNamedQuery updatecount UPDATE "count=count+1 WHERE userid=''''%u''''" users # SQLShowInfo PASS "230" "You''''ve logged on %{getcount} times, %u" # SQLLog PASS updatecount SQLHomedirOnDemand on #...SQL............... 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 quotalimits 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 quotatallies 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}''''" quotatallies
SQLNamedQuery insert-quota-tally INSERT "%{0}, %{1}, %{2}, %{3}, %{4}, %{5}, %{6}, %{7}" quotatallies
QuotaLimitTable sql:/get-quota-limit QuotaTallyTable sql:/get-quota-tally/update-quota-tally/insert-quota-tally # close our block.
#全局设置完成 # 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 normal user and group permissions for the server. User FTPUSR Group FTPGRP # Normally, we want files to be overwriteable.
AllowOverwrite on
# A basic anonymous configuration, no upload directories. If you # don''''t want to support anonymous access, simply remove this # ... block.
User ftp Group ftp # We want clients to be able to login with "anonymous" as well as "ftp" UserAlias anonymous ftp # Limit the maximum number of anonymous logins MaxClients 100 # We want ''''welcome.msg'''' displayed at login, and ''''.message'''' displayed # in each newly chdired directory. DisplayLogin welcome.msg DisplayFirstChdir .message # Limit WRITE everywhere in the anonymous chroot
DenyAll
4,mysql 用户认证部分
在proftpd.conf中加 [1] [2] 下一页 [MySql]PHP存取 Mysql 数据乱码终极解决方案 [MySql]解决Table xxx is marked as crashed and should … [MySql][MySQL]快速解决"is marked as crashed and shoul… [MySql]MySQL DELETE语法用法详解 [MySql]mysql中时间日期格式化 [MySql]修改mysql导入文件大小限制 [其他]MySql常用命令大全 [Web开发]把ACCESS的数据导入到Mysql中的方法详解 [MySql]解决mysql 1040错误Too many connections的方法 [系统软件]利用crontab系统每天定时备份MySQL数据库
|