pure-ftpd的安裝和使用

一,系統支持
系統中需要安裝有 Mysql+Apache+Dns(可選).
二,準備軟件
Ftpd Server :
pure-ftpd-1.0.20.tar.gz
pureftpd_php_manager:
pureftpd_php_manager.tar.gz

三,定製安裝
1:解壓縮
到下載的兩個文件所在目錄.
#cd download
#tar zxvf pure-ftpd-1.0.20.tar.gz
#tar zxvf pureftpd_php_manager.tar.gz
2:編譯
#cd pure-ftpd-1.0.20

#./configure /
--prefix=/usr/local/pureftpd /
--with-mysql=/usr/local/mysql /
--with-paranoidmsg /
--with-shadow /
--with-welcomemsg /
--with-uploadscript /
--with-quotas /
--with-cookie /
--with-pam /
--with-virtualhosts /
--with-virtualroot /
--with-diraliases /
--with-sysquotas /
--with-ratios /
--with-ftpwho /
--with-throttling /
--with-language=simplified-chinese --------------->>Socket 會話顯示出來的信息的語言.缺省爲英語,simplified-chinese 簡體中文,traditional-chinese BIG5繁體中文

--with-mysql=/usr/local/mysql / 此處的 /usr/local/mysql 請改爲你的mysql實際安裝路徑.如果出現類似configure: error: Your MySQL client libraries aren't properly installed 的錯誤,請將mysql目錄下的 include/mysql下的mysql.h文件以及lib/mysql下的全部文件,連接(直接複製過去或許也可)到 /usr/lib 目錄下
3:安裝
#make
#make check
#make install

#cp pureftpd-mysql.conf /usr/local/etc/

#cd configuration-file
#chmod u+x pure-config.pl
#cp pure-config.pl /usr/local/sbin/


#cp /usr/local/pureftpd/sbin/pure-ftpwho /usr/local/sbin/

#cp pure-ftpd.conf /usr/local/etc/
將pureftpd_php_manager目錄拷貝到網站目錄下
cp -R pureftpd_php_manager /opt/www/pureftpd_php_manager


四,配置服務

1:編輯/usr/local/etc/pure-ftpd.conf文件
找到
#CreateHomeDir yes
改爲
CreateHomeDir yes
作用是,用戶登錄,如果主目錄不存在,便自動建立.
找到
Umask 133:022
改爲
Umask 755:755
設定新文件的默認屬性.
找到
# MySQLConfigFile /etc/pureftpd-mysql.conf
改爲
MySQLConfigFile /usr/local/etc/pureftpd-mysql.conf
設定ftpd服務的參數取得爲pureftpd-mysql.conf
文件設置
#######################
存盤退出.


2:編輯/usr/local/etc/pureftpd-mysql.conf文件
它的大概樣子是這樣的

##############################################
#                                            #
# Sample Pure-FTPd Mysql configuration file. #
# See README.MySQL for explanations.         #
#                                            #
##############################################


# Optional : MySQL server name or IP. Don't define this for unix sockets.

MYSQLServer     localhost
#服務器地址

# Optional : MySQL port. Don't define this if a local unix socket is used.

MYSQLPort       3306

#服務器端口
# Optional : define the location of mysql.sock if the server runs on this host.

MYSQLSocket     /opt/mysql/var/mysql.sock
#這裏換成你的真實地址

# Mandatory : user to bind the server as.

MYSQLUser       root
#登錄服務器用戶名

# Mandatory : user password. You must have a password.

MYSQLPassword   123456
#登錄服務器密碼

# Mandatory : database to open.
MYSQLDatabase   ftpd
#配置文件所在的數據庫

# Mandatory : how passwords are stored
# Valid values are : "cleartext", "crypt", "md5" and "password"
# ("password" = MySQL password() function)
# You can also use "any" to try "crypt", "md5" *and* "password"

MYSQLCrypt      cleartext
#驗證方式

# In the following directives, parts of the strings are replaced at
# run-time before performing queries :
#
# /L is replaced by the login of the user trying to authenticate.
# /I is replaced by the IP address the user connected to.
# /P is replaced by the port number the user connected to.
# /R is replaced by the IP address the user connected from.
# /D is replaced by the remote IP address, as a long decimal number.
#
# Very complex queries can be performed using these substitution strings,
# especially for virtual hosting.


# Query to execute in order to fetch the password

MYSQLGetPW      SELECT Password FROM users WHERE User="/L" AND  status="1"
#登錄服務器的用戶密碼驗證字段,status="1"爲此用戶必需爲激活模式.

# Query to execute in order to fetch the system user name or uid

MYSQLGetUID     SELECT Uid FROM users WHERE User="/L"
#用戶的UID

# Optional : default UID - if set this overrides MYSQLGetUID

#MYSQLDefaultUID 1000


# Query to execute in order to fetch the system user group or gid

MYSQLGetGID     SELECT Gid FROM users WHERE User="/L"

#用戶的Gid
# Optional : default GID - if set this overrides MYSQLGetGID

#MYSQLDefaultGID 1000


# Query to execute in order to fetch the home directory

MYSQLGetDir     SELECT Dir FROM users WHERE User="/L"
#用戶的主目錄

# Optional : query to get the maximal number of files
# Pure-FTPd must have been compiled with virtual quotas support.

MySQLGetQTAFS  SELECT QuotaFiles FROM users WHERE User="/L"

#用戶的最大文件數量
# Optional : query to get the maximal disk usage (virtual quotas)
# The number should be in Megabytes.
# Pure-FTPd must have been compiled with virtual quotas support.

MySQLGetQTASZ  SELECT QuotaSize FROM users WHERE User="/L"
#用戶的最大磁盤空間

# Optional : ratios. The server has to be compiled with ratio support.

MySQLGetRatioUL SELECT  ULBandwidth FROM users WHERE User="/L"
MySQLGetRatioDL SELECT  DLBandwidth FROM users WHERE User="/L"
#上邊兩項爲,用戶上傳與下載的速度,單位 Kb/s

# Optional : bandwidth throttling.
# The server has to be compiled with throttling support.
# Values are in KB/s .

# MySQLGetBandwidthUL SELECT ULBandwidth FROM users WHERE User="/L"
# MySQLGetBandwidthDL SELECT DLBandwidth FROM users WHERE User="/L"

# Enable ~ expansion. NEVER ENABLE THIS BLINDLY UNLESS :
# 1) You know what you are doing.
# 2) Real and virtual users match.

# MySQLForceTildeExpansion 1


# If you upgraded your tables to transactionnal tables (Gemini,
# BerkeleyDB, Innobase...), you can enable SQL transactions to
# avoid races. Leave this commented if you are using the
# traditionnal MyIsam databases or old (< 3.23.x) MySQL versions.

# MySQLTransactions On

保存退出
請按您的實際情況修改.或者直接找錯後複製過去.



3:修改/opt/www/pureftpd_php_manager/index.php文件

#unzip -d pureftpd_php_manager pureftpd_php_manager.zip
#cd pureftpd_php_manager
注:因爲上面我已經寫pureftpd-mysql.conf所以這裏不用移動
#mv pureftpd-mysql.conf.sample /usr/local/etc/pureftpd-mysql.conf

#cp -R pureftpd_php_manager /var/wwwroot/html/pureftpd_php_manager
#cd /var/wwwroot/html/pureftpd_php_manager
#vi pureftp.config.php

修改:/opt/www/pureftpd_php_manager/pureftp.config.php文件
######################
####### SETUP ########
######################


        // 設置pureftpd-mysql.conf的位置,這個要注意,不要寫錯哦
        $PUREFTP_CONFIG_FILE    = '/usr/local/etc/pureftpd-mysql.conf';

        // The location where all the Forms directed to. (Mayby no change needed)
        $SELF_URL                               = 'index.php';

        // The location of your pure-ftpdwho binary  (set this to chmod 4711)
        $FTP_WHO                                = "/usr/local/sbin/pure-ftpwho";

#######################
# DEFAULT NEW-USER PARAMS #
#######################
   $DB_TABLE='users';                 #新增加變量,定義數據表名
   $DefaultUser = "ftpuser";                  # 默認用戶
        $DefaultPass = "passwd";                   # 默認初始用戶密碼
        $DefaultUid = "2004";                      # 默認的uid(設置爲apache的uid,你的或許不是48,爲PHP建立的目錄能夠正常使用而設置)
       $DefaultGid = "2004";                          # 默認的gid(設置爲apache的gid,你的或許不是48,爲PHP建立的目錄能夠正常使用而設置)
       $DefaultDir = "/var/ftproot/ftpusershome";     # 默認的用戶主目錄
        $DefaultUL = "0";                          # 默認用戶上傳速率限制(KB/S)
        $DefaultDL = "0";                          # 默認用戶下載速率限制(KB/S)
        $Defaultip = "*";                               # 設置用戶可以從哪些IP登陸
        $DefaultQS = "50";                         # 用戶默認的quota
        $Defaultcmt = "";                               # 默認備註信息
        $DefaultQF = "0";                          # 默認文件數目quota
        $PWC = "55";                               # Vorsatz fuerr Crypt Password 

保存退出




五,創建啓動服務環境

1:創見用戶和組
#groupadd ftpusers -g 2004
#useradd ftpusers -g ftpusers -u 2004

2:創建數據庫,以及數據表.
mysql>CREATE DATABASE pureftpd;

CREATE TABLE users (
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;
或者使用phpmyadmin創見上邊的數據表和數據庫數據庫名爲pureftpd.

mysql>grant all on pureftpd.* to pureftpd@localhost identified by 'yourpassword'

mysql>FLUSH PRIVILEGES;   //重載受權表

編輯/usr/local/etc/pureftpd-mysql.conf
將剛纔在mysql中新建的用戶和密碼加入其中,選項很簡單,只要注意不要輸錯


六、啓動pureftpd
1:啓動服務需要給定一些參數,以告知服務配置文件的位置.
方法一:
#/usr/local/pureftpd/sbin/pure-ftpd -l mysql:/usr/local/etc/pureftpd-mysql.conf &
方法二:
#/usr/local/sbin/pure-config.pl /usr/local/etc/pure-ftpd.conf
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章