网站域名的设置,网站建设课程下载,宁波制作网站软件,wordpress修改网址第二次作业第三次作业
第二次作业
题目#xff1a; 网站需求#xff1a;
1.基于域名[www.openlab.com](http://www.openlab.com)可以访问网站内容为 welcome to openlab!!!
2.给该公司创建三个子界面分别显示学生信息#xff0c;教学资料和缴费网站#xff0c;基于[ww…第二次作业第三次作业
第二次作业
题目 网站需求
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访问。
步骤如下 1.关闭防火墙和关闭unix规则
[rootlocalhost ~]# systemctl stop firewalld
[rootlocalhost ~]# setenforce 0
当然还可以查看一下是否关闭好
[rootlocalhost ~]# systemctl status firewalld
2.开启nginx并查看一下我这里是安装好了的
[rootlocalhost ~]# systemctl start nginx
[rootlocalhost ~]# ps -aux | grep nginx --- 查看是否在运行nginx
3.在conf.d下面创建一个以.conf结尾的文件并写入信息
[rootlocalhost conf.d]# vim /etc/nginx/conf.d/openlab.conf
写入server {listen 192.168.81.132:80;root /www/name/openlab;server_name www.openlab.com;location / {index index.html;}
}
保存并退出
4.重启一下nginx
[rootlocalhost conf.d]# systemctl restart nginx
5.根据配置需要创建自定义文件
[rootlocalhost conf.d]# mkdir /www/openlab -pv
6.写入网站里面存放的信息
[rootlocalhost conf.d]# echo welcome to openlab\!\!\! /www/openlab/index.html
[rootlocalhost conf.d]# ll /www/openlab --- 查看一下是否创建成功
注意有符号的需要用\一起写
7.去本地主机域名/etc/hosts修改
192.168.81.132 www.openlab.com
8.修改主界面标签
[rootlocalhost ~]# semanage fcontext -a -t httpd_sys_content_t /www/openlab/index.html
[rootlocalhost ~]# restorecon /www/openlab/index.html
[rootlocalhost ~]# ll -Z /www/openlab/index.html --- 查看一下
-rw-r--r--. 1 root root unconfined_u:object_r:httpd_sys_content_t:s0 22 1月 18 09:16 /www/openlab/index.html 注意缺少semanage命令直接执行yum install semanage 没有包存在
通过以下命令可查到命令对应的包 重要命令
[rootlocalhost ~]# yum whatprovides /usr/sbin/semanage
Last metadata expiration check: 0:00:42 ago on 2024年01月18日 星期四 09时25分04秒.
policycoreutils-python-utils-3.3-8.oe2203sp3.noarch : Policy core...: python utilities for selinux
Repo : OS
Matched from:
Filename : /usr/sbin/semanage
policycoreutils-python-utils-3.3-8.oe2203sp3.noarch : Policy core...: python utilities for selinux
Repo : everything
Matched from:
Filename : /usr/sbin/semanage
[rootlocalhost ~]# yum install policycoreutils-python-utils-3.3-8.oe2203sp3.noarch 9.实现与客户端的测试连接
[rootlocalhost conf.d]# curl www.openlab.com
welcome to openlab!!!
证明该网站已经创建好啦 10.创建三个子目录学生信息、教学资源、缴费网站
[rootlocalhost ~]# mkdir /www/openlab/{data,money,student} -pv 10.写入信息
[rootlocalhost ~]# echo this is data /www/openlab/data/index.html
[rootlocalhost ~]# echo this is student /www/openlab/student/index.html
[rootlocalhost ~]# echo this is money /www/openlab/money/index.html
11.三个子界面也要更改标签
#对/www下面所有文件标签进行修改此方法好处不需要restorecon
[rootlocalhost ~]# chcon -t httpd_sys_content_t /www -R 12.查看一下三个子界面看看是否能正常访问 13.song和tian可以访问student网站所以要对该网站进行修改 14.创建/etc/nginx/users文件
首先要安装httpd
[rootlocalhost ~]# yum install httpd-tools
之后创建文件并添加用户song
[rootlocalhost ~]# htpasswd -c /etc/nginx/users song
New password:
Re-type new password:
Adding password for user song
添加用户tian
[rootlocalhost ~]# htpasswd /etc/nginx/users tian
New password:
Re-type new password:
Adding password for user tian
注意:创建第二个用户的时候不要用-c用了-c会覆盖前面那个用户 15.重启服务加载配置并测试一下
[rootlocalhost ~]# systemctl restart nginx
[rootlocalhost ~]# curl www.openlab.com/student/ -u song:123456
this is student
[rootlocalhost ~]# curl www.openlab.com/student/ -u song:123456
this is student 16.对money进行处理但是它是要加密所以我们要单独弄一个网站
由于在前面的步骤里面我把money弄在了第一个服务器里面以明文形式访问所以我要删除那条记录
[rootlocalhost ~]# rm -rf /www/openlab/money/
然后再/www下面重新创建一个目录
[rootlocalhost ~]# mkdir /www/money
[rootlocalhost ~]# echo this is money /www/money/index.html 17.然后创建证书和私钥文件
[rootlocalhost ~]# openssl genrsa -out /etc/pki/tls/private/openlab.key
[rootlocalhost ~]# openssl req -utf8 -new -key /etc/pki/tls/private/openlab.key -x509 -days 365 -out /etc/pki/tls/certs/openlab.crt 18.重启nginx服务
[rootlocalhost ~]# systemctl restart nginx 19.最后测试一下 注意money是加密文件所以访问的时候加-k忽略证书安全信息 第三次作业
题目 架设一台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.安装nfs-utils
[rootlocalhost ~]# yum install nfs-utils-2:2.5.4-15.oe2203sp3.x86_64
注意有时候找不到安装源就用yum provides nfs-utils 查看一下
2.创建一个文件
[rootlocalhost ~]# vim /etc/exports
/nfs/share *(ro)
/nfs/upload 192.168.81.0/24 (rw, all_squash,anonuid210,anongid210)
/home/tom 192.168.81.129(rw)
保存并退出~
3.创建自己配置的文件
[rootlocalhost ~]# mkdir /nfs/{shared,upload} -pv 4.让/nfs/upload文件下的都有有权限
[rootlocalhost ~]# chmod ow /nfs/upload/
5.所有用户及所属的组映射为nfs-upload,其UID和GID均为210
基于系统用户创建
[rootlocalhost ~]# useradd -r -u 210 nfs-upload 6.将/home/tom目录仅共享给192.168.xxx.xxx这台主机并只有用户tom可以完全访问该目录
[rootlocalhost ~]# useradd tom 7.重启一下
[rootlocalhost ~]# systemctl restart nfs-server 8.让用户端去访问一下信息
A.下载nfs-utils
[rootlocalhost ~]# yum install nfs-utils
B.创建目录
[rootlocalhost ~]# mkdir /1 /2 /3 C.将服务端创建的三个文件挂载到客户端上
[rootlocalhost ~]# mount 192.168.81.132:/nfs/shared /1
[rootlocalhost ~]# mount 192.168.81.132:/nfs/upload /2
[rootlocalhost ~]# mount 192.168.81.132:/home/tom /3 8.进行客户端测试