linux下用Proftpd搭建ftp服务器及配置 |
本文标签:ftp服务器搭建,如何搭建ftp服务器 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. 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 这部分是匿名用户的定义其实也很简单 。 启动不了,出现如下错误的解决方法 [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文件夹中操作,后面的比较复杂,我试试以大学教授的水平用简单的语言讲 。 |