歡迎您光臨本站 註冊首頁

安裝proftpd1.3.0a和mysql認證及磁碟限額時出先mysql錯誤

←手機掃碼閱讀     火星人 @ 2014-03-04 , reply:0

安裝proftpd1.3.0a和mysql認證及磁碟限額時出先mysql錯誤

我寫以下安裝過程:
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的資料庫;
  # 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;然後通過下面的命令來導入;
  # 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 "^()'+$"
  #PathAllowFilter "^()'+$"
  # We don't want .ftpaccess or .htaccess files to be uploaded
  #PathDenyFilter "(\.ftp)|(\.ht)+$"
  #pathDenyFilter "\.ftp+$"
  # Do not allow to pass printf-Formats (security! see documentation!):
  #AllowFilter "^*$"
  #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 編輯 ]

[火星人 ] 安裝proftpd1.3.0a和mysql認證及磁碟限額時出先mysql錯誤已經有585次圍觀

http://coctec.com/docs/service/show-post-36568.html