您好,歡迎來電子發(fā)燒友網(wǎng)! ,新用戶?[免費(fèi)注冊]

您的位置:電子發(fā)燒友網(wǎng)>電子百科>網(wǎng)絡(luò)>功能服務(wù)器>

linux系統(tǒng)搭建ftp服務(wù)器的配置方法

2012年02月15日 14:13 本站整理 作者:辰光 用戶評論(0

很久以前知道linux下搭建ftp服務(wù)器的軟件是wuftp,現(xiàn)在真的時(shí)代變了,上網(wǎng)看一下幾乎全世界的人都用proftpd了!趕個潮流,我也用proftpd在公司的一臺備用小服務(wù)器上裝上ftp服務(wù)器。

首先proftpd是一個開源軟件,其官方地址是http://www.proftpd.org,目前最高版本是:1.3.1(非穩(wěn)定版),穩(wěn)定的版本是1.3.0,下載文件為proftpd-1.3.0a.tar.gz

我下載的是1.3.0,上傳到服務(wù)器上后按照常規(guī)的方法安裝即可。

tar -zxvf proftpd-1.3.0a.tar.gz

cd proftpd*

./configure --prefix=/usr/local/proftpd

make

make install

安裝完成!接下來是配置。

設(shè)置一:隨機(jī)啟動服務(wù),sbin/proftpd文件復(fù)制到/etc/rc.d/rc.local文件夾中,以實(shí)現(xiàn)開機(jī)自動啟動。

設(shè)置二:配置文件在etc/proftpd.conf,配置文件說明如下:

ServerName "ProFTPD Default Installation"

ServerType standalone

DefaultServer on

分別表示:服務(wù)器名稱,服務(wù)類型和默認(rèn)服務(wù)狀態(tài)!

后面的服務(wù)端口啊什么的我就省去不說了,說最關(guān)鍵的權(quán)限控制部分。

# Set the user and group under which the server will run.

User nobody

Group nogroup

注意看上面:以什么用戶和什么組來運(yùn)行服務(wù)。

更改為你現(xiàn)有的組和用戶,這里為了管理上的方便和安全性上考慮,建議新建一個ftp組和ftp用戶。

# To cause every FTP user to be "jailed" (chrooted) into their home

# directory, uncomment this line.

#DefaultRoot ~

是否允許用戶進(jìn)入用戶的主目錄,注意:可是適用/home替代

# Normally, we want files to be overwriteable.

AllowOverwrite on

是否具有重寫的權(quán)利

# A basic anonymous configuration, no upload directories. If you do not

# want anonymous users, simply delete this entire section.

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

DenyAll

這部分是匿名用戶的定義其實(shí)也很簡單。

啟動不了,出現(xiàn)如下錯誤的解決方法

[root@new-host sbin]# ./proftpd

- IPv4 getaddrinfo 'new-host' error: Name or service not known

- warning: unable to determine IP address of 'new-host'

- error: no valid servers configured

- Fatal: error processing configuration file '/usr/local/proftpd/etc/proftpd.conf'

原因是無法綁定Ip地址。

在配置文件中增加下面這句:

DefaultAddress 192.168.8.105

再重啟服務(wù)就可以了!

接上!原來以為這樣就完事了,可是看看才知道如果我要新增加一個FTP用戶的話實(shí)際上是很麻煩的一件事,因?yàn)閹ぬ柺侵苯痈到y(tǒng)帳號想關(guān)聯(lián)的,不安全也不好操作,我們的目的是要做成像虛擬主機(jī)服務(wù)提供商那樣的ftp!

接下去,需要一個模塊的支持到http://www.castaglia.org/proftpd/#Modules去看看proftpd-mod-quotatab模塊,注意下面這句話:

NOTE: mod_quotatab became part of the offical ProFTPD source distribution in 1.2.10rc1. If using a version of ProFTPD later than that, please use the mod_quotatab already included, as it will be most up-to-date.

表示我們下載的1.3版本已經(jīng)支持做了這個東西,主要編譯安裝的時(shí)候把mod_quotatab 開起來就可以了,于是重新編譯!

前提:確認(rèn)你已經(jīng)安裝并且能夠正常運(yùn)行mysql,否則后面的工作都是沒有意義的了!

重新編譯:

./configure --prefix=/usr/local/proftpd --with-modules=mod_sql:mod_sql_mysql:mod_quotatab:mod_quotatab_sql --with-includes=/usr/include/mysql --with-libraries=/usr/lib/mysql

注意請根據(jù)自己的Linux系統(tǒng)找到MySQL的相應(yīng)include和lib目錄,以上例子中的相關(guān)路徑是大多數(shù)Linux系統(tǒng)默認(rèn)的,如果你的MySQL是通過源碼編譯安裝的,則這兩個目錄一般在安裝路徑下。

資料說:需要修改contrib目錄中mod_sql_mysql.c文件:

vi mod_sql_mysql.c

找到#include 這一行,將mysql.h改成你的系統(tǒng)中此文件所在的路徑,如/usr/include/mysql/mysql.h

可是我沒有這樣做也可以,真奇怪!

然后make

make install

一樣的切換到proftpd文件夾中操作,后面的比較復(fù)雜,我試試以大學(xué)教授的水平用簡單的語言講。

非常好我支持^.^

(4) 100%

不好我反對

(0) 0%

( 發(fā)表人:辰光 )

      發(fā)表評論

      用戶評論
      評價(jià):好評中評差評

      發(fā)表評論,獲取積分! 請遵守相關(guān)規(guī)定!

      ?