proftpd+mysql+quota

來源:互聯網
上載者:User
發現網上很多兄弟都在為安裝proftpd+mysql+quota的種種問題苦惱。
我就整理一下我的安裝過程,當然也不是原創了。也提供了相關軟體包永久下載
,mysql/php/apache安裝就免了。我的mysql是使用源碼安裝!
相關軟體:
---------------------------------------------------------------
proftpd-1.2.9.tar.gz
proftpd-mod-quotatab-1.2.11.tar.gz
ftpdb.sql
proftpd.conf

---------------------------------------------------------------
步驟如下:

代碼:
vi /etc/ld.so.conf
添加:/usr/local/mysql/lib

tar zvxf proftpd-1.2.9.tar.gz
tar zvxf proftpd-mod-quotatab-1.2.11.tar.gz
cp mod_quotatab/*.c proftpd-1.2.9/contrib/
cp mod_quotatab/*.h proftpd-1.2.9/contrib/
vi proftpd-1.2.9/contrib/mod_sql_mysql.c
#include</usr/local/mysql/include/mysql.h>
修改mysql.h的實際路徑
cd proftpd-1.2.9
./configure \--prefix=/usr/local/proftpd \--with-modules=mod_sql:mod_sql_mysql:mod_quotatab\:mod_quotatab_sql:mod_ratio \--with-includes=/usr/local/mysql/include \--with-libraries=/usr/local/mysql/lib
make
make install
cp proftpd-1.2.9/contrib/dist/rpm/proftpd.init.d /etc/rc.d/init.d/proftpd
vi /etc/rc.d/init.d/proftpd
修改:PATH="$PATH:/usr/local/proftpd/sbin"
chmod 755 /etc/rc.d/init.d/proftpd
chkconfig --level 3 proftpd on
groupadd -g 5500 ftpgroup
adduser -u 5500 -s /bin/false -d /bin/null -c "proftpd user" -g ftpgroup ftpuser
然後配置你的Proftpd.conf
最後就是啟動啦。/usr/local/proftpd/sbin/proftpd

-------------------------------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         "ltsnet"
ServerType         standalone
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

# 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            nobody
Group            nobody

# To cause every FTP user to be "jailed" (chrooted) into their home
# directory, uncomment this line.
ServerIdent off
DisplayLogin welcome.msg
DefaultRoot ~
# Normally, we want files to be overwriteable.
<Directory />
  AllowOverwrite      on
</Directory>

# A basic anonymous configuration, no upload directories.  If you do not
# want anonymous users, simply delete this entire <Anonymous> section.
<Anonymous /home/ftp>
  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         10

  # 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
  <Limit WRITE>
    DenyAll
  </Limit>
</Anonymous>

SQLAuthTypes Backend Plaintext
SQLAuthenticate users* groups*

SQLConnectInfo ftpdb@localhost root 123456
SQLUserInfo ftpuser userid passwd uid gid homedir shell
SQLGroupInfo ftpgroup groupname gid members
SQLHomedirOnDemand on
SQLLog PASS updatecount
SQLNamedQuery updatecount UPDATE "count=count+1,accessed=now() WHERE userid='%u'" ftpuser
SQLLog STOR,DELE modified
SQLNamedQuery modified UPDATE "modified=now() WHERE userid='%u'" ftpuser

QuotaEngine on
QuotaDirectoryTally on
QuotaDisplayUnits Mb
QuotaShowQuotas on
QuotaLog "/var/log/quota"
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

建ftpdb庫,在phpMyAdmin中匯入ftpdb.sql就ok。
--------------------------------------ftpdb.sql---------------------------------

代碼:
# 表的結構 `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';

#
# 匯出表中的資料 `ftpgroup`
#

INSERT INTO `ftpgroup` VALUES ('ftpgroup', 5500, 'ftpuser');

# --------------------------------------------------------

#
# 表的結構 `ftpquotalimits`
#

CREATE TABLE `ftpquotalimits` (
  `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'
) TYPE=MyISAM;

#
# 匯出表中的資料 `ftpquotalimits`
#

INSERT INTO `ftpquotalimits` VALUES ('test', 'user', 'true', 'hard', '9e+06', '2000', '9e+09', 2000, 2000, 2000);

# --------------------------------------------------------

#
# 表的結構 `ftpquotatallies`
#

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;

#
# 匯出表中的資料 `ftpquotatallies`
#

INSERT INTO `ftpquotatallies` VALUES ('test', 'user', '2000', '2000', '2000', 2000, 2000, 2000);

# --------------------------------------------------------

#
# 表的結構 `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`)
) TYPE=MyISAM COMMENT='ProFTP user table' AUTO_INCREMENT=3 ;

#
# 匯出表中的資料 `ftpuser`
#

INSERT INTO `ftpuser` VALUES (1, 'test', '123456', 5500, 5500, '/home/test', '/sbin/nologin', 36, '2004-09-28 13:07:41', '2004-09-28 13:07:42');

quotalimits表

代碼:
name: - 使用者帳號
quota type: - user, group, class, all (we use user)
per_session: - true or false (we use true)
limit_type: - 硬限制 or 軟式節流 (我們一般用硬限制)
bytes_in_avail: - 允許上傳的位元組數
bytes_out_avail: - 允許下載的位元組數
bytes_xfer_avail: - 允許傳輸的位元組數(包括上傳/下載)
files_in_avail: - 允許上傳的檔案數
files_out_avail: - 允許下載的檔案數
files_xfer_avail: - 允許傳輸的檔案數(包括上傳/下載)


按這些步驟來安裝,應該沒問題。老實說用mysql和quota模組來驗證使用者和設定磁碟限額,但我總覺得還是不夠完善,因為在這個方法中,資料庫表裡還沒有相應的許可權的欄位,所以說相應使用者的許可權還是得用實際得使用者即mysql對應得uid和gid來控制許可權,那天要是mysql資料庫也能完全控制許可權就好了。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.