发布时间:2026-07-25阅读(1)
每天分享技术实战干货,技术在于积累和收藏,希望可以帮助到您。
架构开源地址:https://gitee.com/msxy
评论转发
什么是Apache FtpserverApache FtpServer是100%纯Java FTP服务器。它被设计为基于当前可用的开放协议的完整且可移植的FTP服务器引擎解决方案。FtpServer可以作为Windows服务或Unix / Linux守护程序独立运行,也可以嵌入Java应用程序中。我们还提供对Spring应用程序内集成的支持,并以OSGi捆绑软件的形式提供我们的发行版。默认的网络支持基于高性能异步IO库Apache MINA。使用MINA,FtpServer可以扩展到大量并发用户。
Apache ftpserver特性部署演示是在window机器上,linux服务器运行与window运行大同小异,参考即可。
Apache Ftpserver下载下载地址:
根据需要下载对应版本的部署包:https://mina.apache.org/ftpserver-project/downloads.html
或者点击https://dlcdn.apache.org/mina/ftpserver/1.2.0/apache-ftpserver-1.2.0-bin.zip 直接下载。
下载后,解压到当前文件夹:


例如配置一个qingfeng用户:#密码 配置新的用户ftpserver.user.qingfeng.userpassword=123456#主目录,这里可以自定义自己的主目录ftpserver.user.qingfeng.homedirectory=./res/qingfeng-home#当前用户可用ftpserver.user.qingfeng.enableflag=true#具有上传权限ftpserver.user.qingfeng.writepermission=true#最大登陆用户数为20ftpserver.user.qingfeng.maxloginnumber=20#同IP登陆用户数为2ftpserver.user.qingfeng.maxloginperip=2#空闲时间为300秒ftpserver.user.qingfeng.idletime=300#上传速率限制为480000字节每秒ftpserver.user.qingfeng.uploadrate=48000000#下载速率限制为480000字节每秒ftpserver.user.qingfeng.downloadrate=48000000

<server xmlns="http://mina.apache.org/ftpserver/spring/v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://mina.apache.org/ftpserver/spring/v1 https://mina.apache.org/ftpserver-project/ftpserver-1.0.xsd " id="myServer"> <listeners> <nio-listener name="default" port="2121"> <!--<ssl> <keystore file="./res/ftpserver.jks" password="password" /> </ssl>--> <!--注意:如果要支持外网连接,需要使用被动模式passive,默认开启主动模式--><data-connection idle-timeout="60"><!--<active enabled="true" ip-check="true" />--><passive ports="2000-2222" /></data-connection><!--添加ip黑名单--><blacklist>127.0.0.2</blacklist> </nio-listener> </listeners> <file-user-manager file="./res/conf/users.properties" encrypt-passwords="clear"/></server>

打开cmd并cd到bin路径执行.\ftpd.bat res/conf/ftpd-typical.xml,看到如下状态说明启动成功

如果出现问题:2 字节的 UTF-8 序列的字节 2 无效,用记事本打开,然后另存为-Utf-8

测试访问,打开浏览器输入:ftp://localhost:2121/就会看到你的文件目录了,如果没有配置匿名用户,则会要求你输入用户名密码,正是你在user.properties中配置的


Copyright © 2024 有趣生活 All Rights Reserve吉ICP备19000289号-5 TXT地图HTML地图XML地图