歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux技術 >> linux下用Proftpd搭建ftp服務器及配置

linux下用Proftpd搭建ftp服務器及配置

日期:2017/3/1 18:07:34   编辑:Linux技術

linux下搭建ftp服務器的軟件是wuftp,現在真的時代變了,上網看一下幾乎全世界的人都用proftpd了!趕個潮流,我也用proftpd在公司的一台備用小服務器上裝上ftp服務器。

  首先proftpd是一個開源軟件,目前最高版本是:1.3.1(非穩定版),穩定的版本是1.3.0,下載文件為proftpd-1.3.0a.tar.gz

  我下載的是1.3.0,上傳到服務器上後按照常規的方法安裝即可。

  tar -zxvf proftpd-1.3.0a.tar.gz

  cd proftpd*

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

  make

  make install

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

  設置一:隨機啟動服務,sbin/proftpd文件復制到/etc/rc.d/rc.local文件夾中,以實現開機自動啟動。

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

  ServerName "ProFTPD Default Installation"

  ServerType standalone

  DefaultServer on

  分別表示:服務器名稱,服務類型和默認服務狀態!

  後面的服務端口啊什麼的我就省去不說了,說最關鍵的權限控制部分。

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

  User nobody

  Group nogroup

  注意看上面:以什麼用戶和什麼組來運行服務。

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

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

  # directory, uncomment this line.

  #DefaultRoot ~

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

  # Normally, we want files to be overwriteable.

  AllowOverwrite on

  是否具有重寫的權利

  # 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

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

  啟動不了,出現如下錯誤的解決方法

  [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

  再重啟服務就可以了!

  接上!原來以為這樣就完事了,可是看看才知道如果我要新增加一個FTP用戶的話實際上是很麻煩的一件事,因為帳號是直接跟系統帳號想關聯的,不安全也不好操作,我們的目的是要做成像虛擬主機服務提供商那樣的ftp!

  接下去,需要一個模塊的支持到 去看看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版本已經支持做了這個東西,主要編譯安裝的時候把mod_quotatab 開起來就可以了,於是重新編譯!

  前提:確認你已經安裝並且能夠正常運行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

  注意請根據自己的Linux系統找到MySQL的相應include和lib目錄,以上例子中的相關路徑是大多數Linux系統默認的,如果你的MySQL是通過源碼編譯安裝的,則這兩個目錄一般在安裝路徑下。

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

  vi mod_sql_mysql.c

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

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

  然後make

  make install

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

Copyright © Linux教程網 All Rights Reserved