免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2593 | 回复: 0
打印 上一主题 下一主题

[FTP] 安装proftpd1.3.0a和mysql认证及磁盘限额时出先mysql错误 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-08-16 13:56 |只看该作者 |倒序浏览
我写以下安装过程:
1、编译前准备
vi contrib/mod_sql_mysql.c
#找到#include <mysql.h>这一行,将mysql.h改成系统中此文件所在的路径,如/usr/local/mysql/include/mysql/mysql.h
2、编译过程
tar zxvf proftpd-1.3.0a.tar.gz
cd proftpd-1.3.0rc3
./configure --prefix=/usr/loca/proftpd
                 --with-modules=mod_sql:mod_sql_mysql:mod_quotatab:mod_quotatab_sql \
                 --with-includes=/usr/local/mysql/includes/mysql \
                 --with-libraries=/usr/local/mysql/lib/mysql \
make
make install
3、插入数据库
3.1、创建一个ProFTPD的数据库proftpd;
  首先您应该会把MySQL数据库服务器打开,以MySQL的超级管理员root进入创建名为proftpd的数据库;
  [root@localhost ~]# mysql -u root -p
  Enter password: 注:在这里请您输入MySQL的管理密码;
  Welcome to the MySQL monitor. Commands end with ; or \g.
  Your MySQL connection id is 41 to server version: 4.1.11
  Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
  mysql>create database proftpd;
  mysql>Grant select,insert,update,delete,create,drop,index,alter,create
  temporary tables,lock tables on proftpd.* to proftpd@localhost Identified by
  "123456";
  mysql>quit
  说明:
  create database proftpd; 这行是创建名为proftpd的数据库;
  Grant 这行是为proftpd
  数据库授权,让用户名为proftpd,密码为123456(这只是一个例子,密码自己定义),这个用来管理proftpd这个数据库;
  quit 这行是退出mysql界面;
  3.2、导入proftpd数据库;
  下面是一个现成的数据库,你只需要导入就行了,比较简单;把下面的代码拷贝下来,然后另存为 proftpd.sql;然后通过下面的命令来导入;
  [root@localhost ~]# mysql -uproftpd -p proftpd <proftpd.sql
  Enter password: 在这里输入proftpd 数据库管理员proftpd 的密码,我们前面举例是123456,以你设置的为准;
  下面是proftpd的数据库,您可以拷贝下来,另存为 proftpd.sql ,然后用上面的命令来导入;
  -- 数据库: `proftpd`
  --
  -- --------------------------------------------------------
  --
  -- 表的结构 `ftpgroups`
  --
  CREATE TABLE `ftpgroups` (
    `groupname` varchar(30) NOT NULL default '',
    `gid` int(11) NOT NULL default '1000',
    `members` varchar(255) NOT NULL default ''
  ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
  -- --------------------------------------------------------
  --
  -- 表的结构 `ftpusers`
  --
  CREATE TABLE `ftpusers` (
    `userid` varchar(30) NOT NULL default '',
    `passwd` varchar(80) NOT NULL default '',
    `uid` int(10) unsigned NOT NULL default '1000',
    `gid` int(10) unsigned NOT NULL default '1000',
    `homedir` varchar(255) NOT NULL default '',
    `shell` varchar(255) NOT NULL default '/sbin/nologin',
    `count` int(10) unsigned NOT NULL default '0',
    `host` varchar(30) NOT NULL default '',
    `lastlogin` varchar(30) NOT NULL default '',
    UNIQUE KEY `userid` (`userid`)
  ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
  --
  -- 导出表中的数据 `ftpusers`
  --
  INSERT INTO `ftpusers` VALUES ('test', 'test', 1000, 1000, '/home/test',
  '/sbin/nologin',0,'','');
  -- --------------------------------------------------------
  --
  -- 表的结构 `quotalimits`
  --
  CREATE TABLE `quotalimits` (
    `name` varchar(30) default NULL,
    `quota_type` enum('user','group','class','all') NOT NULL default 'user',
    `per_session` enum('false','true') NOT NULL default 'false',
    `limit_type` enum('soft','hard') NOT NULL default 'soft',
    `bytes_in_avail` float NOT NULL default '0',
    `bytes_out_avail` float NOT NULL default '0',
    `bytes_xfer_avail` float NOT NULL default '0',
    `files_in_avail` int(10) unsigned NOT NULL default '0',
    `files_out_avail` int(10) unsigned NOT NULL default '0',
    `files_xfer_avail` int(10) unsigned NOT NULL default '0'
  ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
  -- --------------------------------------------------------
  --
  -- 表的结构 `quotatallies`
  --
  CREATE TABLE `quotatallies` (
    `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'
  ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
4、编辑proftpd.conf
# This is a basic ProFTPD configuration file (rename it to
  # 'proftpd.conf' for actual use. It establishes a single server
  # and a single anonymous login. It assumes that you have a user/group
  # "nobody" and "ftp" for normal operation and anon.
  ServerName "My TestFTP" #这是您的FTP服务器的名字,自己写定
  ServerType standalone
  ServerAdmin xxxxx@xxxxxxxxxxx.com #这是管理员信箱,自己来写;
  DefaultServer On
  # Display message
  DisplayLogin /opt/proftpd/etc/ftplogin.msg
  #DisplayConnect /net/messages/ftp.pre
  #DisplayFirstChdir index.txt
  # Port 21 is the standard FTP port.
  Port 21
  # Limit users to login by username
  <Limit LOGIN>
  AllowAll
  </Limit>
  # Umask 022 is a good standard umask to prevent new dirs and files
  # from being group and world writable.
  Umask 022
  # Limit login attempts
  #
  MaxLoginAttempts 5
  # Set the maximum number of seconds a data connection is allowed
  # to "stall" before being aborted.
  TimeoutStalled 600
  TimeoutLogin 900
  TimeoutIdle 600
  TimeoutNoTransfer 600
  # Set the user and group under which the server will run.
  User nobody
  Group nobody
  # To cause every FTP user to be "jailed" (chrooted) into their home
  # directory, uncomment this line.
  DefaultRoot ~
  # Users needs a valid shell
  #
  RequireValidShell off
  # Performance: skip DNS resolution when we process the logs...
  UseReverseDNS off
  # Turn off Ident lookups
  IdentLookups off
  # Restart session support
  #
  AllowStoreRestart on
  AllowRetrieveRestart on
  #-------- load sql.mod for mysql authoritative --------#
  SQLConnectInfo proftpd@localhost proftpd 123456
  #注:上面这行是MySQL连接服务器部份,自己根据情况来改一改;
  SQLAuthTypes Plaintext
  SQLUserInfo ftpusers userid passwd uid gid homedir shell
  SQLGroupInfo ftpgroups groupname gid members
  SQLAuthenticate users groups
  SQLNegativeCache on
  SQLHomedirOnDemand on
  SQLLogFile /var/log/proftpd.sql.log
  SQLNamedQuery getcount SELECT "count from ftpusers where userid='%u'"
  SQLNamedQuery getlastlogin SELECT "lastlogin from ftpusers where userid='%u'"
  SQLNamedQuery updatelogininfo UPDATE "count=count+1,host='%h',lastlogin=current_timestamp() WHERE userid='%u'"  ftpusers
  SQLShowInfo PASS "230" "You've logged on %{getcount} times, last login at %{getlastlogin}"
  SQLLog PASS updatelogininfo
  #-------- load sql.mod for mysql authoritative --------#
  #--------- load qudes.mod for Quota limit --------#
  QuotaDirectoryTally on
  QuotaDisplayUnits "Mb"
  QuotaEngine on
  #QuotaLog /var/log/proftpd.quota.log
  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 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
  #--------- load qudes.mod for Quota limit --------#
  # Logging options
  # Debug Level
  # emerg, alert, crit (empfohlen), error, warn. notice, info, debug
  #
  SyslogLevel emerg
  SystemLog /var/log/proftpd.system.log
  TransferLog /var/log/proftpd.xferlog
  # Some logging formats
  #
  LogFormat default "%h %l %u %t \"%r\" %s %b"
  LogFormat auth "%v [%P] %h %t \"%r\" %s"
  LogFormat write "%h %l %u %t \"%r\" %s %b"
  # Log file/dir access
  # ExtendedLog /var/log/proftpd.access_log WRITE,READ write
  # Record all logins
  ExtendedLog /var/log/proftpd.auth_log AUTH auth
  # Paranoia logging level....
  ExtendedLog /var/log/proftpd.paranoid_log ALL default
  #注;上面几行是存放log的设置,不必改动也行;查看log就到上面相应的文件看吧;
  # 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 #注最多30个ip同时登录使用ftp;
  # Maximum clients with message
  #MaxClients 2 "Sorry, max %m users -- try again later"
  MaxClientsPerHost 2 "Sorry, only 2 session for one host"
  #注每个ip,只能两个线程程,请自己调整;
  # Normally, we want files to be overwriteable.
  <Directory />
    AllowOverwrite on
  </Directory>
  RootLogin off
  RequireValidShell off
  # alphanumeric characters for uploads (and not shell code...)
  #PathAllowFilter "^[a-zA-Z0-9_.-]()'+$"
  #PathAllowFilter "^[a-zA-Z0-9 _.-]()'+$"
  # We don't want .ftpaccess or .htaccess files to be uploaded
  #PathDenyFilter "(\.ftp)|(\.ht)[a-z]+$"
  #pathDenyFilter "\.ftp[a-z]+$"
  # Do not allow to pass printf-Formats (security! see documentation!):
  #AllowFilter "^[a-zA-Z0-9@~ /,_.-]*$"
  #DenyFilter "%"
5、出现的问题
在安装过程中没有出现错误
启动proftpd以后出现拒绝连接,查看/var/log/proftpd_sql_mysql.log时发现mysql数据库连接出现出错
就是mysql.sock连不上。(我的mysql是4.1.22安装在/usr/local/mysql)
请问各位,不知道问题出在哪里??????????????????

[ 本帖最后由 nbslr 于 2007-8-16 16:16 编辑 ]
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP