web网站搭建
网站需求:
1.基于域名www.openlab.com可以访问网站内容为 welcome to openlab!!!
2.给该公司创建三个子界面分别显示学生信息,教学资料和缴费网站,基于www.openlab.com/student 网站访问学生信息,www.openlab.com/data网站访问教学资料 www.openlab.com/money网站访问缴费网站。
3.要求 (1)访问该网站http请求都通过https响应。 (2)学生信息网站只有song和tian两人可以访问,其他用户不能访问。
[root@localhost ~]# vim /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.30.131 www.openlab.com[root@localhost ~]# vim /etc/nginx/conf.d/host.conf
server {listen 443 ssl http2;listen [::]:443 ssl http2;server_name www.openlab.com;root /ssl;ssl_certificate "/etc/pki/nginx/openlab.crt"; ssl_certificate_key "/etc/pki/nginx/openlab.key"; ssl_session_cache shared:SSL:1m;ssl_session_timeout 10m;ssl_ciphers PROFILE=SYSTEM;ssl_prefer_server_ciphers on;
}
server{listen 80;server_name www.openlab.com;root /www/openlab;location /student{alias /stu;auth_basic "请登录用户";auth_basic_user_file /etc/nginx/userfile;index index.html;}location /data{alias /data;index index.html;}location /money{alias /money;index index.html;}
}
[root@localhost ~]# mkdir /www/openlab
[root@localhost ~]# echo "welcome to openlab!" > /www/openlab/index.html
[root@localhost ~]# mkdir /{stu,data,money}
[root@localhost ~]# echo hello student > /stu/index.html
[root@localhost ~]# echo this is data > /data/index.html
[root@localhost ~]# echo money money money > /money/index.html
[root@localhost ~]# systemctl restart nginx[root@localhost ~]# dnf install httpd-tools -y
[root@localhost ~]# touch /etc/nginx/userfile
[root@localhost ~]# htpasswd -c /etc/nginx/userfile song
[root@localhost ~]# htpasswd /etc/nginx/userfile tian[root@localhost ~]#mkdir /etc/pki/nginx
[root@localhost ~]#openssl genrsa 2048 > /etc/pki/nginx/openlab.key
[root@localhost ~]#openssl req -utf8 -new -key /etc/pki/nginx/openlab.key -x509 -days 365 -out /etc/pki/nginx/openlab.crt
[root@localhost ~]#mkdir mkdir /ssl
[root@localhost ~]#echo this is https > /ssl/index.html
[root@localhost ~]# systemctl restart nginx





