综合练习:请给openlab搭建web网站 网站需求:
1.基于域名www.openlab.com可以访问网站内容为
welcome to openlab!!!
2.给该公司创建三个子界面分别显示学生信息,教学资料 和缴费网站,基于,www.openlab.com/data网站访问教学 资料 www.openlab.com/money网站访问缴费网站。
3.要求 (1)学生信息网站只有song和tian两人可以访问,其他 用户 不能访问。 (2)访问缴费网站实现数据加密基于https访问。
第一步:准备工作
关闭安全软件 ,安装所需软件
[root@server ~]# yum install nginx httpd-tools -y
在 C:\Windows\System32\drivers\etc\hosts 文件中进行DNS映射
添加 192.168.48.130 www.openlab.com
第二步:创建www.openlab.com网站
创建网页目录及网页
在文件中添加如下内容
server { listen 80;
server_name www.openlab.com;
root /www/openlab; }
重新启动nginx,测试
[root@server ~]# systemctl start nginx
第三步:创建教学资料子网站www.openlab.com/data
创建网页目录及网页
在文件中添加如下内容
location /data { alias /www/openlab/data;
index index.html index.htm; }
重新启动nginx,测试
[root@server ~]# systemctl restart nginx
第四步:创建学生信息子网站www.openlab.com/studen t
创建网页目录及网页,设置登录账号song&tian ,密码123456&654321
在文件中添加如下内容
location /student { alias /www/openlab/student;
index index.html index.htm;
auth_basic "Please input password";
auth_basic_user_file /etc/nginx/passwd; }
重新启动nginx,测试
[root@server ~]# systemctl restart nginx
输入账号密码
登录
第五步:创建缴费子网站www.openlab.com/money
创建网页目录及网页
设置加密私钥的密码 123456
制作证书
[root@server ~] openssl req -utf8 -new -key /etc/nginx/money.key -x509 -days 365 -out /etc/nginx/money.crt
在文件中添加如下内容
server { listen 443 ssl http2;
server_name www.openlab.com;
location /money { alias /www/openlab/money;
index index.html index.htm; }
ssl_certificate "/etc/nginx/money.crt";
ssl_certificate_key "/etc/nginx/money.key"; }
重新启动nginx,测试
[root@server ~]# systemctl restart nginx