FTP是File Transfer Protocol(檔案傳輸協議)的英文簡稱,而中文簡稱為“文傳協議”。用於Internet上的控制檔案的雙向傳輸。
本文以ubuntu為例來安裝及配置ftp
1、安裝vsftpd伺服器
sudo apt-get install vsftpd
複製程式碼
如圖,如果出現以下提示,說明系統已經安裝好了最新版的vsftpd,不用我們再去下載和安裝。

2、配置vsftpd.conf檔案
sudo vi /etc/vsftpd.conf
複製程式碼
開啟vsftpd.conf

找到【anonymous_enable】設定為NO,不允許匿名使用者登入

設定FTP檔案上傳下載目錄,在檔案的最後一行自行加上
local_root=目錄
複製程式碼

設定允許本機登入。找到【local_enable】,將前面的#號去掉,取消註釋。

設定允許vsftpd.chroot_list檔案中的使用者登入ftp,找到【chroot_list_enable】將前面的#號去掉,取消註釋。

設定允許上傳檔案到FTP伺服器,找到【write_enable】將前面的#號去掉,取消註釋。

在/etc目錄下建立 vsftpd.chroot_list 檔案,在裡面放入允許登入FTP伺服器的使用者名稱
vi /etc/vsftpd.chroot_list
複製程式碼


將ftp資料夾的擁有者許可權減去w
chmod u-w ftp
複製程式碼

在ftp資料夾中新建一個share資料夾,此資料夾就是使用ftp客戶端進行上傳、下載時的資料夾
// 建立share資料夾
mkdir share
// 設定許可權,所有使用者可讀可寫可執行
chmod 777 share
複製程式碼

重啟FTP服務,因為剛剛已經修改過/etc/vsftpd.conf,所以只有重啟,才能使FTP伺服器按照新的配置進行工作。
/etc/init.d/vsftpd restart
複製程式碼

