1.基于域名[www.openlab.com](http://www.openlab.com)可以访问网站内容为 welcome to openlab!!!2.给该公司创建三个子界面分别显示学生信息

fnag网站需求:

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

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

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

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

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

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

2、开放/nfs/upload目录,为192.168.xxx.0/24网段主机可以上传目录,

并将所有用户及所属的组映射为nfs-upload,其UID和GID均为210

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

读题分析:

访问 www.openlab.com (http://www.openlab.com)-> welcome to openlab!!!

三个子网: 

学生信息(只能songtian访问):www.openlab.com/student

教学资料:www.openlab.com/data

缴费网站:www.openlab.com/money(https://www.openlab.com/money)

配置NFS服务器

1./nfs/shared,供所有用户查询资料  ro

2./nfs/upload,为192.168.xxx.0/24网段主机可以上传目录  rw

3.将所有用户及所属的组映射为nfs-upload,其UID和GID均为210openlab   rw

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

 一.访问openlab以及三个子网:

#首先关闭防火墙
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# setenforce 0
[root@localhost ~]# getenforce
Permissive
[root@localhost ~]# yum install -y httpd
OS                                                 5.0 kB/s | 1.9 kB     00:00
everything                                         5.2 kB/s | 1.9 kB     00:00
EPOL                                               5.1 kB/s | 1.9 kB     00:00
debuginfo                                          6.1 kB/s | 2.2 kB     00:00
source                                             5.5 kB/s | 2.2 kB     00:00
update                                             5.2 kB/s | 1.9 kB     00:00
update-source                                      6.3 kB/s | 2.2 kB     00:00
Package httpd-2.4.55-3.oe2309.x86_64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!
[root@localhost ~]# systemctl enable httpd
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
[root@localhost ~]# vim /etc/nginx/conf.d/test_httpd.conf

server {
        listen 192.168.168.129:80;
        root /www/name/openlab;
        server_name www.openlab.com;
        location / {
                index index.html;
        }
}
server {
        listen 192.168.168.129:80;
        root /www/name/openlab/student;
        server_name www.openlab.com/student;
        location / {
                index index.html;
        }
}
server {
        listen 192.168.168.129:80;
        root /www/name/openlab/data;
        server_name www.openlab.com/data;
        location / {
                index index.html;
        }
}
server {
        listen 192.168.168.129:80;
        root /www/name/openlab/money;
        server_name www.openlab.com/money;
        location / {
                index index.html;
        }
}
[root@localhost ~]# mkdir -pv /www/name/openlab/{student,data,money}
mkdir: 已创建目录 '/www/name'
mkdir: 已创建目录 '/www/name/openlab'
mkdir: 已创建目录 '/www/name/openlab/student'
mkdir: 已创建目录 '/www/name/openlab/data'
mkdir: 已创建目录 '/www/name/openlab/money'
[root@localhost ~]# echo welcome to openlab  >   /www/name/openlab/index.html
[root@localhost ~]# echo 这是学生信息网  >   /www/name/openlab/student/index.html
[root@localhost ~]# echo 这是教学资料网  >   /www/name/openlab/data/index.html
[root@localhost ~]# echo 这是缴费网  >   /www/name/openlab/money/index.html
[root@localhost ~]# systemctl restart nginx

这里我用的另一台虚拟机来验证访问网站,所以必须在其/etc/hosts文件中添加网站对应IP地址

[root@192 ~]# vim /etc/hosts
# Loopback entries; do not change.
# For historical reasons, localhost precedes localhost.localdomain:
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
# See hosts(5) for proper format and other examples:
# 192.168.1.10 foo.mydomain.org foo
# 192.168.1.13 bar.mydomain.org bar
192.168.168.129  www.openlab.com
192.168.168.129  www.openlab.com/student
192.168.168.129  www.openlab.com/data
192.168.168.129  www.openlab.com/money

[root@192 ~]# curl http://www.openlab.com
welcome to openlab
[root@192 ~]# curl http://www.openlab.com/student/
这是学生信息网
[root@192 ~]# curl http://www.openlab.com/data/
这是教学资料网
[root@192 ~]# curl http://www.openlab.com/money/
这是缴费网

 学生网只能song和tian访问:

#增加用户:
[root@node1 ~]# htpasswd  -c /etc/nginx/users song
New password: 
Re-type new password: 
Adding password for user song
[root@node1 ~]# htpasswd  -c /etc/nginx/users tian
New password: 
Re-type new password: 
Adding password for user tian

#修改配置文件
[root@localhost ~]# vim /etc/nginx/conf.d/test_httpd.conf
server {
        listen 192.168.168.129:80;
        root /www/name/openlab/student;
        server_name www.openlab.com/student;
        location / {
                index index.html;
                auth_basic on;
                auth_basic_user_file /etc/nginx/users;
        }
}

 

二,访问缴费网时需要https: 

[root@localhost ~]# vim /etc/nginx/conf.d/test_https.conf
server {
        listen 192.168.168.129:443 ssl;
        root /www/name/openlab/money/;
        ssl_certificate /etc/pki/tls/certs/openlab.crt;
        ssl_certificate_key /etc/pki/tls/private/openlab.key;
        location / {
                index index.html;
        }
}

[root@localhost ~]# openssl req -utf8 -new -key openlab.key -x509 -days 365 -out openlab.crt
Could not read private key from openlab.key
[root@localhost ~]# openssl genrsa -out /etc/pki/tls/private/openlab.key
[root@localhost ~]# openssl req -utf8 -new -key /etc/pki/tls/private/openlab.key  -x509 -days 365 -out /etc/pki/tls/certs/openlab.crt
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:86
State or Province Name (full name) [Some-State]:xi'an
Locality Name (eg, city) []:shannxi
Organization Name (eg, company) [Internet Widgits Pty Ltd]:open
Organizational Unit Name (eg, section) []:ce
Common Name (e.g. server FQDN or YOUR name) []:local
Email Address []:admin

[root@localhost ~]# systemctl restart nginx

然后用另外一台虚拟机验证:
 

[root@192 ~]# curl https://192.168.168.129 -k
这是缴费网

 

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

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

服务器配置: 

#安装对应包
[root@localhost ~]#yum install rpcbind
OS                                                 2.2 kB/s | 1.9 kB     00:00
everything                                         2.6 kB/s | 1.9 kB     00:00
EPOL                                               4.3 kB/s | 1.9 kB     00:00
debuginfo                                          4.0 kB/s | 2.2 kB     00:00
source                                             4.1 kB/s | 2.2 kB     00:00
update                                             357  B/s | 1.9 kB     00:05
update-source                                      410  B/s | 2.2 kB     00:05
Package rpcbind-1.2.6-8.oe2309.x86_64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!
[root@localhost ~]# yum install nfs-utils
Last metadata expiration check: 0:00:13 ago on 2024年01月14日 星期日 09时15分38秒.
Package nfs-utils-2:2.6.2-4.oe2309.x86_64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!

#关闭防火墙
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# setenforce 0
[root@localhost ~]# systemctl start nfs-server

#创建对应文件夹
[root@localhost ~]# mkdir /nfs/shared -pv
mkdir: 已创建目录 '/nfs'
mkdir: 已创建目录 '/nfs/shared'
[root@localhost ~]# mkdir /nfs/upload -pv
mkdir: 已创建目录 '/nfs/upload'
[root@localhost ~]# mkdir /home/tom -pv
mkdir: 已创建目录 '/home/tom'

#分别创建5个文件,方便在客户端查看是否共享
[root@localhost ~]# touch /nfs/shared/{1..5}
[root@localhost ~]# touch /nfs/upload/{1..5}
[root@localhost ~]# touch /home/tom/{1..5}

#编辑配置文件
[root@localhost ~]# vim /etc/exports
/nfs/shared  *(ro,anonuid=210,anongid=210)
/nfs/upload  192.168.168.136/24(rw,anonuid=210,anongid=210)
/home/tom  192.168.168.136/24(rw,anonuid=210,anongid=210)

#导出配置
[root@localhost ~]# exportfs -r

客户端配置:

#安装对应包
[root@192 ~]# yum install -y nfs-utils -y
OS                                                 4.8 kB/s | 1.9 kB     00:00
everything                                         3.5 kB/s | 1.9 kB     00:00
EPOL                                               1.9 kB/s | 1.9 kB     00:01
debuginfo                                          2.7 kB/s | 2.2 kB     00:00
source                                             4.3 kB/s | 2.2 kB     00:00
update                                             2.3 kB/s | 1.9 kB     00:00
update-source                                      4.2 kB/s | 2.2 kB     00:00
Package nfs-utils-2:2.6.2-4.oe2309.x86_64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!

#创建对应文件夹(存放共享文件)
[root@192 ~]# mkdir /nfs
[root@192 ~]# mkdir /nfs/shared
[root@192 ~]# mkdir /nfs/upload

#挂载对应文件
[root@192 ~]# mount 192.168.168.129:/nfs/shared /nfs/shared
[root@192 ~]# mount 192.168.168.129:/nfs/upload /nfs/upload
[root@192 ~]# mount 192.168.168.129:/home/tom  /nfs/tom

#验证是否挂载成功
[root@192 ~]# ll /nfs/shared
总计 0
-rw-r--r--. 1 root root 0  1月14日 09:18 1
-rw-r--r--. 1 root root 0  1月14日 09:18 2
-rw-r--r--. 1 root root 0  1月14日 09:18 3
-rw-r--r--. 1 root root 0  1月14日 09:18 4
-rw-r--r--. 1 root root 0  1月14日 09:18 5

[root@192 ~]# ll /nfs/upload/
总计 0
-rw-r--r--. 1 root root 0  1月14日 09:18 1
-rw-r--r--. 1 root root 0  1月14日 09:18 2
-rw-r--r--. 1 root root 0  1月14日 09:18 3
-rw-r--r--. 1 root root 0  1月14日 09:18 4
-rw-r--r--. 1 root root 0  1月14日 09:18 5
[root@192 ~]# ll /nfs/tom/
总计 0
-rw-r--r--. 1 root root 0  1月14日 09:29 1
-rw-r--r--. 1 root root 0  1月14日 09:29 2
-rw-r--r--. 1 root root 0  1月14日 09:29 3
-rw-r--r--. 1 root root 0  1月14日 09:29 4
-rw-r--r--. 1 root root 0  1月14日 09:29 5

#因为upload具有写入权限,这里也是成功创建
[root@192 ~]# touch /nfs/upload/6
[root@192 ~]# ll /nfs/upload/
总计 0
-rw-r--r--. 1 root root 0  1月14日 09:18 1
-rw-r--r--. 1 root root 0  1月14日 09:18 2
-rw-r--r--. 1 root root 0  1月14日 09:18 3
-rw-r--r--. 1 root root 0  1月14日 09:18 4
-rw-r--r--. 1 root root 0  1月14日 09:18 5
-rw-r--r--. 1  210  210 0  1月14日 10:07 6

3.将/home/tom目录仅共享给192.168.xxx.xxx这台主机,并只有用户tom可以完全访问该目录(这一题还不知道怎么弄)

  • 10
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值