本科毕业设计所设计的系统需要用到一个ftp服务器。我选择的是ProFTPD服务器。
一.ProFTPD 服务器介绍
ProFTPD is a highly configurable FTP daemon for Unix and Unix-likeoperating systems.
二.官方地址 三.安装步骤解压下载的文件
命令终端进入到解压后的文件目录(该目录一般和解压之前的文件名同名)
输入 ./configure
输入 make
输入 sudo make install
注:更详细的说明,请参考解压后的文件中的INSTALL文件
四.创建 ftp组以及ftp用户
为了使匿名用户登录进系统之后具有访问目录的权限,需要创建一个锁定的用户“ftp”,并把该“ftp”用户归到"ftp"group中。
使用的命令有:
1.sudo groupadd ftp
2.sudo useradd ftp -g ftp -d /host/LIVES
五.配置文件 proftpd.conf
proftpd.conf 一般位于 /usr/local/etc 目录,下面给出一种配置文件,它是我毕业设计所需的。
# This is a basic ProFTPD configuration file (rename it to
# 'proftpd.conf' for actual use. It establishes a single server
# and a single anonymous login. It assumes that you have a user/group
# "nobody" and "ftp" for normal operation and anon.
ServerName "ProFTPD Default Installation"
ServerType standalone
DefaultServer on
# Port 21 is the standard FTP port.
Port 21
# Don't use IPv6 support by default.
UseIPv6 off
# Umask 022 is a good standard umask to prevent new dirs and files
# from being group and world writable.
Umask 022
# To prevent DoS attacks, set the maximum number of child processes
# to 30. If you need to allow more than 30 concurrent connections
# at once, simply increase this value. Note that this ONLY works
# in standalone mode, in inetd mode you should use an inetd server
# that allows you to limit maximum number of processes per service
# (such as xinetd).
MaxInstances 30
# Set the user and group under which the server will run.
User nobody
Group nogroup
# To cause every FTP user to be "jailed" (chrooted) into their home
# directory, uncomment this line.
DefaultRoot /host/LIVES
# Normally, we want files to be overwriteable.
AllowOverwrite on
# Bar use of SITE CHMOD by default
<Limit SITE_CHMOD>
DenyAll
</Limit>
# A basic anonymous configuration, no upload directories. If you do not
# want anonymous users, simply delete this entire <Anonymous> section.
<Anonymous /host/LIVES/users>
<Limit LOGIN>
AllowAll
</Limit>
RequireValidShell off
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 10000
# We want 'welcome.msg' displayed at login, and '.message' displayed
# in each newly chdired directory.
DisplayLogin welcome.msg
DisplayChdir .message
# Limit WRITE everywhere in the anonymous chroot
<Limit WRITE>
AllowAll
</Limit>
<Limit READ>
AllowAll
</Limit>
<Limit STOR>
AllowAll
</Limit>
</Anonymous>
上面配置的效果是: 将所有匿名用户的操作目录限制在 “/host/LIVES/users",匿名用户可以读写修改目录和文件。当然还有其他的功能,在此不一一细说。
六.方便操作的shell脚本
脚本名称:proftpd.sh
#!/bin/sh
# ProFTPD files
FTPD_BIN=/usr/local/sbin/proftpd
FTPD_CONF=/usr/local/etc/proftpd.conf
PIDFILE=/usr/local/var/proftpd.pid
# If PIDFILE exists, does it point to a proftpd process?
if [ -f $PIDFILE ]; then
pid=`cat $PIDFILE`
fi
if [ ! -x $FTPD_BIN ]; then
echo "$0: $FTPD_BIN: cannot execute"
exit 1
fi
case $1 in
start)
if [ -n "$pid" ]; then
echo "$0: proftpd [PID $pid] already running"
exit
fi
if [ -r $FTPD_CONF ]; then
echo "Starting proftpd..."
$FTPD_BIN -c $FTPD_CONF
else
echo "$0: cannot start proftpd -- $FTPD_CONF missing"
fi
;;
stop)
if [ -n "$pid" ]; then
echo "Stopping proftpd..."
kill -TERM $pid
else
echo "$0: proftpd not running"
exit 1
fi
;;
restart)
if [ -n "$pid" ]; then
echo "Rehashing proftpd configuration"
kill -HUP $pid
else
echo "$0: proftpd not running"
exit 1
fi
;;
*)
echo "usage: $0 {start|stop|restart}"
exit 1
;;
esac
exit 0
该脚本的使用方法:
sudo ./proftpd.sh start
sudo ./proftpd.sh restart
sudo ./proftpd.sh stop
它们的含义是显而易见的,值得注意的是"./proftpd restart"并不会关闭已经开启的进程,而是重新读取配置文件,这样后来开启的进程使用的都是刚读入的配置文件。