web服务器和nfs服务器搭建

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

2、具体配置

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


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


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

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


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


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

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

192.168.137.129 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.具体配置
#下载nginx
[root@csa ~]# yum install  nginx  -y 
 
#关闭防火墙
1、[root@csa ~]# systemctl stop firewalld
2、[root@csa ~]# setenforce 0
 
#修改配置文件
[root@csa ~]# vim /etc/nginx/conf.d/test_alias.conf 
server {
        listen 192.168.137.129:22;
        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@csa ~]# mkdir /openlab/student -pv
[root@csa ~]# mkdir /openlab/data
[root@csa ~]# mkdir /openlab/monev
 
#写入网页内容
[root@csa ~]# echo this is student > /openlab/student/index.html
[root@csa ~]# echo this is data > /openlab/data/index.html
[root@csa ~]# echo this is monev > /openlab/monev/index.html
 
#(1)通过如下方式查看htpasswd命令的包名并下载该包
[root@csa ~]# yum provides htpasswd
[root@csa ~]# yum install httpd-tools
 
#添加song和tian两个用户
[root@csa ~]# htpasswd  -c /etc/nginx/users song
New password: 
Re-type new password: 
Adding password for user song
[root@csa ~]# htpasswd  -c /etc/nginx/users tian
New password: 
Re-type new password: 
Adding password for user tian
 
#(2)安装对应的包
[root@server ~]# yum update
 
#修改https配置文件
[root@csa ~]# vim /etc/nginx/conf.d/test_https.conf 
server {
        listen 192.168.137.129: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@csa ~]# openssl genrsa 2048 > ../private/openlab.key
[root@csa ~]# openssl req -utf8 -new -key ../private/openlab.key -x509 -days 365 -out openlab.crt 
 
#重启nginx
[root@csa ~]# systemctl restart nginx

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

#安装相关的包
[root@csa ~]# yum install rpcbind
[root@csa ~]# yum install nfs-utils
 
#关闭防火墙
[root@csa ~]# systemctl stop firewalld
[root@csa ~]# setenforce 0
 
#启动程序
[root@csa ~]# systemctl start nfs-server
 
#创建目录
[root@csa ~]# mkdir /nfs/shared -pv
[root@csa ~]# mkdir /nfs/upload
[root@csa ~]# mkdir /home/tom -pv
 
#编写共享文件相关配置
[root@csa ~]# 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@csa ~]# groupadd nfs-upload -g 210 
[root@csa ~]# useradd nfs-upload -u 210 -g 210
 
#使对应网段的客户端用户都有上传的权限
[root@csa ~]# chmod o+w /nfs/upload
 
[root@csa ~]# exportfs -r 

  • 7
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值