RHCE:web服务器+nfs服务器搭建

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

1、准备服务端(采用OpenEuler系统)

2、具体配置

#下载nginx
[root@server ~]# yum install  nginx  -y 

#关闭防火墙
1、[root@server ~]# systemctl stop firewalld
2、[root@server ~]# setenforce 0

#修改配置文件
[root@server ~]# vim /etc/nginx/conf.d/test_name.conf 
server {
        listen 192.168.157.140:80;
        root /www/name/node1;
        server_name www.openlab.com;
        location / { 
        }
}

#创建网页目录
[root@server ~]# mkdir -pv /www/name/node1

#写入网页内容
[root@server ~]# vim /www/name/node1/index.html
welcome to openlab!!!

#重启nginx
[root@server ~]# systemctl restart nginx

在windows系统上以管理员身份打开记事本,编辑C:\Windows\System32\drivers\etc\hosts文本,末行添加如下信息

192.168.157.140 www.openlab.com

3、测试

在windows浏览器上搜索http://www.openlab.com

出现以上界面,配置完成。

二、给该公司创建三个子界面分别显示学生信息,教学资料和缴费网站。

基于[www.openlab.com/student](http://www.openlab.com/student) 网站访问学生信息,[www.openlab.com/data](http://www.openlab.com/data)网站访问教学资料,网站访问缴费网站(http://www.openlab.com/monev网站访问缴费网站)。

要求如下:

(1)学生信息网站只有song和tian两人可以访问,其他用户不能访问。
(2)访问缴费网站实现数据加密基于https访问。

 1、准备服务端(采用OpenEuler系统)

2、具体配置

#下载nginx
[root@server ~]# yum install  nginx  -y 

#关闭防火墙
1、[root@server ~]# systemctl stop firewalld
2、[root@server ~]# setenforce 0

#修改配置文件
[root@server ~]# vim /etc/nginx/conf.d/test_alias.conf 
server {
        listen 192.168.157.140:80;
        root /www/name/node1;
        server_name www.openlab.com;
        location /student/ {
                alias /openlab/student/;
                auth_basic on;
		        auth_basic_user_file /etc/nginx/users;
        }
        location /data/ {
                alias /openlab/data/;
}

#创建网页目录
[root@server ~]# mkdir /openlab/student -pv
[root@server ~]# mkdir /openlab/data
[root@server ~]# mkdir /openlab/monev

#写入网页内容
[root@server ~]# echo this is student > /openlab/student/index.html
[root@server ~]# echo this is data > /openlab/data/index.html
[root@server ~]# echo this is monev > /openlab/monev/index.html

#(1)通过如下方式查看htpasswd命令的包名并下载该包
[root@server ~]# yum provides htpasswd
[root@server ~]# yum install httpd-tools

#添加song和tian两个用户
[root@server ~]# htpasswd  -c /etc/nginx/users song
New password: 
Re-type new password: 
Adding password for user song
[root@server ~]# htpasswd  -c /etc/nginx/users tian
New password: 
Re-type new password: 
Adding password for user tian

#(2)安装对应的包
[root@server ~]# yum update

#修改https配置文件
[root@server ~]# vim /etc/nginx/conf.d/test_https.conf 
server {
        listen 192.168.157.140:443 ssl;
        root /www/name/node1;
        server_name www.openlab.com;
        ssl_certificate /etc/pki/tls/certs/openlab.crt;#签名证书文件
        ssl_certificate_key /etc/pki/tls/private/openlab.key;#私钥文件
        location /monev/ {
                alias /openlab/monev/;
        }
}

#切换到签名证书文件目录(/etc/pki/tls/certs)做以下处理
[root@server ~]# openssl genrsa 2048 > ../private/openlab.key
[root@server ~]# openssl req -utf8 -new -key ../private/openlab.key -x509 -days 365 -out openlab.crt 

#重启nginx
[root@server ~]# systemctl restart nginx

3、测试

在windows浏览器上搜索http://www.openlab.com/student/

搜索http://www.openlab.com/data/

搜索https://www.openlab.com/monev/

出现以上界面,配置完成。

三、架设一台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可以完全访问该目录

1、准备服务端、客户端(采用OpenEuler系统)

2、服务端具体配置

#安装相关的包
[root@server ~]# yum install rpcbind
[root@server ~]# yum install nfs-utils

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

#启动程序
[root@server ~]# systemctl start nfs-server

#创建目录
[root@server ~]# mkdir /nfs/shared -pv
[root@server ~]# mkdir /nfs/upload
[root@server ~]# useradd /home/tom 

#编写共享文件相关配置
[root@server ~]# vim /etc/exports
/nfs/shared *(ro)
/nfs/upload 192.168.157.0/24(rw,all_squash,anonuid=210,anongid=210)
/home/tom 192.168.157.138(rw)

#添加一个gid、uid=210的nfs-upload映射
[root@server ~]# groupadd nfs-upload -g 210 
[root@server ~]# useradd nfs-upload -u 210 -g 210

#使对应网段的客户端用户都有上传的权限
[root@server ~]# chmod o+w /nfs/upload

[root@server ~]# exportfs -r 

3、客户端测试

#安装相应的包
[root@client ~]# yum install nfs-utils

#创建挂载的目录
[root@client ~]# mkdir /a1
[root@client ~]# mkdir /a2
[root@client ~]# mkdir /a3

#挂载
[root@client ~]# mount   192.168.157.140:/nfs/shared  /a1
[root@client ~]# mount   192.168.157.140:/nfs/upload  /a2
[root@client ~]# mount   192.168.157.140:/home/tom  /a3

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值