安裝Pure-FTPd
cd /usr/ports/ftp/pure-ftpd
make install clean(選MYSQL、UTF-8)
cd /usr/local/etc
cp pure-ftpd.conf.sample pure-ftpd.conf
設定Pure-FTPd
vim pure-ftpd.conf
更改pure-ftpd.conf設定,我列出我所用到的設定:
ChrootEveryone yes # 限制每個用戶到自己的根目錄
# List dot-files even when the client doesn't send "-a".
DisplayDotFiles no #是否顯示.XXX記錄檔(隱藏系統檔)
# Disallow anonymous connections. Only allow authenticated users.
NoAnonymous yes # 不允許匿名用戶
NoAnonymous yes # 不允許匿名用戶
# MySQL configuration file (see README.MySQL)
MySQLConfigFile /usr/local/etc/pureftpd-mysql.conf #設定使用MySQL管理虛擬帳戶
# File creation mask. <umask for files>:<umask for dirs> .
# 177:077 if you feel paranoid.
Umask 133 :022 #文件權限:目錄,777-133=644:777-022=755
# Allow FXP transfers for authenticated users.
AllowUserFXP yes #允許使用者使用FTP傳輸軟體
# Automatically create home directories if they are missing
CreateHomeDir yes #當使用者第一次存取FTP空間時,會依據帳號自動創資料夾
以上設定好後,儲存離開。
建立MySQL設定檔
vim pureftpd-mysql.conf
# If you want to use the Socket connect methode comment out the
# Lines with MMYSQLServer and MYSQLPort.
# If you want to use the Port methode comment out the MYSQLSocket line
#MYSQLSocket /var/lib/mysql/mysql.sock
MYSQLServer localhost
MYSQLPort 3306
MYSQLUser ftp #MySQL使用者 最好是設定非root
MYSQLPassword ftpuser #密碼
MYSQLDatabase pureftpd
MYSQLCrypt cleartext
MYSQLGetPW SELECT Password FROM ftpd WHERE User="\L" AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R")
MYSQLGetUID SELECT Uid FROM ftpd WHERE User="\L" AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R")
MYSQLGetGID SELECT Gid FROM ftpd WHERE User="\L"AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R")
MYSQLGetDir SELECT Dir FROM ftpd WHERE User="\L"AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R")
MySQLGetBandwidthUL SELECT ULBandwidth FROM ftpd WHERE User="\L"AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R")
MySQLGetBandwidthDL SELECT DLBandwidth FROM ftpd WHERE User="\L"AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R")
MySQLGetQTASZ SELECT QuotaSize FROM ftpd WHERE User="\L"AND status="1"
MySQLGetQTAFS SELECT QuotaFiles FROM ftpd WHERE User="\L"AND status="1"
這樣Pure-FTPd就都設定好了,接著新建一個存放Pure-FTPd使用者帳號的pureftpd資料庫。
DROP TABLE IF EXISTS ftpd;CREATE TABLE ftpd (
User varchar(16) NOT NULL default '',
status enum('0','1') NOT NULL default '0',
Password varchar(64) NOT NULL default '',
Uid varchar(11) NOT NULL default '-1',
Gid varchar(11) NOT NULL default '-1',
Dir varchar(128) NOT NULL default '',
ULBandwidth smallint(5) NOT NULL default '0',
DLBandwidth smallint(5) NOT NULL default '0',
comment tinytext NOT NULL,
ipaccess varchar(15) NOT NULL default '*',
QuotaSize smallint(5) NOT NULL default '0',
QuotaFiles int(11) NOT NULL default 0,
PRIMARY KEY (User),
UNIQUE KEY User (User)
) TYPE=MyISAM;
設定開機自動啟動
vim /etc/rc.conf
加入pureftpd_enable="YES"
/usr/local/etc/rc.d/pure-ftpd start
資料庫欄位意義:
User: 使用者名稱status: 使用者狀態,1為可登入,0為不可登入
Password: 密碼
UID: 系統的 UID,要大於100以上(Uid,Gid會影響上傳下載權限,基本上是都設一樣)
GID: 系統的 GID,要大於100以上
Dir: 登入系統的使用者目錄
ULBandwidth: 上傳頻寬,單位 KB/s
DLBandwidth: 下載頻寬,單位 KB/s
comment: 使用者身份簡介說明
ipaccess: 連線來源 IP限制,* 為不限制
QuotaSize:家目錄的大小限制,單位 MB,0為不限制
QuotaFiles: 檔案數量限制,0為不限制
後記:關於使用FTP傳輸軟體以外的方式上傳中文檔名會變成亂碼,目前還未找到解決方法,但是使用FTP傳輸軟體就無此問題。
沒有留言:
張貼留言