內容有點亂,回頭有空再整理mysql
yum -y install MariaDB-client MariaDB-server MariaDB-devel
./configure --prefix=/usr/local/pureftpd --with-cookie --with-throttling --with-ratios --with-quotas --with-sysquotas --with-largefile --with-welcomemsg --with-uploadscript --with-virtualhosts --with-virtualroot --with-virtualchroot --with-diraliases --with-peruserlimits --with-language=simplified-chinese --with-mysql --with-paranoidmsg --with-altlog make && make install
cd configuration-file cp pure-config.pl /usr/local/pureftpd/bin/. chmod 755 /usr/local/pureftpd/bin/pure-config.pl mkdir /usr/local/pureftpd/etc //新建FTP的配置文件夾目錄 cp pure-ftpd.conf /usr/local/pureftpd/etc/. //複製ftp配置文件到etc中 cd .. //切換到/pure-ftpd-1.0.22目錄中 cp pureftpd-ldap.conf /usr/local/pureftpd/etc/. //相關配置文件複製到etc中 cp pureftpd-mysql.conf /usr/local/pureftpd/etc/. //相關配置文件複製到etc中 cp pureftpd-pgsql.conf /usr/local/pureftpd/etc/. //相關配置文件複製到etc中
vi /usr/local/pureftpd/etc/pureftpd-mysql.conf
MYSQLSocket /tmp/mysql.sock #MYSQLServer localhost #MYSQLPort 3306 MYSQLUser pureftpd MYSQLPassword 這裏輸入前面給mysql受權時的密碼 MYSQLDatabase pureftpd #MYSQLCrypt md5, cleartext, crypt() or password() - md5 is VERY RECOMMENDABLE uppon cleartext MYSQLCrypt md5 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" AND (ipaccess = "*" OR ipaccess LIKE "\R") MySQLGetQTAFS SELECT QuotaFiles FROM ftpd WHERE User="\L"AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R")
vi /usr/local/pureftpd/etc/pure-ftpd.conf
ChrootEveryone yes MySQLConfigFile /usr/local/pureftpd/etc/pureftpd-mysql.conf CreateHomeDir yes
# groupadd ftpgroup –g 1000 # useradd ftpuser –g ftpgroup –u 1000 –d /data/ftp –s /sbin/nologin
CREATE DATABASE pureftpd; GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP ON pureftpd.* TO 'pureftpd'@'localhost' IDENTIFIED BY '對應的密碼'; GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP ON pureftpd.* TO 'pureftpd'@'localhost.localdomain' IDENTIFIED BY '對應的密碼'; FLUSH PRIVILEGES; USE pureftpd; 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;
數據表說明: User:賬號名; status:0 表示賬號被禁用,沒法登陸服務器; Password:密碼,使用MD5加密; Uid:前面建立的ftpuser賬戶號,咱們填寫的是2001; Gid:前面建立的ftpgroup組號,咱們填寫的是2001; Dir:虛擬用戶的我的目錄路徑,將在/home下建立(第一次登陸); ULBandwidth:上傳文件限制速度,KB/s,0爲不限制; DLBandwidth:下載文件限制速度,KB/s,0爲不限制; comment:備註信息; ipaccess:* 表示任意IP均可以訪問此ftp服務器,輸入具體IP地址能夠只容許此IP鏈接服務器; QuotaSize:用戶磁盤空間分配,單位:MB,0表示不加限制; QuotaFiles:用戶能夠保存的文件數量限制,0表示不加限制。
vi /etc/init.d/pureftpd
#!/bin/sh # # ScriptName: /etc/init.d/pureftpd # chkconfig: - 60 50 # description: pureftpd is a ftp daemon, which is the program \ # that answers incoming ftp service requests. # processname: pureftpd # # Author : cnscn # Time : 2006-04-18 09:30 # #tput func funcTput() { tput init for args do case "$args" in green_black) echo -e -n "\033[;32m" ;; red_black) echo -e -n "\033[;31m" ;; endtput) tput sgr0 esac done } case "$1" in start) ps aux | grep pure-ftp | grep -v grep > /dev/null 2>&1 if [ $? -eq 0 ] then echo -n "Pureftpd has already been running ... " funcTput red_black echo "[failed]" funcTput endtput exit 1 fi echo -n "start pureftpd.... " /usr/local/pureftpd/bin/pure-config.pl /usr/local/pureftpd/etc/pure-ftpd.conf > /dev/null 2>&1 if [ $? -eq 0 ] ; then funcTput green_black echo " [OK]" funcTput endtput else funcTput red_black echo " [Failed] "; funcTput endtput fi ;; stop) ps aux | grep pure-ftp | grep -v grep > /dev/null 2>&1 if [ $? -eq 1 ] then echo -n "Pureftpd has not been runned now ... " funcTput red_black echo "[failed]" funcTput endtput exit 1 fi echo -n "Stop pureftpd... " killall pure-ftpd > /dev/null 2>&1 if [ $? -eq 0 ] ; then funcTput green_black echo " [OK]" funcTput endtput else funcTput red_black echo " [Failed] "; funcTput endtput fi ;; restart) ps aux | grep pure-ftp | grep -v grep > /dev/null 2>&1 if [ $? -eq 0 ] then echo -n "Stop pureftpd... " killall pure-ftpd > /dev/null 2>&1 if [ $? -eq 0 ] ; then funcTput green_black echo " [OK]" funcTput endtput else funcTput red_black echo " [Failed] "; funcTput endtput fi fi echo -n "start pureftpd.... " /usr/local/pureftpd/bin/pure-config.pl /usr/local/pureftpd/etc/pure-ftpd.conf >/dev/null 2>&1 if [ $? -eq 0 ] ; then funcTput green_black echo " [OK]" funcTput endtput else funcTput red_black echo " [Failed] "; funcTput endtput fi ;; *) echo "Usage: `basename $0` {start | stop | restart}" ;; esac exit 0