一:简介
Pure-FTPd 是一款免费的,安全的,高质量和符合标准的FTP服务器。 侧重于运行效率和易用性。 它提供了简单的答案,他满足了大众化的需求,包括普通用户以及主机供应商们。
pure - ftpd 得到了充分的支持,它是始终以安全设计为理念,其代码总是作为有漏洞的来进行讨论,并重新审核。该服务可以适应严格的安全需要做到权限分离。 甚至在不需要Root权限的情况下通过其内建的chroot()仿真以及虚拟帐户100%正常运行。避免密码作为明文传输:pure - ftpd的OpenSSL库支持可选的 SSL / TLS加密层使用。
二:案例
配置步骤
首先搭建lnmp环境
[root@localhost ~]# yum -y install http php php-mysql mysql mysql-server mysql-devel
启动httpd服务,开机自启动
[root@localhost ~]# service httpd start
启动 httpd:
[确定]
[root@localhost ~]# chkconfig httpd on
启动mysqld服务,开机自启动
[root@localhost ~]# service mysqld start
Support MySQL by buying support/licenses at http://shop.mysql.com
[确定]
启动 MySQL:
[确定]
[root@localhost ~]# chkconfig mysqld on
为mysql建密码
[root@localhost ~]# mysqladmin -u root -p password '123456'
1.源码安装pure-ftp,解压pure-ftpd
[root@localhost pureftp]# tar -zxvf pure-ftpd-1.0.36.tar.gz -C /usr/local/src/
[root@localhost pureftp]# cd /usr/local/src//pure-ftpd-1.0.36/
检测预编译环境
[root@localhost pure-ftpd-1.0.36]# ./configure \
>
--prefix=/usr/local/pureftpd \
>
--with-mysql \
>
--with-shadow \
>
--with-pam \
>
--with-welcomemsg \
>
--with-uploadscript \
>
--with-cookie \
>
--with-virtualchroot \
>
--with-virtualhosts \
>
--with-diraliases \
>
--with-quotas \
>
--with-puredb \
>
--with-sysquotas \
>
--with-ratios \
>
--with-ftpwho \
>
--with-throttling \
>
--with-language=simplified-chinese
编译
[root@localhost pure-ftpd-1.0.36]# make
将文件放入指定位置
[root@localhost pure-ftpd-1.0.36]# make install
创建配置文件存放位置
[root@localhost pure-ftpd-1.0.36]# mkdir /usr/local/pureftpd/etc
拷贝pureftp配置文件
[root@localhost configuration-file]# cp pure-ftpd.conf /usr/local/pureftpd/etc/
拷贝调用文件,修改权限可执行
[root@localhost configuration-file]# cp pure-config.pl /usr/local/pureftpd/sbin/
[root@localhost configuration-file]# chmod 755 pure-config.pl
拷贝pureftp控制脚本
[root@localhost pure-ftpd-1.0.36]# cd contrib/
[root@localhost contrib]# cp redhat.init /etc/init.d/pureftpd
给予执行权限
[root@localhost contrib]# chmod 755 /etc/init.d/pureftpd
编辑控制脚本
[root@localhost contrib]# vim /etc/init.d/pureftpd
18 fullpath=/usr/local/pureftpd/sbin/$prog
19 pureftpwho=/usr/local/pureftpd/sbin/pure-ftpwho
24
$fullpath /usr/local/pureftpd/etc/pure-ftpd.conf --daemonize
启动pureftpd服务
[root@localhost sbin]# service pureftpd start
启动 pure-config.pl:Running: /usr/local/pureftpd/sbin/pure-ftpd --daemonize -A -c50 -B -C8 -D -fft-m4 -s -U133:022 -u100 -k99 -Z
[root@localhost contrib]# chkconfig --add pureftpd
[root@localhost contrib]# chkconfig --list |grep pureftpd
pureftpd
0:关闭
1:关闭
2:启用
3:启用
4:启用
5:启用
6:关闭
2.配置虚拟用户登录环境
创建本地帐号目录
[root@localhost contrib]# mkdir /ftproot
[root@localhost contrib]# chmod -R 777 /ftproot
创建接虚拟用户对应的系统用户
[root@localhost contrib]# useradd virtualftp -d /ftproot -s /sbin/nologin -M
修改所属者和所属组
[root@localhost contrib]# chown virtualftp:virtualftp /ftproot
编辑pureftpd主配置文件
[root@localhost contrib]# vim /usr/local/pureftpd/etc/pure-ftpd.conf
NoAnonymous
yes //不允许匿名登录
CreateHomeDir
yes //允许用户登录后自动创建家目录
重启服务
[root@localhost contrib]# service pureftpd restart
停止 pure-config.pl:
启动 pure-config.pl:Running: /usr/local/pureftpd/sbin/pure-ftpd --daemonize -A -c50 -B -C8 -D -E -fftp -H -I15 -L10000:8 -m4 -s -U133:022 -u100 -j -k99 –Z
3.用mysql认证
[root@localhost contrib]# vim /usr/local/pureftpd/etc/pure-ftpd.conf
MySQLConfigFile
/usr/local/pureftpd/etc/pureftpd-mysql.conf
拷贝配置文件
[root@localhost pureftp]# cp pureftpd-mysql.conf /usr/local/pureftpd/etc/
[root@localhost pureftp]# cd /usr/local/pureftpd/etc/
编辑配置文件
[root@localhost etc]# vim pureftpd-mysql.conf
MYSQLPassword
tmppasswd
MYSQLCrypt
md5
导入数据
[root@localhost pureftp]# mysql -u root -p <pureftp.sql
Enter password:
查看数据库
[root@localhost pureftp]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.0.77 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> showdatabases;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'showdatabases' at line 1
mysql> show databases;
+--------------------+
| Database
|
+--------------------+
| information_schema |
| ftpusers
|
| mysql
|
| test
|
+--------------------+
4 rows in set (0.01 sec)
4.查看mysql
[root@localhost pureftp]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.0.77 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> grant all privileges on ftpusers.* to ftp@localhost identified by 'tmppasswd';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
5.配置web程序PureAdmin
解压
[root@localhost pureftp]# tar -zxvf PureAdmin-0.3.tar.gz -C /var/www/html/
修改文件名称
[root@localhost pureftp]# cd /var/www/html/
[root@localhost html]# mv PureAdmin-0.3 pureadmin
编辑config.php
[root@localhost html]# cd pureadmin/
[root@localhost pureadmin]# vim config.php
<?php
2 $cfg['dbhost']='localhost'; //mysql host
3 $cfg['dbname']='ftpusers'; //mysql db name
4 $cfg['dbuser']='ftp';
//mysql user
5 $cfg['dbpasswd']='tmppasswd';
//mysql password
6
7 //ftp config
8 $cfg['page']=15;
9 //ftp passwd type : TEXT/CRYPT/MD5
10 $cfg['passwdtype']='MD5';
11 //ftp default
12 $cfg['uid']=1000; //uid
13 $cfg['gid']=1000;
//gid
14 $cfg['dir']='/ftproot/'; //dir
15 $cfg['qf']=0;
//quotafiles
16 $cfg['qs']=100; //quotasize
17 $cfg['ul']=0;
//ULBandwidth
18 $cfg['dl']=200; //DLBandwidth
19 $cfg['ur']=0;
//ULRatio
20 $cfg['dr']=0;
//DLRatio
21 $cfg['status']=1; //status
6.区域帐号映射到本地帐号
[root@localhost ftproot]# vim /usr/local/pureftpd/etc/pure-ftpd.conf
126 PureDB
/usr/local/pureftpd/pureftpd.pdb
设置环境变量
[root@localhost bin]# echo PATH=$PATH:/usr/local/pureftpd/bin/ >>/etc/profile
使之立即生效
[root@localhost bin]# . /etc/profile
新建虚拟帐号
[root@localhost bin]# pure-pw useradd user9 -u virtualftp -g virtualftp -d /ftproot/user9 -m
Password:
Enter it again:
建立用户数据库
[root@localhost bin]# pure-pw mkdb /usr/local/pureftpd/pureftpd.pdb
测试:
后台使用管理帐号登录新建用户
查看数据库信息
查看ftproot目录下多了两个文件
[root@localhost bin]# cd /ftproot/
[root@localhost ftproot]# ll
总计 8
drwxr-xr-x 2
1000 1000 4096 08-19 21:58 user10
drwxr-xr-x 2 virtualftp virtualftp 4096 08-19 21:57 user9
转载于:https://blog.51cto.com/niuxiaolin/992552