一、基本要求
网站需求:
1.基于域名www.openlab.com可以访问网站内容为 welcome to openlab!!!
2.给该公司创建三个子界面分别显示学生信息,教学资料 和缴费网站,基与www.openlab.com网站访问教学资料。
3.要求 (1)学生信息网站只有song和tian两人可以访问,其他 用户不能访问。 (2)访问缴费网站实现数据加密基于https访问。
二、具体操作
第一步:准备工作
# 恢复快照,关闭安全软件
# 安装所需软件
[root@server ~]# yum install nginx httpd-tools -y
# Windows的 C:\Windows\System32\drivers\etc\hosts 文件进 行DNS映射
192.168.192.138 www.openlab.com # 添加
第二步:创建www.openlab.com网站
# 创建网页目录以及网页
[root@server ~]# mkdir -p /www/openlab
[root@server ~]# echo 'welcom to openlab' > /www/openlab/index.html
# 修改配置文件
[root@server ~]# vim /etc/nginx/nginx.conf
[root@server ~]# systemctl start nginx
windows端测试
第三步:创建教学资料子网站www.openlab.com/data
mkdir /www/openlab/data
[root@server ~]# echo 'data' > /www/openlab/data/index.html
[root@server ~]# # 继续修改配置文件
[root@server ~]# vim /etc/nginx/nginx.conf
[root@server ~]# systemctl restart nginx
windows端 测试
第四步:创建学生信息子网站www.openlab.com/student
[root@server ~]# mkdir -p /www/openlab/student
[root@server ~]# echo 'student' > /www/openlab/student/index.html
[root@server ~]# useradd pyt
[root@server ~]# passwd pyt # 密码123456
[root@server ~]# useradd pyt
[root@server ~]# passwd pyt # 密码654321
[root@server ~]# htpasswd -c /etc/nginx/passwd hyy
[root@server ~]# htpasswd -c /etc/nginx/passwd zjj
# 修改配置文件
[root@server ~]# vim /etc/nginx/nginx.conf
[root@server ~]# systemctl restart nginx
windows端测试
输入用户名和密码后
第五步:创建缴费子网站www.openlab.com/money
[root@server ~]# mkdir -p /www/openlab/money
[root@server ~]# echo 'money' > /www/openlab/money/index.html
[root@server ~]# # 制作密钥
[root@server ~]# openssl genras -aes128 2048 > /etc/nginx/money.key
Invalid command 'genras'; type "help" for a list.
[root@server ~]# openssl genrsa -aes128 2048 > /etc/nginx/money.key
Generating RSA private key, 2048 bit long modulus (2 primes)
..........................+++++
........................................+++++
e is 65537 (0x010001)
Enter pass phrase:
Verifying - Enter pass phrase:
[root@server ~]# # 密码 123456
[root@server ~]# # 制作证书
[root@server ~]# openssl req -utf8 -new -key /etc/nginx/money.key -x509 -days 365 -out /etc/nginx/money.crt
Enter pass phrase for /etc/nginx/money.key:
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]:ningxia
Locality Name (eg, city) []:yinchuan
Organization Name (eg, company) [Internet Widgits Pty Ltd]:openlab
Organizational Unit Name (eg, section) []:RHCE
Common Name (e.g. server FQDN or YOUR name) []:hyyy1009@163.com
Email Address []:pyt@163.com
[root@server ~]# # 提取密钥
[root@server ~]# cd /etc/nginx/
[root@server nginx]# cp money.key money.key.org
[root@server nginx]# openssl rsa -in money.key.org -out money.key
Enter pass phrase for money.key.org:
writing RSA key
[root@server nginx]# # 修改配置文件
[root@server nginx]# vim /etc/nginx/nginx.conf
[root@server nginx]# systemctl restart nginx
windows端测试
综上所述,作业完成
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/yonah1627/article/details/137148978