一.关于文件服务器
二.使用Apache搭建文件服务器
1.Apache服务在linux环境下的程序叫作httpd,因此首先安装httpd服务,若是配置好了yum源的话,直接使用yum命令安装,若是没有配置好yum源的话,能够参考博客“linux 配置本地yum源,配置国内yum源,配置epel源”进行配置, 址为:https://www.cnblogs.com/renshengdezheli/p/13949693.htmljava
[root@node5 ~]# yum -y install httpd
2.启动httpd服务node
#启动httpd服务
[root@node5 ~]# systemctl start httpd
#查看httpd服务状态
[root@node5 ~]# systemctl status httpd
● httpd.service – The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
Active: active (running) since Thu 2020-12-17 16:26:05 CST; 7s ago
Docs: man:httpd(8)
man:apachectl(8)
Main PID: 98576 (httpd)
Status: “Processing requests…”
CGroup: /system.slice/httpd.service
├─98576 /usr/sbin/httpd -DFOREGROUND
├─98577 /usr/sbin/httpd -DFOREGROUND
├─98578 /usr/sbin/httpd -DFOREGROUND
├─98579 /usr/sbin/httpd -DFOREGROUND
├─98580 /usr/sbin/httpd -DFOREGROUND
└─98581 /usr/sbin/httpd -DFOREGROUND
Dec 17 16:26:05 node5 systemd[1]: Starting The Apache HTTP Server…
Dec 17 16:26:05 node5 httpd[98576]: AH00558: httpd: Could not reliably determine the server’s fully qualified domain name, using 192.168.110.184. Set the ‘ServerName’ directive globally to su…ss this message
Dec 17 16:26:05 node5 systemd[1]: Started The Apache HTTP Server.
Hint: Some lines were ellipsized, use -l to show in full.
#查看Apache版本
[root@node5 ~]# httpd -version
Server version: Apache/2.4.6 (CentOS)
Server built: Nov 16 2020 16:18:20
3.查看IP地址,访问Apache页面linux
#能够看到本机IP地址为192.168.110.184
[root@node5 soft]# ifconfig
ens33: flags=4163 mtu 1500
inet 192.168.110.184 netmask 255.255.255.0 broadcast 192.168.110.255
ether 00:0c:29:11:c4:4a txqueuelen 1000 (Ethernet)
RX packets 24682 bytes 13301526 (12.6 MiB)
RX errors 0 dropped 4 overruns 0 frame 0
TX packets 15119 bytes 2166095 (2.0 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73 mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10
loop txqueuelen 1 (Local Loopback)
RX packets 2402 bytes 221903 (216.7 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 2402 bytes 221903 (216.7 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
在浏览器里访问http://192.168.110.184/,若是出现以下界面说明Apache服务安装成功nginx
7.经过 页咱们发现中文是乱码,能够修改配置文件使中文正常显示tomcat
#在Apache配置文件的末尾追加一行
[root@node5 ~]# echo “IndexOptions Charset=UTF-8” >> /etc/httpd/conf/httpd.conf
[root@node5 ~]# systemctl restart httpd
再次访问 页http://192.168.110.184/file/,发现页面的中文正常显示了

三.测试文件服务器是否可用
1.在windows上使用浏览器访问http://192.168.110.184/file/,若是页面能够打开,而且点击软件会自动下载,说明经过windows下载文件成功。
2.在局域 内的另一台linux机器上测试是否能够下载文件
#首先在node8机器上使用root帐户测试下载文件
#使用wget命令下载文件
[root@node8 ~]# wget http://192.168.110.184/file/饼干.txt
–2020-12-17 16:53:00– http://192.168.110.184/file/%E9%A5%BC%E5%B9%B2.txt
Connecting to 192.168.110.184:80… connected.
HTTP request sent, awaiting response… 200 OK
Length: 1181 (1.2K) [text/plain]
Saving to: ‘饼干.txt’
100%[=======================================================================================================================================================================>] 1,181 –.-K/s in 0s
2020-12-17 16:53:00 (130 MB/s) – ‘饼干.txt’ saved [1181/1181]
[root@node8 ~]# wget http://192.168.110.184/file/today_db.tar.gz
–2020-12-17 16:53:26– http://192.168.110.184/file/today_db.tar.gz
Connecting to 192.168.110.184:80… connected.
HTTP request sent, awaiting response… 200 OK
Length: 767 [application/x-gzip]
Saving to: ‘today_db.tar.gz’
100%[=======================================================================================================================================================================>] 767 –.-K/s in 0s
2020-12-17 16:53:26 (268 MB/s) – ‘today_db.tar.gz’ saved [767/767]
#发现文件能正常下载
[root@node8 ~]# ls 饼干.txt today_db.tar.gz
today_db.tar.gz 饼干.txt
#使用node8机器上的普通帐户file1测试下载文件
[root@node8 ~]# useradd file1
[root@node8 ~]# echo “123456” | passwd –stdin file1
Changing password for user file1.
passwd: all authentication tokens updated successfully.
[root@node8 ~]# su – file1
[file1@node8 ~]$ pwd
/home/file1
[file1@node8 ~]$ ls
[file1@node8 ~]$ wget http://192.168.110.184/file/饼干.txt
–2020-12-17 17:44:10– http://192.168.110.184/file/%E9%A5%BC%E5%B9%B2.txt
Connecting to 192.168.110.184:80… connected.
HTTP request sent, awaiting response… 200 OK
Length: 1181 (1.2K) [text/plain]
Saving to: ‘饼干.txt’
100%[=======================================================================================================================================================================>] 1,181 –.-K/s in 0s
2020-12-17 17:44:10 (254 MB/s) – ‘饼干.txt’ saved [1181/1181]
[file1@node8 ~]$ wget http://192.168.110.184/file/today_db.tar.gz
–2020-12-17 17:44:20– http://192.168.110.184/file/today_db.tar.gz
Connecting to 192.168.110.184:80… connected.
HTTP request sent, awaiting response… 200 OK
Length: 767 [application/x-gzip]
Saving to: ‘today_db.tar.gz’
100%[=======================================================================================================================================================================>] 767 –.-K/s in 0s
2020-12-17 17:44:20 (216 MB/s) – ‘today_db.tar.gz’ saved [767/767]
#发现能正常下载文件
[file1@node8 ~]$ ls
today_db.tar.gz 饼干.txt
自此文件服务器搭建成功,功能正常。
文章知识点与官方知识档案匹配,可进一步学习相关知识CS入门技能树Linux入门初识Linux25157 人正在系统学习中 相关资源:…智慧农业信息化建设解决方案-管理软件文档类资源-CSDN文库
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!