lkoih 发表于 2015-9-21 09:33:18

源码编译安装vsftpd3.0.2

首先,是下载vsftpd-3.0.2.tar.gz这个源码包,由于网上提供的下载地址需要翻墙,所以,再次提供一个下载包。
源地址https://security.appspot.com/downloads/vsftpd-3.0.2.tar.gz
360云盘 http://yunpan.cn/cHf5pXNceyuiR访问密码 d65a
具体步骤:
1、卸载之前已经yum装的vsftpd

1
yum remove vsftpd




2、创建ftp目录和用户

1
2
3
4
5
6
mkdir /alidata/www/
useradd -s /sbin/nologin -d /alidata/www/ www
passwdwww给www用户设置密码,即FTP用户密码
useradd nobody
chown www:www/alidata/www/
chmod a-w /alidata/www/




3、安装一些依赖包

1
yum install libcaptcp_wrapperstcp_wrappers_devel




4、解压、编译安装vsftp

1
2
tar zxvf vsftpd 3.0.2.tar.gz
cd vsftpd 3.0.2




修改builddefs.h 文件,undef不启用Define启用

1
2
3
4
5
6
#ifndef VSF_BUILDDEFS_H
#define VSF_BUILDDEFS_H
#define VSF_BUILD_TCPWRAPPERS
#define VSF_BUILD_PAM
#undef VSF_BUILD_SSL
#endif /* VSF_BUILDDEFS_H */




修改opts.c文件
if (str_equal_text(&p_sess->ftp_arg_str,"UTF8 ON")) 改为if (str_equal_text(&p_sess->ftp_arg_str,"DISABLE UTF8 ON"))
如果是64位系统,需要替换lib目录的位置   

1
sed -i 's/lib\//lib64\//g' vsf_findlibs.sh




编译,安装


1
make && make install




5、创建配置文件

1
2
3
mkdir /etc/vsftpd/
cp vsftpd.conf /etc/vsftpd/       #配置文件   
cp RedHat/vsftpd.pam /etc/pam.d/www#PAM认证文件




如果是64位系统,需要替换lib目录的位置

1
sed -i 's/lib\//lib64\//g' /etc/pam.d/www




6、修改配置文件vsftpd.conf

1
2
3
4
5
6
7
8
9
10
11
12
13
14
anonymous_enable=No #不允许匿名用户使用
local_enable=YES#允许本地用户可用
write_enable=YES#写操作
umask=022
dirmessage_enable=YES#需要显示某目录下文件信息
max_clients=100#FTP服务器最大承载用户数
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd/vsftpd.chroot_list   #限制用户在家目录
allow_writeable_chroot=YES                                           listen=YES
#listen_port=8080    #更改监听端口9000 默认是21
userlist_enable=YES
#改被动模式
pasv_min_port=30000
pasv_max_port=30010





1
echo "www" > /etc/vsftpd/vsftpd.chroot_list




vim /etc/vsftpd/vsftpd.user_list    userlist_file选项指定文件中的用户将无法login

1
2
3
4
5
6
7
8
9
10
11
12
13
14
root
bin
daemon
adm
lp
sync
shutdown
halt
mail
news
uucp
operator
games
nobody




7、启动,并查看ftp进程


1
2
/usr/local/sbin/vsftpd &
netstat -tunlp | grep 21




8、制作启动脚本

1
vim /etc/xinetd.d/vsftpd




把disable改为 yes
vim/etc/init.d/vsftpd

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/bash
#
# vsftpd      This Shell script takes care of starting and stopping
#             standalone vsftpd.
#
# chkconfig: - 60 50
# description: Vsftpd is a ftp daemon, which is the program
#            that answers incoming ftp service requests.
# processname: vsftpd
# config: /etc/vsftpd.conf
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0
[ -x /usr/local/sbin/vsftpd ] || exit 0
RETVAL=0
prog="vsftpd"
start() {
      # Start daemons.
      if [ -d /etc ] ; then
                for i in `ls /etc/vsftpd.conf`; do
                        site=`basename $i .conf`
                        echo -n $"Starting $prog for $site: "
                        /usr/local/sbin/vsftpd $i &
                        RETVAL=$?
                        [ $RETVAL -eq 0 ] && {
                           touch /var/lock/subsys/$prog
                           success $"$prog $site"
                        }
                        echo
                done
      else
                RETVAL=1
      fi
      return $RETVAL
}
stop() {
      # Stop daemons.
      echo -n $"Shutting down $prog: "
      killproc $prog
      RETVAL=$?
      echo
      [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog
      return $RETVAL
}
# See how we were called.
case "$1" in
start)
      start
      ;;
stop)
      stop
      ;;
restart|reload)
      stop
      start
      RETVAL=$?
      ;;
condrestart)
      if [ -f /var/lock/subsys/$prog ]; then
            stop
            start
            RETVAL=$?
      fi
      ;;
status)
      status $prog
      RETVAL=$?
      ;;
*)
      echo $"Usage: $0 {start|stop|restart|condrestart|status}"
      exit 1
esac
exit $RETVAL




授予755权限

1
chmod755/etc/init.d/vsftpd



页: [1]
查看完整版本: 源码编译安装vsftpd3.0.2