How to build several ftp servers on one mac OS

Statement:

If you don’t run it successfully according to this tutorial, please give a comment. Once noticed, your message would be replied asap. If you think highly of this article, Could you give me a thumb-up? I would appreciate it.

1 How to establish one ftp server locally?

I have viewed one article which helps us how to do this on mac OS. You can refer to this link Mac下搭建FTP服务器
please read the tutorial seriously. What I do in the following will be based on it.

2 How to build several ones on one mac machine ?

prepostional knowledge:
We all know that only the socket(ip+port) is able to mark the unique process. If we allocate the corresponding file to the process as the zone of the ftp server.

So we merely need to change the port number of socket and allocate relevant zone to create different ftp server process.

Based on the part 1, we do this trial using Apache FtpServer 1.1.4 Release

2.1 Observing the features of starting one local ftp server

在这里插入图片描述

1

ftpd.sh res/conf/ftpd-typical.xml
Let’s have a look at the .xml file:

<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 http://mina.apache.org/ftpserver/ftpserver-1.0.xsd	
	   "
	id="myServer">
	<listeners>
		<nio-listener name="default" port="8000">
		    <ssl>
                <keystore file="./res/ftpserver.jks" password="password" />
            </ssl>
		</nio-listener>
	</listeners>
	<file-user-manager file="./res/conf/users.properties" />
</server>

we discover that ftpd-typical.xml defines the server instance. And there is a tag that indicates where the user’s config is.

2
let’s look at the contents of the user.properties file:

# Password is "admin"
ftpserver.user.admin.userpassword=21232F297A57A5A743894A0E4A801FC3
ftpserver.user.admin.homedirectory=./res/home/localhost
ftpserver.user.admin.enableflag=true
ftpserver.user.admin.writepermission=true
ftpserver.user.admin.maxloginnumber=0
ftpserver.user.admin.maxloginperip=0
ftpserver.user.admin.idletime=0
ftpserver.user.admin.uploadrate=0
ftpserver.user.admin.downloadrate=0

according to the contents above:
We now know that this config file defines what is the pwd and its zone space of users. Take this xml file for example, it shows the username “user” and password “admin” and its uploading and downloading space “./res/home/localhost”

We know that there is a sh script plus a confi file with its user config file.
Secondly, we notice that there is space for the designated ftpServer, where all users registering share.
Therefore, if we want to create multiple instances of GTP server locally. What we need to do is to reconfigure these sets of files.

2.2 Configure 2 ftp servers

1 enter the “conf” directory,
use the following cmd to create these new config files:

cat ftpd-typical.xml >> ftpd-typical_8022.xml >> ftpd-typical_8023
cat users.properties >> users_8022.properties >> users_8023.properties

2 modify some items in these files according to the below templates

(1) ftpd-typical_8022.xml

<?xml version="1.0" encoding="UTF-8"?>
<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 http://mina.apache.org/ftpserver/ftpserver-1.0.xsd	
	   "
	id="myServer">
	<listeners>
		<nio-listener name="default" port="8022">
		    <ssl>
                <keystore file="./res/ftpserver.jks" password="password" />
            </ssl>
		</nio-listener>
	</listeners>
	<file-user-manager file="./res/conf/users_8022.properties" />
</server>

(2) users_8022.properties

# Password is "admin"
ftpserver.user.admin.userpassword=21232F297A57A5A743894A0E4A801FC3
ftpserver.user.admin.homedirectory=./res/home/localhost8022
ftpserver.user.admin.enableflag=true
ftpserver.user.admin.writepermission=true
ftpserver.user.admin.maxloginnumber=0
ftpserver.user.admin.maxloginperip=0
ftpserver.user.admin.idletime=0
ftpserver.user.admin.uploadrate=0
ftpserver.user.admin.downloadrate=0

ftpserver.user.anonymous.userpassword=
ftpserver.user.anonymous.homedirectory=./res/home/localhost8022
ftpserver.user.anonymous.enableflag=true
ftpserver.user.anonymous.writepermission=false
ftpserver.user.anonymous.maxloginnumber=20
ftpserver.user.anonymous.maxloginperip=2
ftpserver.user.anonymous.idletime=300
ftpserver.user.anonymous.uploadrate=4800
ftpserver.user.anonymous.downloadrate=4800

(3) ftpd-typical_8023

<?xml version="1.0" encoding="UTF-8"?>

<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 http://mina.apache.org/ftpserver/ftpserver-1.0.xsd	
	   "
	id="myServer">
	<listeners>
		<nio-listener name="default" port="8023">
		    <ssl>
                <keystore file="./res/ftpserver.jks" password="password" />
            </ssl>
		</nio-listener>
	</listeners>
	<file-user-manager file="./res/conf/users_8023.properties" />
</server>

(4) users_8023.properties

# Password is "admin"
ftpserver.user.admin.userpassword=21232F297A57A5A743894A0E4A801FC3
ftpserver.user.admin.homedirectory=./res/home/localhost8023
ftpserver.user.admin.enableflag=true
ftpserver.user.admin.writepermission=true
ftpserver.user.admin.maxloginnumber=0
ftpserver.user.admin.maxloginperip=0
ftpserver.user.admin.idletime=0
ftpserver.user.admin.uploadrate=0
ftpserver.user.admin.downloadrate=0

ftpserver.user.anonymous.userpassword=
ftpserver.user.anonymous.homedirectory=./res/home/localhost8023
ftpserver.user.anonymous.enableflag=true
ftpserver.user.anonymous.writepermission=false
ftpserver.user.anonymous.maxloginnumber=20
ftpserver.user.anonymous.maxloginperip=2
ftpserver.user.anonymous.idletime=300
ftpserver.user.anonymous.uploadrate=4800
ftpserver.user.anonymous.downloadrate=4800

3 Entering the res/home directory
use the following cmds:

mkdir localhost8022 localhost80233
chmod 777 localhost8022 localhost8023

to make ftp server’s space and impart authorities of read,write, and execute to all users.

2.3 let’s start the two ftp servers created just now

(1) use the following cmds to start the 2 servers.(alert: This is because of ftpd.sh not a global shell cmd, we need to use “sh” cmd to execute the script.)

sh ftpd.sh res/conf/ftpd-typical_8022.xml
sh ftpd.sh res/conf/ftpd-typical_8023.xml

if this error " We cannot execute /System/Library/Frameworks/JavaVM.framework/Home/bin/java" exists when mac executes the cmds above. we just need to export JAVA_HOME variable by “export JAVA_HOME=$(/usr/libexec/java_home)”
在这里插入图片描述

(2) observe the space by web page:
you can input the “ftp://127.0.0.1:8022/” directly and then you will see the ftp zone
you can input the “ftp://127.0.0.1:8023/” directly and then you will see the other ftp zone

(3) by cmd of mac:

Firstly, your OS must install the FTP command. you can draw upon this link https://www.jianshu.com/p/10c4e46c77f1
open a new cmd by shortcuts “command + N” in old cmd:
input the ”ftp“,
input “open 127.0.0.1 8022”

open another new cmd by shortcuts “command + N” in old cmd:
input the ”ftp“,
input “open 127.0.0.1 8023”

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值