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 localhost8023
chmod 777 localhost8022 localhost8023
to make ftp server’s space and impart authorities of read,write, and execute to all users.
let’s start the two ftp servers created just now
(1) start it 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
(2) 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”