1.基于域名[www.openlab.com](http://www.openlab.com)可以访问网站内容为 welcome to openlab!!!

[root@localhost ~]# systemctl stop firewalld.service  #关闭防火墙

[root@localhost ~]# setenforce 0 #关闭selinux

[root@localhost www]# vim /etc/nginx/conf.d/test_openlab.conf #在conf.d目录下创建配置文件

[root@localhost www]# mkdir /www/test1 -pv #创建要打开的html文件目录

[root@localhost www]# echo this is openlab > /www/test1/index.html #创建html文件

[root@localhost www]# systemctl restart nginx.service #重启nginx应用

因为这并不是一个真正的公网域名所以需要修改相关配置文件

使用windows访问 需要进入C:\Windows\System32\drivers\etc\hosts文件中绑定域名和ip

尝试访问

2.给该公司创建三个子界面分别显示学生信息,教学资料和缴费网站,基于[www.openlab.com/student](http://www.openlab.com/student) 网站访问学生信息,[www.openlab.com/data](http://www.openlab.com/data)网站访问教学资料,网站访问缴费网站(http://www.openlab.com/money网站访问缴费网站)。

[root@localhost www]# vim /etc/nginx/conf.d/test_openlab.conf #进入配置文件中写入虚拟目录

[root@localhost www]# mkdir /openlab/{student,data,money} -pv #虽然是虚拟目录但是却是真是存在的只是使用alias进行了重定向了真实存在的目录

在目录中创建需要访问的html文件

[root@localhost www]# echo this is student > /openlab/student/index.html [root@localhost www]# echo this is data > /openlab/data/index.html [root@localhost www]# echo this is money > /openlab/money/index.html

[root@localhost www]# systemctl restart nginx.service #重启nginx服务

尝试访问

3.要求

(1)学生信息网站只有song和tian两人可以访问,其他用户不能访问。 ​

[root@localhost www]# vim /etc/nginx/conf.d/test_openlab.conf #进入配置文件

#在sutdent中开启用户认证

#在/etc/nginx/users文件中创建用户

[root@localhost www]# systemctl restart nginx.service  #重启nginx服务

尝试访问

输入用户名密码  可以成功访问

(2)访问缴费网站实现数据加密基于https访问。

[root@localhost www]# vim /etc/nginx/conf.d/test_openlab.conf  #进入配置文件

#监听443端口 并启用ssl

[root@localhost www]# openssl genrsa -out /etc/pki/tls/private/openlab.key #在默认文件夹下创建私钥

[root@localhost www]# openssl req -utf8 -new -key /etc/pki/tls/private/openlab.key -x509 -days 365 -out /etc/pki/tls/certs/openlab.crt  #创建证书

[root@localhost www]# systemctl restart nginx #重启nginx服务

尝试访问

架设一台NFS服务器,并按照以下要求配置

1、开放/nfs/shared目录,供所有用户查询资料

服务端

[root@localhost ~]# systemctl stop firewalld.service #关闭防火墙 [root@localhost ~]# setenforce 0 #关闭selinux [root@localhost ~]# yum install rpcbind  #下载rpc远程过程调用协议 [root@localhost ~]# yum install nfs-utils  #下载nfs服务 [root@localhost ~]# systemctl restart nfs-server #启动nfs服务 [root@localhost ~]# mkdir /nfs/shared -pv  #创建文件夹 [root@localhost ~]# touch /nfs/shared/{1..5}  #在文件夹中创建文件 [root@localhost ~]# vim /etc/exports  #进入nfs配置文件编写配置 [root@localhost ~]# exportfs -r  #重新挂载 客户端 [root@bogon ~]# yum install nfs-utils  #下载nfs服务 [root@bogon ~]# mkdir /test_nfs  #创建一个用于挂载的文件夹 [root@bogon ~]# mount 192.168.182.132:/nfs/shared /test_nfs/ #将服务器提供的目录挂载在创建好的文件夹上

2、开放/nfs/upload目录,为192.168.xxx.0/24网段主机可以上传目录,并将所有用户及所属的组映射为nfs-upload,其UID和GID均为210

服务端 [root@localhost ~]# systemctl stop firewalld.service #关闭防火墙 [root@localhost ~]# setenforce 0 #关闭selinux [root@localhost ~]# yum install nfs-utils  #下载nfs服务 [root@localhost ~]# systemctl restart nfs-server #启动nfs服务 [root@localhost ~]# mkdir /nfs/upload  #创建文件夹 [root@localhost ~]# vim /etc/exports  #进入nfs配置文件编写配置 [root@localhost ~]# chmod o+w /nfs/upload/   #修改目录权限 [root@localhost ~]# useradd -u 210 -r nfs-upload   #创建nfs-upload用户 [root@localhost ~]# exportfs -r   #重新读取

客户端 [root@bogon ~]# mkdir /test_nfs_uplod  #创建目录 [root@bogon ~]# mount 192.168.182.132:/nfs/upload    /test_nfs_uplod  #挂载 [root@localhost ~]# touch /test_nfs_uplod/a        #创建文件

返回服务端查看创建结果

3、将/home/tom目录仅共享给192.168.xxx.xxx这台主机,并只有用户tom可以完全访问该目录

服务端 [root@localhost ~]# systemctl stop firewalld.service #关闭防火墙 [root@localhost ~]# setenforce 0 #关闭selinux [root@localhost ~]# yum install nfs-utils  #下载nfs服务 [root@localhost ~]# systemctl restart nfs-server #启动nfs服务 [root@localhost ~]# vim /etc/exports        #编写配置文件 [root@localhost ~]# useradd tom         #创建tom用户 [root@localhost ~]# exportfs -r   #重新读取

客户端 [root@localhost ~]# mkdir /test_nfs_tom        #创建用于挂载的文件夹 [root@localhost ~]# mount 192.168.182.132:/home/tom /test_nfs_tom        #挂载 #用root身份访问发现无法打开

服务端 [root@localhost ~]# id tom​​​​​​​        #在服务端查看tom的用户id

客户端 [root@localhost ~]# useradd -u 1001 tom        #创建相同uid和gid的用户 [tom@localhost root]$ ll /test_nfs_tom/​​​​​​​        #查看是否可以访问 [tom@localhost root]$ touch /test_nfs_tom/a        #创建文件

#在服务端查看是否创建成功

参考阅读

评论可见,请评论后查看内容,谢谢!!!评论后请刷新页面。