1.基于域名[www.openlab.com](http://www.openlab.com)可以访问网站内容为 welcome to openlab!!!
创建文件
编辑文件
创建目录
添加内容
重启系统
更改host文件
在host追加域名
最后在网页查看及可
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两人可以访问,其他用户不能访问。
在学生信息网站编辑用户控制
[root@localhost ~]# systemctl restart nginx #重新加载nginx
[root@localhost ~]# htpasswd -c /etc/nginx/usrs song
New password:
Re-type new password:
Adding password for user song
[root@localhost ~]# htpasswd -c /etc/nginx/usrs tian
New password:
Re-type new password:
Adding password for user tian
(2)访问缴费网站实现数据加密基于https访问。
1.修改虚拟配置文件
[root@localhost certs]# vim /etc/nginx/conf.d/test_alias.conf
server {
listen 192.168.247.132:443 ssl;
root /www/name/openlab;
ssl_certificate /etc/pki/tls/certs/openlab.crt;
ssl_certificate_key /etc/pki/tls/private/openlab.key;
location /money/ {
alias /openlab/money/;
}
}
2.重启nginx,是否正常运行,创建/www/https文件夹
[root@localhost certs]# systemctl restart nginx
[root@localhost certs]# mkdir /www/https
[root@localhost certs]# echo this is https > /www/https/index.html
3.生成密钥文件
[root@localhost certs]# cd ../private
[root@localhost private]# openssl genrsa 2048 > openlab.key
[root@localhost private]# ll
总计 4
-rw-r--r--. 1 root root 1704 1月19日 08:55 openlab.key
4.生成证书
[root@localhost private]# cd ../certs/
[root@localhost certs]# openssl req -utf8 -new -key ../private/openlab.key -x509 -days 365 -out openlab.crt
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]:sichuan
Locality Name (eg, city) []:localhost
Organization Name (eg, company) [Internet Widgits Pty Ltd]:ii
Organizational Unit Name (eg, section) []:en
Common Name (e.g. server FQDN or YOUR name) []:ni
Email Address []:@amin.com
[root@localhost certs]# ll
总计 4
lrwxrwxrwx. 1 root root 49 9月21日 23:34 ca-bundle.crt -> /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem
lrwxrwxrwx. 1 root root 55 9月21日 23:34 ca-bundle.trust.crt -> /etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt
-rw-r--r--. 1 root root 1375 1月19日 09:00 openlab.crt
5.重启服务
[root@localhost certs]# systemctl restart nginx