nfs+http综合练习
配置nfs服务器和web服务器
1.配置nfs服务器,要求将两个网站的资源文件通过nfs服务器共享给web服务器。
#通过两个共享目录分别网页文件例如:/openlab/index.html/xianoupeng/index.html(网页文件内容自定义)。
2.通过nfs共享网页文件,配置web服务实现www.openlab.com以及www.xianoupeng.com访问各自的网站信息。
无论是服务端还是客户端首先关闭防火墙和selinux
[root@localhost ~]
[root@localhost ~]
S服务器端配置(ip:192.168.164.128):
要部署NFS服务,必须安装下面两个软件包:nfs-utils:NFS主程序,rpcbind:PRC主程序 #查看NFS软件包
[root@localhost ~]
sssd-nfs-idmap-2.2.3-20.el8.x86_64
rpcbind-1.2.5-7.el8.x86_64
libnfsidmap-2.3.3-31.el8.x86_64
nfs-utils-2.3.3-31.el8.x86_64
启动nfs服务
[root@localhost ~]
查看nfs服务运行状态(Active:active 说明启动成功)
[root@localhost ~]
● nfs-server.service - NFS server and services
Loaded: loaded (/usr/lib/systemd/system/nfs-server.service; disabled; vendor preset: disabled)
Active: active (exited) since Sun 2021-07-11 07:13:02 EDT; 2s ago
Process: 3567 ExecStart=/bin/sh -c if systemctl -q is-active gssproxy; then systemctl reload gssprox>
Process: 3553 ExecStart=/usr/sbin/rpc.nfsd (code=exited, status=0/SUCCESS)
Process: 3552 ExecStartPre=/usr/sbin/exportfs -r (code=exited, status=0/SUCCESS)
Main PID: 3567 (code=exited, status=0/SUCCESS)
当nfs服务启动成功时会相应的启动rpc服务
[root@localhost ~]
● rpc-statd-notify.service - Notify NFS peers of a restart
Loaded: loaded (/usr/lib/systemd/system/rpc-statd-notify.service; static; vendor preset: disabled)
Active: active (exited) since Sun 2021-07-11 06:43:38 EDT; 30min ago
Process: 1137 ExecStart=/usr/sbin/sm-notify (code=exited, status=0/SUCCESS)
Tasks: 0 (limit: 23663)
Memory: 0B
CGroup: /system.slice/rpc-statd-notify.service
创建目录文件openlab,xianoupeng以及创建index.html网页文件
[root@localhost ~]
[root@localhost ~]
[root@localhost ~]
[root@localhost ~]
编写nfs配置文件
[root@localhost ~]
/openlab *(rw)
/xianoupeng *(rw)
C客户端配置(ip:192.168.164.129):
创建两个目录并进行挂载
[root@localhost ~]
[root@localhost ~]
[root@localhost ~]
[root@localhost ~]
查看文件是否共享
[root@localhost ~]
[root@localhost openlab]
this is openlab
编写yum仓库并下载httpd服务器
[root@localhost openlab]
[root@localhost openlab]
[BaseOS]
name=BaseOS
baseurl=file:///mnt/BaseOS
gpgcheck=0
[AppStream]
name=AppStream
baseurl=file:///mnt/AppStream
gpgcheck=0
[root@localhost openlab]
启动web服务并编写配置文件
[root@localhost ~]
[root@localhost ~]
<VirtualHost 192.168.164.129:80>
ServerName www.openlab.com
DocumentRoot /openlab
</VirtualHost>
<Directory /openlab>
AllowOverride none
Require all granted
</Directory>
<VirtualHost 192.168.164.129:80>
ServerName www.xianoupeng.com
DocumentRoot /xianoupeng
</VirtualHost>
<Directory /xianoupeng>
AllowOverride none
Require all granted
</Directory>
在Linux下hosts添加两行代码
[root@localhost ~]
192.168.164.129 www.openlab.com
192.168.164.129 www.xianoupeng.com
在window下C:\Windows\System32\drivers\etc\hosts添加两行代码
192.168.164.129 www.openlab.com
192.168.164.129 www.xianoupeng.com
重启httpd服务
[root@localhost ~]
在测试Linux中测试:(只写Linux中的hosts)
[root@localhost ~]
this is openlab
[root@localhost ~]
this is xianoupeng
[root@localhost ~]
在测试window中测试(既要写Linux中的hosts又要写window中的hosts):
|