Finology 大数据金融

通过大数据以量化金融

通过yum安装vsftpd

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
yum install vsftpd

Is this ok [y/d/N]: y
Downloading packages:
vsftpd-3.0.2-22.el7.x86_64.rpm | 169 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : vsftpd-3.0.2-22.el7.x86_64 1/1
验证中 : vsftpd-3.0.2-22.el7.x86_64 1/1

已安装:
vsftpd.x86_64 0:3.0.2-22.el7

完毕!

新建一个上传文件夹

用于存放通过ftp上传的文件

1
2
3
4
pwd
/usr/local

mkdir ftpfile

新建一个ftp用户

新建ftpuser用户,该用户登录后的地址为/usr/local/ftpfile,这个用户不能登录系统

1
useradd ftpuser -d /ftpfile -s /sbin/nologin

修改/usr/local/ftpfile文件夹的权限

1
2
3
4
5
6
7
ll | grep ftpfile
drwxr-xr-x 2 root root 6 6月 10 14:05 ftpfile

chown -R ftpuser.ftpuser ftpfile/

ll | grep ftpfile
drwxr-xr-x 2 ftpuser ftpuser 6 6月 10 14:05 ftpfile

为用户ftpuser添加密码

1
passwd ftpuser

修改vsftpd配置文件

1
2
3
4
5
6
7
8
9
10
11
12
13
vi /etc/vsftpd/vsftpd.conf

ftpd_banner=Welcome to simon's FTP service.

local_root=/usr/local/ftpfile # 添加本地根目录
anon_root=/usr/local/ftpfile #
use_localtime=yes

chroot_list_enable=YES # 修改
# (default follows)
chroot_list_file=/etc/vsftpd/chroot_list # 修改

anonymous_enable=NO

把用户ftpuser添加到/etc/vsftpd/chroot_list

1
vi /etc/vsftpd/chroot_list

添加一行记录,内容为:ftpuser

设置传输文件时的端口号

1
2
pasv_min_port=61001
pasv_max_port=62000

设置pasv被动传输的端口号,这样可以通过防火墙开放这个范围内的端口,从而更加安全。

启动vsftpd

1
2
service vsftpd start
Redirecting to /bin/systemctl start vsftpd.service

测试

在浏览器上输入:ftp://192.168.1.30/
输入用户名和密码后,貌似不能进去。

或者在终端输入

1
2
3
4
5
6
7
8
9
ftp 192.168.1.30

Connected to 192.168.1.30.
220 Welcome to simon's FTP service.
Name (192.168.1.30:simon): ftpuser
331 Please specify the password.
Password:
500 OOPS: vsftpd: refusing to run with writable root inside chroot()
ftp: Login failed

会出现以上错误,所以还需要在配置文件里面加入如下参数:

1
allow_writeable_chroot=YES # 如果local_root是可写的就要设置这句

重启vsftpd服务后,再次登录,就成功了

1
2
3
4
5
6
7
8
9
10
ftp 192.168.1.30
Connected to 192.168.1.30.
220 Welcome to simon's FTP service.
Name (192.168.1.30:simon): ftpuser
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp>

提示

1
#chroot_local_user=YES

默认为NO,表示用户能看到的最上层目录为/ftpfile。如果改为yes,那用户可以看到整个系统的目录结构。

下载tomcat7的tar.gz压缩文件

解压到/usr/local目录

1
$ tar -zxvf apache-tomcat-8.5.31.tar.gz

编译server.xml文件,修改编码

1
2
$ cd apache-tomcat-8.5.31/
$ vi conf/server.xml

找到这一行

1
2
3
4
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />

增加URIEncoding=”UTF-8”,替换为

1
2
3
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" URIEncoding="UTF-8" />

启动Tomcat7

1
2
3
4
5
6
7
bin/startup.sh 
Using CATALINA_BASE: /usr/local/apache-tomcat-8.5.31
Using CATALINA_HOME: /usr/local/apache-tomcat-8.5.31
Using CATALINA_TMPDIR: /usr/local/apache-tomcat-8.5.31/temp
Using JRE_HOME: /usr
Using CLASSPATH: /usr/local/apache-tomcat-8.5.31/bin/bootstrap.jar:/usr/local/apache-tomcat-8.5.31/bin/tomcat-juli.jar
Tomcat started.

查看本地ip地址

1
2
3
4
5
ifconfig

eno16777736: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.30 netmask 255.255.255.0 broadcast 192.168.1.255
...

访问http://192.168.1.30:8080
出现下图

表示tomcat7安装并启动成功了。

CentOS7默认的yum源的地址是http://mirror.centos.org,需要把其换成国内的镜像,这样访问速度会更加快一些。

  1. 备份系统默认的CentOS-Base.repo
1
$ mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
  1. 下载阿里云的repo文件
1
2
$ cd /etc/yum.repos.d/
$ wget -c http://mirrors.aliyun.com/repo/Centos-7.repo
  1. 生成缓存
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
$ yum makecache

已加载插件:fastestmirror, langpacks
http://mirrors.aliyuncs.com/centos/7/os/x86_64/repodata/repomd.xml: [Errno 12] Timeout on http://mirrors.aliyuncs.com/centos/7/os/x86_64/repodata/repomd.xml: (28, 'Connection timed out after 30181 milliseconds')
正在尝试其它镜像。
base | 3.6 kB 00:00
extras | 3.4 kB 00:00
updates | 3.4 kB 00:00
(1/5): extras/7/x86_64/filelists_db | 519 kB 00:00
(2/5): extras/7/x86_64/other_db | 95 kB 00:00
(3/5): updates/7/x86_64/filelists_db | 1.3 MB 00:01
(4/5): base/7/x86_64/filelists_db | 6.9 MB 00:03
(5/5): extras/7/x86_64/prestodelta | 48 kB 00:11
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
元数据缓存已建立
0%