FTP 是FileTransfer Protocol(文件传输协议)的英文简称,而中文简称为“文传协议”。用于Internet上的控制文件的双向传输。同时,它也是一个应用程序 (Application)。基于不同的操作系统有不同的FTP应用程序,而所有这些应用程序都遵守同一种协议以传输文件。在FTP的使用当中,用户经常 遇到两个概念:"下载"(Download)和"上传"(Upload)。"下载"文件就是从远程主机拷贝文件至自己的计算机上;"上传"文件就是将文件 从自己的计算机中拷贝至远程主机上。用Internet语言来说,用户可通过客户机程序向(从)远程主机上传(下载)文件。

这里我们介绍Apache旗下Mina项目下的FtpServer:

OK,咱们还是切入正题吧!详细步骤如下:

方式一:通过加载文件的方式,创建Apache FtpServer。

1、下载Apache FtpServer,目前,最新为1.0.6,下载地址:http://mina.apache.org/ftpserver-project/downloads.html

2、解压得到apache-ftpserver-1.0.6;

3、进入apache-ftpserver-1.0.6\res\conf,进行相关配置;

首先修改users.properties这个文件

ftpserver.user.admin.userpassword=21232F297A57A5A743894A0E4A801FC3修改为:

ftpserver.user.admin.userpassword=admin

然后修改ftpd-typical.xml文件

<file-user-managerfile="./res/conf/users.properties">为

<file-user-managerfile="./res/conf/users.properties" encrypt-passwords ="clear"/>

4、安装以及启动FTPServer;

进入CMD命令/bin这个目录下执行(win7环境需要以管理员身份启动CMD),

service install (注意:安装只需安装一次)

ftpd.bat res/conf/ftpd-typical.xml(如果看到“FtpServer started”这句话,代表FtpServer启动成功)

5、登陆Apache FtpServer

打开浏览器,输入:ftp://hostaddress:port,如:ftp://10.0.0.132:2121,登陆FTP文件服务器。

方式二:使用数据库进行验证(这里数据库选用mysql),创建Apache Ftpserver服务器

1、前面两步是一样,下载以及解压。

2、进入apache-ftpserver-1.0.6\res\conf,进行相关配置;

首先,选定一个数据库(这里使用ftpserver),根据文件apache-ftpserver-1.0.6/res/ftp-db.sql中的命令创建数据库;

接下来,在数据库中增加一条记录:insert into FTP_USER values("user1","123456","./res/home",1,0,0,0,0,0,0);

然后,创建配置文件:ftpd-db.xml

最后,添加ftpd-db.xml内容,内容如下:

<?xml version="1.0" encoding="UTF-8"?>
<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -->
<server xmlns="http://mina.apache.org/ftpserver/spring/v1"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-2.5.xsdhttp://mina.apache.org/ftpserver/spring/v1http://mina.apache.org/ftpserver/ftpserver-1.0.xsd"id="myServer"><listeners><nio-listener name="default" port="2121"><ssl><keystore file="./res/ftpserver.jks" password="password" /></ssl></nio-listener></listeners><!-- 将文件方式注释掉 --><!-- <file-user-manager file="./res/conf/users.properties" /> --><db-user-manager encrypt-passwords="clear"><!-- 数据源信息,ftpserver为MySQL数据库名称,root/root,为用户名以及密码 --><data-source><beans:bean class="org.apache.commons.dbcp.BasicDataSource"><beans:property name="driverClassName" value="com.mysql.jdbc.Driver" /><beans:property name="url" value="jdbc:mysql://localhost/ftpserver" /><beans:property name="username" value="root" /><beans:property name="password" value="root" /></beans:bean></data-source><insert-user>INSERT INTO FTP_USER (userid, userpassword,homedirectory, enableflag, writepermission, idletime, uploadrate,downloadrate) VALUES ('{userid}', '{userpassword}','{homedirectory}',{enableflag}, {writepermission}, {idletime},{uploadrate},{downloadrate})</insert-user><update-user>UPDATE FTP_USER SETuserpassword='{userpassword}',homedirectory='{homedirectory}',enableflag={enableflag},writepermission={writepermission},idletime={idletime},uploadrate={uploadrate},downloadrate={downloadrate}WHERE userid='{userid}'</update-user><delete-user>DELETE FROM FTP_USER WHERE userid = '{userid}'</delete-user><select-user>SELECT userid, userpassword, homedirectory,enableflag, writepermission, idletime, uploadrate, downloadrate,maxloginnumber, maxloginperip FROMFTP_USER WHERE userid = '{userid}'</select-user><select-all-users>SELECT userid FROM FTP_USER ORDER BY userid</select-all-users><is-admin>SELECT userid FROM FTP_USER WHERE userid='{userid}'ANDuserid='admin'</is-admin><authenticate>SELECT userpassword from FTP_USER WHEREuserid='{userid}'</authenticate></db-user-manager>
</server>

3、导jar包

增加数据库连接需要使用的jar,下载3个jar包到目录apache-ftpserver-1.0.6/common/lib: commons-dbcp-1.2.2.jar、commons-pool-1.3.jar、

mysql-connector-java-3.1.13-bin.jar

4、安装以及启动FTPServer;

进入CMD命令/bin这个目录下执行(win7环境需要以管理员身份启动CMD),

service install

ftpd.bat res/conf/ftpd-db.xml(注意:跟前面启动时加载的XML不相同)

5、登陆Apache FtpServer

打开浏览器,输入:ftp://hostaddress:port,如:ftp://10.0.0.132:2121,输入用户和密码:user1  123456,登陆FTP文件服务器。

配置详解如下:

打开FtpServer安装目录,其目录下有:bin、common、res三个目录。

1、当前至关心res目录,下面来看看该目录:

a、conf目录,该目录下主要存放与FtpServer相关的配置文件,稍后会详细介绍。

b、home目录,该目录下主要用于存放Ftp服务器上的文件(FtpServer默认存放在该目录下),可通过配置文件修改存放目的地,稍后会详细介绍。

c、log目录,从目录名称可得知是存放日志的地方,一般我们不会关心该目录。

b、ftp-db.sql、ftpserver.jks文件,ftp-db.sql文件表示如果采用数据库连接方式创建FTP服务器时的建表语句

2、conf目录:

a、先来看看users.properties文件,该文件主要用户对FtpServer的用户进行配置。下面来看看该文件各配置项的详细说明:

   #密码为1234tpserver.user.anonymous.userpassword=1234#主目录(FtpServer文件存放目录)ftpserver.user.anonymous.homedirectory=./res/home#当前用户可用ftpserver.user.anonymous.enableflag=true#具有上传权限ftpserver.user.anonymous.writepermission=true#最大登陆用户数为20ftpserver.user.anonymous.maxloginnumber=20#同IP登陆用户数为2ftpserver.user.anonymous.maxloginperip=2#空闲时间为300秒ftpserver.user.anonymous.idletime=300#上传速率限制为48字节每秒ftpserver.user.anonymous.uploadrate=4800#下载速率限制为48字节每秒ftpserver.user.anonymous.downloadrate=4800

i、用户名及密码设置:

设置用户名: ftpserver.user.xxxxxx .userpassword=1234用于设置密码,表示当前密码为1234,xxxxxx为用户名,该名字随意自定义。

ii、设置该账号的主目录(FtpServer文件存放目录)

设置文件存放主目录:ftpserver.user.anonymous.homedirectory=./res/home,表示当前主目录为FtpServer安装目录下,res目录中的home目录。

b、再来看看ftpd-typical.xml文件:

i、在server根元素下添加一下属性:(增加了下面属性后,在IE中无法打开)

打开该xml文件,找到server根元素,默认server根元素只有一个id属性值为myServer。

#最大用户登录数

max-logins="20"

#是否允许用户匿名登录

anon-enabled="false"

#以下三个属性一般不会进行修改

max-anon-logins="0"

max-login-failures="3"

login-failure-delay="30000"

ii、修改FtpServer端口:

找到nio-listener元素,修改该元素的port属性为需要修改的端口。

3、关于使用数据连接创建Ftpserver需要说明的点。

ftpd-db.xml中server属性部分的申明部分一定要写,否则就会找不到beans,

报错:The prefix "beans" for element"beans:bean" is not bound;

db-user-manager 的属性部分(encrypt-passwords="clear")一定要写,这里的密码加密方式为clear,否则会登录不成功;

Apache FtpServer详解相关推荐

  1. (转)Apache Rewrite 详解

    (转)Apache Rewrite 详解 参考文档:http://man.chinaunix.net/newsoft/ApacheManual/mod/mod_rewrite.html Apache ...

  2. apache配置文件详解与优化

    apache配置文件详解与优化 一.总结 一句话总结:结合apache配置文件中的英文说明和配置详解一起看 1.apache模块配置用的什么标签? IfModule 例如: <IfModule ...

  3. Apache 服务器配置详解

    Apache 配置详解 Apahce 配置指令可以分为两大块,核心指令和第三方提供的指令.在apache中,每一个指令都对应着一个模块,而在所有模块中,最重要的就是core_module,so_mod ...

  4. Apache 安装详解

    Apache 安装详解 一,Apache 的特点 1,开放源代码,这是 Apache 服务器的重要特性之一,也是其他特性的基础. 2,跨平台应用 3,支持各种 Web 编程语言,包括 Perl.PHP ...

  5. apache 更改默认网站目录 及 CentOS Apache配置详解

    apache 更改默认网站目录: 1:我们测试把默认网站目录改到root家目录下 新建/root/website目录 #mkdir -p /root/website #echo "websi ...

  6. Apache Log4j2详解,【高级Java架构师系统学习

    []( )引用依赖 在一般项目中使用Log4j2至少需要引用log4j-api-2.x和log4j-core-2.x这两个jar包. org.apache.logging.log4j log4j-co ...

  7. php apache日志,Apache日志详解

    1.Apache日志文件名称及路径介绍 当我们安装并启动Apache后,Apache会自动生成两个日志文件,这两个日志文件分别是访问日志access_log(在Windows上是access.log) ...

  8. 集群和分布式的区别,软件架构的演化过程,Apache Dubbo详解

    集群和分布式的区别   集群是通过提高单位时间内执行的任务数来提升效率,分布式是以缩短单个任务的执行时间来提升效率的. 举个例子: &emsp: 例如: &emsp:  一个数据库里边 ...

  9. Apache配置详解(一)

    主配置文件:httpd.conf 更改httpd启动方式 1.将http脚本复制到/etc/rc.d/init.d这个目录下: cp -a apachectl /etc/rc.d/init.d/htt ...

  10. linux配置apache不管用,Linux中apache配置文件详解

    Linux中apache配置文件:/etc/httpd/conf/httpd.conf ServerTokens OS//当服务器响应主机头(header)信息时显示Apache的版本和操作系统名称 ...

最新文章

  1. 2016 - 1- 21 - RunLoop使用(2016-1-24修改一次)(2016 - 1 - 24 再次修改)
  2. 光伏行业需理性看待低价中标 市场竞争是必然选择
  3. 如何给Docker hub用户上传头像
  4. 睡眠音频分割及识别问题(二)
  5. 计算机考试时间2021安徽,安徽省2021年高考录取结果查询正式开通!查询方式权威公布...
  6. win10 python免安装_使用Python编写免安装运行时、以Windows后台服务形式运行的WEB服务器...
  7. astar插件下载 就行_送给你们一个ps插件,5秒抠图神器,这个肯定是你找了很久的...
  8. 基于SSM的健身俱乐部管理系统
  9. 七步法计算测量不确定度:第八步
  10. 全局唯一编码ID生成器
  11. Vue 可拖拽的组件
  12. 如何打开linux字符界面,Linux字符界面转图形界面
  13. 世界编程语言排名2019_世界十大编程语言-2019一起玩
  14. html+css 背景图片铺满并居中
  15. Python开发培训哪里好
  16. android无法接收短信广播,Android BroadcastReceiver接收收到短信的广播
  17. linux编译ice,linux环境下编译安装ICE
  18. 更简单获取到Bean对象(1)
  19. 编写程序计算长方体的体积python_【自学编程】C语言编程简单的小程序,计算长方体体积!...
  20. android版netspot,WiFi概观360 Pro直装解锁专业版

热门文章

  1. 条形码的含义以及商品条码的申请流程
  2. 修改IAR for msp430工程名方法
  3. 以图搜图-自动生成图模式匹配Cypher
  4. 计算机关机界面设置在哪里,电脑怎么设置关机画面
  5. 股票交易接口程序概述
  6. 【计算机网络】PDU地址
  7. 【flask】工厂函数和蓝本的作用
  8. 外置硬盘一插就卡_为什么电脑一插移动硬盘就卡死了?
  9. win10开启移动热点,手机无法获取ip地址
  10. 【机器学习|数学基础】Mathematics for Machine Learning系列之矩阵理论(18):方阵的幂级数